1
1
import type { Automation } from "@/api/automations" ;
2
+ import type { BlockDocument } from "@/api/block-documents" ;
2
3
import type { Deployment } from "@/api/deployments" ;
3
4
import type { components } from "@/api/prefect" ;
4
5
import type { WorkPool } from "@/api/work-pools" ;
@@ -18,6 +19,7 @@ import { StateBadge } from "@/components/ui/state-badge";
18
19
import { Typography } from "@/components/ui/typography" ;
19
20
import {
20
21
createFakeAutomation ,
22
+ createFakeBlockDocument ,
21
23
createFakeDeployment ,
22
24
createFakeWorkPool ,
23
25
createFakeWorkQueue ,
@@ -40,7 +42,8 @@ const ACTION_TYPE_TO_STRING = {
40
42
"pause-automation" : "Pause automation" ,
41
43
"resume-automation" : "Resume automation" ,
42
44
"call-webhook" : "Call a custom webhook notification" ,
43
- "send-notification" : "Send a notification" ,
45
+ /** Default string if `block_type_name` is not found. */
46
+ "send-notification" : "Send a notification using" ,
44
47
"do-nothing" : "Do nothing" ,
45
48
} as const ;
46
49
type ActionLabel =
@@ -61,10 +64,11 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
61
64
const label = ACTION_TYPE_TO_STRING [ action . type ] ;
62
65
switch ( action . type ) {
63
66
// Non-inferrable Actions
64
- case "do-nothing" :
65
67
case "cancel-flow-run" :
66
68
case "suspend-flow-run" :
67
69
case "resume-flow-run" :
70
+ case "call-webhook" : // Not used
71
+ case "do-nothing" : // not used
68
72
return < NoninferredAction label = { label } /> ;
69
73
// Inferable actions
70
74
case "run-deployment" :
@@ -121,7 +125,15 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
121
125
) ;
122
126
// Other actions
123
127
case "send-notification" :
124
- return "TODO" ;
128
+ // TODO: Pass a real block document from API
129
+ return (
130
+ < BlockDocumentActionDetails
131
+ label = { label }
132
+ blockDocument = { createFakeBlockDocument ( {
133
+ block_type_name : "Mattermost Webhook" ,
134
+ } ) }
135
+ />
136
+ ) ;
125
137
case "change-flow-run-state" :
126
138
return (
127
139
< ChangeFlowRunStateActionDetails
@@ -130,8 +142,8 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
130
142
name = { action . name }
131
143
/>
132
144
) ;
133
- case "call-webhook" :
134
- return "TODO" ;
145
+ default :
146
+ return null ;
135
147
}
136
148
} ;
137
149
@@ -263,6 +275,36 @@ export const AutomationActionDetails = ({
263
275
) ;
264
276
} ;
265
277
278
+ type BlockDocumentActionDetailsProps = {
279
+ label : ActionLabel ;
280
+ blockDocument : BlockDocument ;
281
+ } ;
282
+ export const BlockDocumentActionDetails = ( {
283
+ label,
284
+ blockDocument,
285
+ } : BlockDocumentActionDetailsProps ) => {
286
+ if ( ! blockDocument . name ) {
287
+ return < Typography > Block not found</ Typography > ;
288
+ }
289
+
290
+ const _label = blockDocument . block_type_name
291
+ ? `Send a ${ blockDocument . block_type_name . toLowerCase ( ) } using`
292
+ : label ;
293
+
294
+ return (
295
+ < ActionResource >
296
+ < label > { _label } </ label >
297
+ < Link
298
+ to = "/blocks/block/$id"
299
+ params = { { id : blockDocument . id } }
300
+ aria-label = { blockDocument . name }
301
+ >
302
+ < ActionResourceName iconId = "Box" name = { blockDocument . name } />
303
+ </ Link >
304
+ </ ActionResource >
305
+ ) ;
306
+ } ;
307
+
266
308
type WorkPoolActionDetailsProps = {
267
309
label : ActionLabel ;
268
310
workPool : WorkPool ;
0 commit comments