5
5
MdPowerSettingsNew ,
6
6
MdOutlineRestartAlt ,
7
7
MdRefresh ,
8
+ MdOutlineWifiTethering ,
8
9
} from 'react-icons/md' ;
9
10
10
11
import { type CancelWorkflowResponse } from '@/route-handlers/cancel-workflow/cancel-workflow.types' ;
@@ -20,6 +21,12 @@ import {
20
21
type ResetWorkflowSubmissionData ,
21
22
type ResetWorkflowFormData ,
22
23
} from '../workflow-action-reset-form/workflow-action-reset-form.types' ;
24
+ import { signalWorkflowFormSchema } from '../workflow-action-signal-form/schemas/signal-workflow-form-schema' ;
25
+ import WorkflowActionSignalForm from '../workflow-action-signal-form/workflow-action-signal-form' ;
26
+ import {
27
+ type SignalWorkflowSubmissionData ,
28
+ type SignalWorkflowFormData ,
29
+ } from '../workflow-action-signal-form/workflow-action-signal-form.types' ;
23
30
import { type WorkflowAction } from '../workflow-actions.types' ;
24
31
25
32
const cancelWorkflowActionConfig : WorkflowAction < CancelWorkflowResponse > = {
@@ -69,6 +76,37 @@ const terminateWorkflowActionConfig: WorkflowAction<TerminateWorkflowResponse> =
69
76
renderSuccessMessage : ( ) => 'Workflow has been terminated.' ,
70
77
} ;
71
78
79
+ const signalWorkflowActionConfig : WorkflowAction <
80
+ unknown ,
81
+ SignalWorkflowFormData ,
82
+ SignalWorkflowSubmissionData
83
+ > = {
84
+ id : 'signal' ,
85
+ label : 'Signal' ,
86
+ subtitle : 'Send a signal to the workflow' ,
87
+ modal : {
88
+ text : 'Provide data to running workflows using signals' ,
89
+ docsLink : {
90
+ text : 'Learn more about signals' ,
91
+ href : 'https://cadenceworkflow.io/docs/go-client/signals' ,
92
+ } ,
93
+ withForm : true ,
94
+ form : WorkflowActionSignalForm ,
95
+ formSchema : signalWorkflowFormSchema ,
96
+ transformFormDataToSubmission : ( formData ) => formData ,
97
+ } ,
98
+ icon : MdOutlineWifiTethering ,
99
+ getRunnableStatus : ( workflow ) =>
100
+ getWorkflowIsCompleted (
101
+ workflow . workflowExecutionInfo ?. closeEvent ?. attributes ?? ''
102
+ )
103
+ ? 'NOT_RUNNABLE_WORKFLOW_CLOSED'
104
+ : 'RUNNABLE' ,
105
+ apiRoute : 'signal' ,
106
+ renderSuccessMessage : ( { inputParams } ) =>
107
+ `Successfully sent signal "${ inputParams . submissionData . signalName } "` ,
108
+ } ;
109
+
72
110
const restartWorkflowActionConfig : WorkflowAction < RestartWorkflowResponse > = {
73
111
id : 'restart' ,
74
112
label : 'Restart' ,
@@ -136,6 +174,7 @@ export const resetWorkflowActionConfig: WorkflowAction<
136
174
const workflowActionsConfig = [
137
175
cancelWorkflowActionConfig ,
138
176
terminateWorkflowActionConfig ,
177
+ signalWorkflowActionConfig ,
139
178
restartWorkflowActionConfig ,
140
179
resetWorkflowActionConfig ,
141
180
] as const satisfies WorkflowAction < any , any , any > [ ] ;
0 commit comments