Skip to content

Commit

Permalink
send resetType in request body for batch reset (#2110)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rossedfort authored May 14, 2024
1 parent 285beb8 commit e602976
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/i18n/locales/en/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
16 changes: 15 additions & 1 deletion src/lib/services/batch-service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
},
};
}
}
Expand Down

0 comments on commit e602976

Please sign in to comment.