Skip to content

Commit f1167dd

Browse files
authored
Add reset workflow action (#871)
Add reset action
1 parent 71c3aca commit f1167dd

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

src/config/dynamic/resolvers/schemas/resolver-schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const resolverSchemas: ResolverSchemas = {
3939
cancel: workflowActionsEnabledValueSchema,
4040
terminate: workflowActionsEnabledValueSchema,
4141
restart: workflowActionsEnabledValueSchema,
42+
reset: workflowActionsEnabledValueSchema,
4243
}),
4344
},
4445
EXTENDED_DOMAIN_INFO_ENABLED: {

src/config/dynamic/resolvers/workflow-actions-enabled.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export default async function workflowActionsEnabled(
1414
terminate: 'ENABLED',
1515
cancel: 'ENABLED',
1616
restart: 'ENABLED',
17+
reset: 'ENABLED',
1718
};
1819
}

src/config/dynamic/resolvers/workflow-actions-enabled.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type WORKFLOW_ACTIONS_DISABLED_VALUES_CONFIG from './workflow-actions-disabled-values.config';
22

3-
export type WorkflowActionID = 'cancel' | 'terminate' | 'restart';
3+
export type WorkflowActionID = 'cancel' | 'terminate' | 'restart' | 'reset';
44

55
export type WorkflowActionsEnabledResolverParams = {
66
domain: string;

src/utils/config/__fixtures__/resolved-config-values.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const mockResolvedConfigValues: LoadedConfigResolvedValues = {
3131
terminate: 'ENABLED',
3232
cancel: 'ENABLED',
3333
restart: 'ENABLED',
34+
reset: 'ENABLED',
3435
},
3536
EXTENDED_DOMAIN_INFO_ENABLED: {
3637
metadata: false,

src/views/workflow-actions/__fixtures__/workflow-actions-config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const mockWorkflowActionsConfig: [
4949
renderSuccessMessage: () => 'Mock terminate notification',
5050
},
5151
{
52-
id: 'restart', // TODO: rename to reset
52+
id: 'reset',
5353
label: 'Mock reset',
5454
subtitle: 'Mock reset a workflow execution',
5555
modal: {

src/views/workflow-actions/config/workflow-actions.config.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,33 @@ import {
44
MdHighlightOff,
55
MdPowerSettingsNew,
66
MdOutlineRestartAlt,
7+
MdRefresh,
78
} from 'react-icons/md';
89

910
import { type CancelWorkflowResponse } from '@/route-handlers/cancel-workflow/cancel-workflow.types';
11+
import { type ResetWorkflowResponse } from '@/route-handlers/reset-workflow/reset-workflow.types';
1012
import { type RestartWorkflowResponse } from '@/route-handlers/restart-workflow/restart-workflow.types';
1113
import { type TerminateWorkflowResponse } from '@/route-handlers/terminate-workflow/terminate-workflow.types';
1214

1315
import getWorkflowIsCompleted from '../../workflow-page/helpers/get-workflow-is-completed';
1416
import WorkflowActionNewRunSuccessMsg from '../workflow-action-new-run-success-msg/workflow-action-new-run-success-msg';
17+
import { resetWorkflowFormSchema } from '../workflow-action-reset-form/schemas/reset-workflow-form-schema';
18+
import WorkflowActionResetForm from '../workflow-action-reset-form/workflow-action-reset-form';
19+
import {
20+
type ResetWorkflowSubmissionData,
21+
type ResetWorkflowFormData,
22+
} from '../workflow-action-reset-form/workflow-action-reset-form.types';
1523
import { type WorkflowAction } from '../workflow-actions.types';
1624

1725
const workflowActionsConfig: [
1826
WorkflowAction<any, any, CancelWorkflowResponse>,
1927
WorkflowAction<any, any, TerminateWorkflowResponse>,
2028
WorkflowAction<any, any, RestartWorkflowResponse>,
29+
WorkflowAction<
30+
ResetWorkflowFormData,
31+
ResetWorkflowSubmissionData,
32+
ResetWorkflowResponse
33+
>,
2134
] = [
2235
{
2336
id: 'cancel',
@@ -80,6 +93,31 @@ const workflowActionsConfig: [
8093
successMessage: 'Workflow has been restarted.',
8194
}),
8295
},
96+
{
97+
id: 'reset',
98+
label: 'Reset',
99+
subtitle: 'Reset a workflow execution',
100+
modal: {
101+
text: [
102+
'Resets a workflow by creating a new execution with a fresh Run ID starting from a specific decision completion event.',
103+
],
104+
docsLink: {
105+
text: 'Read more about resetting workflows',
106+
href: 'https://cadenceworkflow.io/docs/cli#workflow-reset',
107+
},
108+
form: WorkflowActionResetForm,
109+
formSchema: resetWorkflowFormSchema,
110+
transformFormDataToSubmission: (v) => v,
111+
},
112+
icon: MdRefresh,
113+
getRunnableStatus: () => 'RUNNABLE',
114+
apiRoute: 'reset',
115+
renderSuccessMessage: (props) =>
116+
createElement(WorkflowActionNewRunSuccessMsg, {
117+
...props,
118+
successMessage: 'Workflow has been reset.',
119+
}),
120+
},
83121
] as const;
84122

85123
export default workflowActionsConfig;

src/views/workflow-actions/workflow-actions-menu/__tests__/workflow-actions-menu.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe(WorkflowActionsMenu.name, () => {
6464
cancel: 'DISABLED_DEFAULT',
6565
terminate: 'DISABLED_DEFAULT',
6666
restart: 'ENABLED',
67+
reset: 'ENABLED',
6768
},
6869
});
6970

0 commit comments

Comments
 (0)