Skip to content

Commit b12e5e8

Browse files
[UI v2] feat: Adds action details for send-notification type (#16849)
1 parent 8077ed0 commit b12e5e8

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

ui-v2/src/components/automations/action-details/action-details.tsx

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Automation } from "@/api/automations";
2+
import type { BlockDocument } from "@/api/block-documents";
23
import type { Deployment } from "@/api/deployments";
34
import type { components } from "@/api/prefect";
45
import type { WorkPool } from "@/api/work-pools";
@@ -18,6 +19,7 @@ import { StateBadge } from "@/components/ui/state-badge";
1819
import { Typography } from "@/components/ui/typography";
1920
import {
2021
createFakeAutomation,
22+
createFakeBlockDocument,
2123
createFakeDeployment,
2224
createFakeWorkPool,
2325
createFakeWorkQueue,
@@ -40,7 +42,8 @@ const ACTION_TYPE_TO_STRING = {
4042
"pause-automation": "Pause automation",
4143
"resume-automation": "Resume automation",
4244
"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",
4447
"do-nothing": "Do nothing",
4548
} as const;
4649
type ActionLabel =
@@ -61,10 +64,11 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
6164
const label = ACTION_TYPE_TO_STRING[action.type];
6265
switch (action.type) {
6366
// Non-inferrable Actions
64-
case "do-nothing":
6567
case "cancel-flow-run":
6668
case "suspend-flow-run":
6769
case "resume-flow-run":
70+
case "call-webhook": // Not used
71+
case "do-nothing": // not used
6872
return <NoninferredAction label={label} />;
6973
// Inferable actions
7074
case "run-deployment":
@@ -121,7 +125,15 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
121125
);
122126
// Other actions
123127
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+
);
125137
case "change-flow-run-state":
126138
return (
127139
<ChangeFlowRunStateActionDetails
@@ -130,8 +142,8 @@ export const ActionDetailsType = ({ action }: ActionDetailsProps) => {
130142
name={action.name}
131143
/>
132144
);
133-
case "call-webhook":
134-
return "TODO";
145+
default:
146+
return null;
135147
}
136148
};
137149

@@ -263,6 +275,36 @@ export const AutomationActionDetails = ({
263275
);
264276
};
265277

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+
266308
type WorkPoolActionDetailsProps = {
267309
label: ActionLabel;
268310
workPool: WorkPool;

ui-v2/src/components/ui/icons/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
AlignVerticalJustifyStart,
33
Ban,
44
Bot,
5+
Box,
56
Calendar,
67
Check,
78
ChevronDown,
@@ -35,6 +36,7 @@ export const ICONS = {
3536
AlignVerticalJustifyStart,
3637
Ban,
3738
Bot,
39+
Box,
3840
Calendar,
3941
Check,
4042
ChevronDown,

0 commit comments

Comments
 (0)