Update task run to not display NaN seconds

pull/13767/head
Palak Bhojani 2019-05-02 19:27:36 -07:00
parent 93c07f39a8
commit aa7a65d81e
2 changed files with 12 additions and 1 deletions

View File

@ -490,9 +490,15 @@ export const taskImportSuccess = (): Notification => ({
})
export const taskRunSuccess = (): Notification => ({
...defaultErrorNotification,
duration: FIVE_SECONDS,
message: 'Task scheduled successfully',
})
export const taskRunFailed = (error: string): Notification => ({
...defaultSuccessNotification,
duration: FIVE_SECONDS,
message: 'Task ran successfully',
message: `Failed to run task: ${error}`,
})
export const taskGetFailed = (error: string): Notification => ({

View File

@ -501,6 +501,8 @@ export const runTask = (taskID: string) => async dispatch => {
await client.tasks.startRunByTaskID(taskID)
dispatch(notify(taskRunSuccess()))
} catch (error) {
const message = getErrorMessage(error)
dispatch(notify(copy.taskRunFailed(message)))
console.error(error)
}
}
@ -558,6 +560,9 @@ export const createTaskFromTemplate = (template: ITaskTemplate) => async (
export const runDuration = (finishedAt: Date, startedAt: Date): string => {
let timeTag = 'seconds'
if (isNaN(finishedAt.getTime()) || isNaN(startedAt.getTime())) {
return ''
}
let diff = (finishedAt.getTime() - startedAt.getTime()) / 1000
if (diff > 60) {