From b320645459741a1adb0eb99cb40a899ca1bfb5a9 Mon Sep 17 00:00:00 2001 From: Laura Whitaker Date: Fri, 2 Jun 2023 13:17:48 -0600 Subject: [PATCH] [DT-1051] Add identity and reason to Terminate in the UI (#1399) * Fix extra space if there is no user defined reason * Add Web UI reason to terminate and reset on workflow * Add identity to terminate workflow * Remove workflow and use workflows namespace instead * Refactor reason and placeholder into utils with tests * Fix batch cancel toast translation * Add identity to terminateWorkflows --- src/lib/components/workflow-actions.svelte | 16 ++- .../batch-operation-confirmation-modal.svelte | 34 +----- src/lib/i18n/locales/en/workflows.ts | 7 +- src/lib/models/workflow-actions.ts | 6 + .../pages/workflows-with-new-search.svelte | 5 +- src/lib/services/batch-service.ts | 4 +- src/lib/services/workflow-service.ts | 7 +- src/lib/utilities/workflow-actions.test.ts | 112 ++++++++++++++++++ src/lib/utilities/workflow-actions.ts | 50 ++++++++ static/i18n/locales/en/workflows.json | 7 +- 10 files changed, 207 insertions(+), 41 deletions(-) create mode 100644 src/lib/utilities/workflow-actions.test.ts create mode 100644 src/lib/utilities/workflow-actions.ts diff --git a/src/lib/components/workflow-actions.svelte b/src/lib/components/workflow-actions.svelte index c3918bd18..eaefb5837 100644 --- a/src/lib/components/workflow-actions.svelte +++ b/src/lib/components/workflow-actions.svelte @@ -5,7 +5,10 @@ signalWorkflow, terminateWorkflow, } from '$lib/services/workflow-service'; + import { authUser } from '$lib/stores/auth-user'; + import { formatReason } from '$lib/utilities/workflow-actions'; + import { Action } from '$lib/models/workflow-actions'; import { writeActionsAreAllowed } from '$lib/utilities/write-actions-are-allowed'; import { ResetReapplyType } from '$lib/models/workflow-actions'; @@ -90,7 +93,12 @@ terminateWorkflow({ workflow, namespace, - reason, + reason: formatReason({ + action: Action.Terminate, + reason, + email: $authUser.email, + }), + identity: $authUser.email, }) .then(handleSuccessfulTermination) .catch(handleTerminationError); @@ -153,7 +161,11 @@ workflowId: workflow.id, runId: workflow.runId, eventId: resetId, - reason: resetReason, + reason: formatReason({ + action: Action.Reset, + reason: resetReason, + email: $authUser.email, + }), resetReapplyType, }); diff --git a/src/lib/components/workflow/batch-operation-confirmation-modal.svelte b/src/lib/components/workflow/batch-operation-confirmation-modal.svelte index ce001c7af..aac326838 100644 --- a/src/lib/components/workflow/batch-operation-confirmation-modal.svelte +++ b/src/lib/components/workflow/batch-operation-confirmation-modal.svelte @@ -1,10 +1,3 @@ - -