-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1503 from HubSpot/dont-link-nonexistent-logs
Don't show logs panel if task never running
- Loading branch information
Showing
4 changed files
with
113 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { PropTypes } from 'react'; | ||
import Utils from '../../utils'; | ||
import TaskStatus from './TaskStatus'; | ||
|
||
const labelText = (status, currentState, cleanupType) => { | ||
if (status === TaskStatus.NEVER_RAN) { | ||
return 'Task aborted'; | ||
} else if (cleanupType) { | ||
return `${Utils.humanizeText(currentState)} (${Utils.humanizeText(cleanupType)})`; | ||
} | ||
|
||
return Utils.humanizeText(currentState); | ||
}; | ||
|
||
const labelClass = (status, currentState) => { | ||
if (status === TaskStatus.NEVER_RAN) { | ||
return 'info'; | ||
} | ||
|
||
return Utils.getLabelClassFromTaskState(currentState); | ||
}; | ||
|
||
const TaskState = ({status, updates, cleanupType}) => { | ||
if (updates) { | ||
const currentState = _.last(updates).taskState; | ||
return ( | ||
<div className="col-xs-6 task-state-header"> | ||
<h1> | ||
<span className={`label label-${labelClass(status, currentState)} task-state-header-label`}> | ||
{labelText(status, currentState, cleanupType)} | ||
</span> | ||
</h1> | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
TaskState.propTypes = { | ||
status: PropTypes.oneOf([TaskStatus.RUNNING, TaskStatus.STOPPED, TaskStatus.NEVER_RAN]), | ||
updates: PropTypes.arrayOf(PropTypes.shape({ | ||
taskState: PropTypes.string | ||
})), | ||
cleanupType: PropTypes.string, | ||
}; | ||
|
||
export default TaskState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const RUNNING = 'RUNNING'; | ||
const STOPPED = 'STOPPED'; | ||
const NEVER_RAN = 'NEVER_RAN'; | ||
|
||
export default { | ||
RUNNING, | ||
STOPPED, | ||
NEVER_RAN | ||
}; |