Skip to content

Commit 14cf93b

Browse files
authored
Timeline reset workflow button (#881)
* Timeline reset workflow button * update button mini radius
1 parent 2f2abcb commit 14cf93b

File tree

7 files changed

+431
-147
lines changed

7 files changed

+431
-147
lines changed

src/config/theme/theme-light.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const themeLight = {
1616
backgroundWarningLight: '#FDF2DC',
1717
backgroundPositive: '#0E8345',
1818
},
19+
borders: {
20+
buttonBorderRadiusMini: '8px',
21+
},
1922
} satisfies DeepPartial<MakeExtendable<Theme>>;
2023

2124
export default themeLight;

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

Lines changed: 71 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,44 @@ import { type TerminateWorkflowResponse } from '@/route-handlers/terminate-workf
77

88
import { type WorkflowAction } from '../workflow-actions.types';
99

10-
export const mockWorkflowActionsConfig: [
11-
WorkflowAction<any, any, CancelWorkflowResponse>,
12-
WorkflowAction<any, any, TerminateWorkflowResponse>,
13-
WorkflowAction<
14-
{ testField: string },
15-
{ transformed: string },
16-
ResetWorkflowResponse
17-
>,
18-
] = [
10+
export const mockResetActionConfig: WorkflowAction<
11+
{ testField: string },
12+
{ transformed: string },
13+
ResetWorkflowResponse
14+
> = {
15+
id: 'reset',
16+
label: 'Mock reset',
17+
subtitle: 'Mock reset a workflow execution',
18+
modal: {
19+
text: 'Mock modal text to reset a workflow execution',
20+
docsLink: {
21+
text: 'Mock docs link',
22+
href: 'https://mock.docs.link',
23+
},
24+
form: ({ control, fieldErrors }) => (
25+
<div data-testid="mock-form">
26+
<input
27+
data-testid="test-input"
28+
aria-invalid={!!fieldErrors.testField}
29+
{...control.register('testField')}
30+
/>
31+
</div>
32+
),
33+
formSchema: z.object({
34+
testField: z.string().min(1),
35+
}),
36+
transformFormDataToSubmission: (data: { testField: string }) => ({
37+
transformed: data.testField,
38+
}),
39+
},
40+
icon: MdRefresh,
41+
getRunnableStatus: () => 'RUNNABLE',
42+
apiRoute: 'reset',
43+
renderSuccessMessage: ({ result }) =>
44+
`Mock reset notification (Run ID: ${result.runId})`,
45+
};
46+
47+
const mockCancelActionConfig: WorkflowAction<any, any, CancelWorkflowResponse> =
1948
{
2049
id: 'cancel',
2150
label: 'Mock cancel',
@@ -31,53 +60,39 @@ export const mockWorkflowActionsConfig: [
3160
getRunnableStatus: () => 'RUNNABLE',
3261
apiRoute: 'cancel',
3362
renderSuccessMessage: () => 'Mock cancel notification',
34-
},
35-
{
36-
id: 'terminate',
37-
label: 'Mock terminate',
38-
subtitle: 'Mock terminate a workflow execution',
39-
modal: {
40-
text: 'Mock modal text to terminate a workflow execution',
41-
docsLink: {
42-
text: 'Mock docs link',
43-
href: 'https://mock.docs.link',
44-
},
45-
},
46-
icon: MdPowerSettingsNew,
47-
getRunnableStatus: () => 'RUNNABLE',
48-
apiRoute: 'terminate',
49-
renderSuccessMessage: () => 'Mock terminate notification',
50-
},
51-
{
52-
id: 'reset',
53-
label: 'Mock reset',
54-
subtitle: 'Mock reset a workflow execution',
55-
modal: {
56-
text: 'Mock modal text to reset a workflow execution',
57-
docsLink: {
58-
text: 'Mock docs link',
59-
href: 'https://mock.docs.link',
60-
},
61-
form: ({ control, fieldErrors }) => (
62-
<div data-testid="mock-form">
63-
<input
64-
data-testid="test-input"
65-
aria-invalid={!!fieldErrors.testField}
66-
{...control.register('testField')}
67-
/>
68-
</div>
69-
),
70-
formSchema: z.object({
71-
testField: z.string().min(1),
72-
}),
73-
transformFormDataToSubmission: (data: { testField: string }) => ({
74-
transformed: data.testField,
75-
}),
63+
};
64+
65+
const mockTerminateActionConfig: WorkflowAction<
66+
any,
67+
any,
68+
TerminateWorkflowResponse
69+
> = {
70+
id: 'terminate',
71+
label: 'Mock terminate',
72+
subtitle: 'Mock terminate a workflow execution',
73+
modal: {
74+
text: 'Mock modal text to terminate a workflow execution',
75+
docsLink: {
76+
text: 'Mock docs link',
77+
href: 'https://mock.docs.link',
7678
},
77-
icon: MdRefresh,
78-
getRunnableStatus: () => 'RUNNABLE',
79-
apiRoute: 'reset',
80-
renderSuccessMessage: ({ result }) =>
81-
`Mock reset notification (Run ID: ${result.runId})`,
8279
},
80+
icon: MdPowerSettingsNew,
81+
getRunnableStatus: () => 'RUNNABLE',
82+
apiRoute: 'terminate',
83+
renderSuccessMessage: () => 'Mock terminate notification',
84+
};
85+
86+
export const mockWorkflowActionsConfig: [
87+
WorkflowAction<any, any, CancelWorkflowResponse>,
88+
WorkflowAction<any, any, TerminateWorkflowResponse>,
89+
WorkflowAction<
90+
{ testField: string },
91+
{ transformed: string },
92+
ResetWorkflowResponse
93+
>,
94+
] = [
95+
mockCancelActionConfig,
96+
mockTerminateActionConfig,
97+
mockResetActionConfig,
8398
] as const;

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

Lines changed: 104 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -22,102 +22,117 @@ import {
2222
} from '../workflow-action-reset-form/workflow-action-reset-form.types';
2323
import { type WorkflowAction } from '../workflow-actions.types';
2424

25-
const workflowActionsConfig: [
26-
WorkflowAction<any, any, CancelWorkflowResponse>,
27-
WorkflowAction<any, any, TerminateWorkflowResponse>,
28-
WorkflowAction<any, any, RestartWorkflowResponse>,
29-
WorkflowAction<
30-
ResetWorkflowFormData,
31-
ResetWorkflowSubmissionData,
32-
ResetWorkflowResponse
33-
>,
34-
] = [
35-
{
36-
id: 'cancel',
37-
label: 'Cancel',
38-
subtitle: 'Cancel a workflow execution',
39-
modal: {
40-
text: "Cancels a running workflow by scheduling a cancellation request in the workflow's history, giving it a chance to clean up.",
41-
docsLink: {
42-
text: 'Read more about cancelling workflows',
43-
href: 'https://cadenceworkflow.io/docs/cli#signal-cancel-terminate-workflow',
44-
},
25+
const cancelWorkflowActionConfig: WorkflowAction<
26+
any,
27+
any,
28+
CancelWorkflowResponse
29+
> = {
30+
id: 'cancel',
31+
label: 'Cancel',
32+
subtitle: 'Cancel a workflow execution',
33+
modal: {
34+
text: "Cancels a running workflow by scheduling a cancellation request in the workflow's history, giving it a chance to clean up.",
35+
docsLink: {
36+
text: 'Read more about cancelling workflows',
37+
href: 'https://cadenceworkflow.io/docs/cli#signal-cancel-terminate-workflow',
4538
},
46-
icon: MdHighlightOff,
47-
getRunnableStatus: (workflow) =>
48-
getWorkflowIsCompleted(
49-
workflow.workflowExecutionInfo?.closeEvent?.attributes ?? ''
50-
)
51-
? 'NOT_RUNNABLE_WORKFLOW_CLOSED'
52-
: 'RUNNABLE',
53-
apiRoute: 'cancel',
54-
renderSuccessMessage: () => 'Workflow cancellation has been requested.',
5539
},
56-
{
57-
id: 'terminate',
58-
label: 'Terminate',
59-
subtitle: 'Terminate a workflow execution',
60-
modal: {
61-
text: 'Terminates a running workflow immediately. Please terminate a workflow only if you know what you are doing.',
62-
docsLink: {
63-
text: 'Read more about terminating workflows',
64-
href: 'https://cadenceworkflow.io/docs/cli#signal-cancel-terminate-workflow',
65-
},
40+
icon: MdHighlightOff,
41+
getRunnableStatus: (workflow) =>
42+
getWorkflowIsCompleted(
43+
workflow.workflowExecutionInfo?.closeEvent?.attributes ?? ''
44+
)
45+
? 'NOT_RUNNABLE_WORKFLOW_CLOSED'
46+
: 'RUNNABLE',
47+
apiRoute: 'cancel',
48+
renderSuccessMessage: () => 'Workflow cancellation has been requested.',
49+
};
50+
51+
const terminateWorkflowActionConfig: WorkflowAction<
52+
any,
53+
any,
54+
TerminateWorkflowResponse
55+
> = {
56+
id: 'terminate',
57+
label: 'Terminate',
58+
subtitle: 'Terminate a workflow execution',
59+
modal: {
60+
text: 'Terminates a running workflow immediately. Please terminate a workflow only if you know what you are doing.',
61+
docsLink: {
62+
text: 'Read more about terminating workflows',
63+
href: 'https://cadenceworkflow.io/docs/cli#signal-cancel-terminate-workflow',
6664
},
67-
icon: MdPowerSettingsNew,
68-
getRunnableStatus: (workflow) =>
69-
getWorkflowIsCompleted(
70-
workflow.workflowExecutionInfo?.closeEvent?.attributes ?? ''
71-
)
72-
? 'NOT_RUNNABLE_WORKFLOW_CLOSED'
73-
: 'RUNNABLE',
74-
apiRoute: 'terminate',
75-
renderSuccessMessage: () => 'Workflow has been terminated.',
7665
},
77-
{
78-
id: 'restart',
79-
label: 'Restart',
80-
subtitle: 'Restart a workflow execution',
81-
modal: {
82-
text: [
83-
'Restarts a workflow by creating a new execution with a fresh Run ID while using the existing input. If the previous execution is still running, it will be terminated.',
84-
'What differentiates Restart from Reset is that the restarted workflow is not aware of the previous workflow execution.',
85-
],
86-
},
87-
icon: MdOutlineRestartAlt,
88-
getRunnableStatus: () => 'RUNNABLE',
89-
apiRoute: 'restart',
90-
renderSuccessMessage: (props) =>
91-
createElement(WorkflowActionNewRunSuccessMsg, {
92-
...props,
93-
successMessage: 'Workflow has been restarted.',
94-
}),
66+
icon: MdPowerSettingsNew,
67+
getRunnableStatus: (workflow) =>
68+
getWorkflowIsCompleted(
69+
workflow.workflowExecutionInfo?.closeEvent?.attributes ?? ''
70+
)
71+
? 'NOT_RUNNABLE_WORKFLOW_CLOSED'
72+
: 'RUNNABLE',
73+
apiRoute: 'terminate',
74+
renderSuccessMessage: () => 'Workflow has been terminated.',
75+
};
76+
77+
const restartWorkflowActionConfig: WorkflowAction<
78+
any,
79+
any,
80+
RestartWorkflowResponse
81+
> = {
82+
id: 'restart',
83+
label: 'Restart',
84+
subtitle: 'Restart a workflow execution',
85+
modal: {
86+
text: [
87+
'Restarts a workflow by creating a new execution with a fresh Run ID while using the existing input. If the previous execution is still running, it will be terminated.',
88+
'What differentiates Restart from Reset is that the restarted workflow is not aware of the previous workflow execution.',
89+
],
9590
},
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,
91+
icon: MdOutlineRestartAlt,
92+
getRunnableStatus: () => 'RUNNABLE',
93+
apiRoute: 'restart',
94+
renderSuccessMessage: (props) =>
95+
createElement(WorkflowActionNewRunSuccessMsg, {
96+
...props,
97+
successMessage: 'Workflow has been restarted.',
98+
}),
99+
};
100+
101+
export const resetWorkflowActionConfig: WorkflowAction<
102+
ResetWorkflowFormData,
103+
ResetWorkflowSubmissionData,
104+
ResetWorkflowResponse
105+
> = {
106+
id: 'reset',
107+
label: 'Reset',
108+
subtitle: 'Reset a workflow execution',
109+
modal: {
110+
text: [
111+
'Resets a workflow by creating a new execution with a fresh Run ID starting from a specific decision completion event.',
112+
],
113+
docsLink: {
114+
text: 'Read more about resetting workflows',
115+
href: 'https://cadenceworkflow.io/docs/cli#workflow-reset',
111116
},
112-
icon: MdRefresh,
113-
getRunnableStatus: () => 'RUNNABLE',
114-
apiRoute: 'reset',
115-
renderSuccessMessage: (props) =>
116-
createElement(WorkflowActionNewRunSuccessMsg, {
117-
...props,
118-
successMessage: 'Workflow has been reset.',
119-
}),
117+
form: WorkflowActionResetForm,
118+
formSchema: resetWorkflowFormSchema,
119+
transformFormDataToSubmission: (v) => v,
120120
},
121+
icon: MdRefresh,
122+
getRunnableStatus: () => 'RUNNABLE',
123+
apiRoute: 'reset',
124+
renderSuccessMessage: (props) =>
125+
createElement(WorkflowActionNewRunSuccessMsg, {
126+
...props,
127+
successMessage: 'Workflow has been reset.',
128+
}),
129+
};
130+
131+
const workflowActionsConfig = [
132+
cancelWorkflowActionConfig,
133+
terminateWorkflowActionConfig,
134+
restartWorkflowActionConfig,
135+
resetWorkflowActionConfig,
121136
] as const;
122137

123138
export default workflowActionsConfig;

0 commit comments

Comments
 (0)