From e602976b7e7faa0aab6578efa28d8b2a0ae4b6a8 Mon Sep 17 00:00:00 2001 From: Ross Edfort Date: Tue, 14 May 2024 10:09:26 -0600 Subject: [PATCH] send resetType in request body for batch reset (#2110) * send resetType in req body for batch reset for compatibility with older server/api versions * default reset type to first, clear up reason hint text --- .../batch-reset-confirmation-modal.svelte | 2 +- src/lib/i18n/locales/en/workflows.ts | 2 +- src/lib/services/batch-service.ts | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/components/workflow/client-actions/batch-reset-confirmation-modal.svelte b/src/lib/components/workflow/client-actions/batch-reset-confirmation-modal.svelte index 4ad022135..c51984f72 100644 --- a/src/lib/components/workflow/client-actions/batch-reset-confirmation-modal.svelte +++ b/src/lib/components/workflow/client-actions/batch-reset-confirmation-modal.svelte @@ -27,7 +27,7 @@ export let open = false; let error = ''; let jobIdPlaceholder = v4(); - let resetType = writable<'first' | 'last'>(); + let resetType = writable<'first' | 'last'>('first'); const reason = writable(''); const reasonPlaceholder = getPlacholder(Action.Reset, $authUser.email); const jobId = writable(''); diff --git a/src/lib/i18n/locales/en/workflows.ts b/src/lib/i18n/locales/en/workflows.ts index 58f44f622..109ab2dfc 100644 --- a/src/lib/i18n/locales/en/workflows.ts +++ b/src/lib/i18n/locales/en/workflows.ts @@ -30,7 +30,7 @@ export const Strings = { 'batch-reset-confirmation_other': 'Are you sure you want to reset {{count, number}} workflows?', 'batch-operation-confirmation-input-hint': - 'If you supply a custom reason, "{{placeholder}}" will be appended to it.', + 'If you supply a custom reason, "{{placeholder}}" will be appended to it. If you omit a reason, the placeholder will be used.', 'batch-terminate-all-success': 'The batch terminate request is processing in the background.', 'batch-cancel-all-success': diff --git a/src/lib/services/batch-service.ts b/src/lib/services/batch-service.ts index 0ae806c32..beec05541 100644 --- a/src/lib/services/batch-service.ts +++ b/src/lib/services/batch-service.ts @@ -1,5 +1,7 @@ import { get } from 'svelte/store'; +import { temporal } from '@temporalio/proto'; + import { Action } from '$lib/models/workflow-actions'; import { getAuthUser } from '$lib/stores/auth-user'; import { inProgressBatchOperation } from '$lib/stores/batch-operations'; @@ -27,6 +29,8 @@ import type { } from '$types/batch'; import type { WorkflowExecution } from '$types/workflows'; +const ResetType = temporal.api.enums.v1.ResetType; + type CreateBatchOperationOptions = { namespace: string; reason: string; @@ -75,8 +79,18 @@ const batchActionToOperation = ( resetType === 'first' ? { firstWorkflowTask: {} } : { lastWorkflowTask: {} }; + return { - resetOperation: { identity, options }, + resetOperation: { + identity, + // options is a new field for server versions 1.23 and later + options, + // resetType is a deprecated field for server versions 1.23 and earlier + resetType: + resetType === 'first' + ? ResetType.RESET_TYPE_FIRST_WORKFLOW_TASK + : ResetType.RESET_TYPE_LAST_WORKFLOW_TASK, + }, }; } }