From aa7a65d81ea8afe6457b1158b52c6ee3af1c5b5d Mon Sep 17 00:00:00 2001 From: Palak Bhojani Date: Thu, 2 May 2019 19:27:36 -0700 Subject: [PATCH] Update task run to not display NaN seconds --- ui/src/shared/copy/notifications.ts | 8 +++++++- ui/src/tasks/actions/index.ts | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/src/shared/copy/notifications.ts b/ui/src/shared/copy/notifications.ts index 1e734b15d5..cbfb149869 100644 --- a/ui/src/shared/copy/notifications.ts +++ b/ui/src/shared/copy/notifications.ts @@ -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 => ({ diff --git a/ui/src/tasks/actions/index.ts b/ui/src/tasks/actions/index.ts index d947d29c7f..9a61fa2ca0 100644 --- a/ui/src/tasks/actions/index.ts +++ b/ui/src/tasks/actions/index.ts @@ -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) {