Skip to content

Commit 67e2d20

Browse files
authored
feat: show task name in notification message (#4975)
1 parent 89bf363 commit 67e2d20

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/shared/copy/notifications/categories/tasks.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ export const taskCloneFailed = (
8181
message: `Failed to clone task ${taskName}: ${additionalMessage} `,
8282
})
8383

84-
export const taskUpdateFailed = (additionalMessage: string): Notification => ({
84+
export const taskUpdateFailed = (
85+
additionalMessage: string,
86+
taskName?: string
87+
): Notification => ({
8588
...defaultErrorNotification,
86-
message: `Failed to update task: ${additionalMessage}`,
89+
message: `Failed to update task ${
90+
taskName ? taskName : ''
91+
}: ${additionalMessage}`,
8792
})
8893

89-
export const taskUpdateSuccess = (): Notification => ({
94+
export const taskUpdateSuccess = (taskName?: string): Notification => ({
9095
...defaultSuccessNotification,
91-
message: 'Task was updated successfully',
96+
message: `Task ${taskName ? taskName : ''} was updated successfully`,
9297
})
9398

9499
export const taskImportFailed = (errorMessage: string): Notification => ({

src/tasks/actions/thunks.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('Tasks.Actions.Thunks', () => {
116116

117117
expect(dispatch.mock.calls[2][0].type).toBe('PUBLISH_NOTIFICATION')
118118
expect(dispatch.mock.calls[2][0].payload.notification).toEqual(
119-
taskUpdateSuccess()
119+
taskUpdateSuccess(sampleTask.name)
120120
)
121121
})
122122
})

src/tasks/actions/thunks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ export const updateTaskStatus = (task: Task) => async (
231231

232232
dispatch(editTask(normTask))
233233
dispatch(setCurrentTask(normTask))
234-
dispatch(notify(copy.taskUpdateSuccess()))
234+
dispatch(notify(copy.taskUpdateSuccess(task.name)))
235235
} catch (e) {
236236
console.error(e)
237237
const message = getErrorMessage(e)
238-
dispatch(notify(copy.taskUpdateFailed(message)))
238+
dispatch(notify(copy.taskUpdateFailed(message, task.name)))
239239
}
240240
}
241241

@@ -255,11 +255,11 @@ export const updateTaskName = (name: string, taskID: string) => async (
255255
)
256256

257257
dispatch(editTask(normTask))
258-
dispatch(notify(copy.taskUpdateSuccess()))
258+
dispatch(notify(copy.taskUpdateSuccess(name)))
259259
} catch (e) {
260260
console.error(e)
261261
const message = getErrorMessage(e)
262-
dispatch(notify(copy.taskUpdateFailed(message)))
262+
dispatch(notify(copy.taskUpdateFailed(message, name)))
263263
}
264264
}
265265

0 commit comments

Comments
 (0)