Skip to content

Commit 531fbbe

Browse files
committed
feat(ui): add error prop to Destructive block component
Adds optional error?: string | null to DestructiveProps so section machines can surface async failure messages inside the confirm dialog.
1 parent 1656137 commit 531fbbe

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/ui/src/mosaic/block/destructive.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface DestructiveProps {
1717
resourceName: string;
1818
onDelete: () => void | Promise<void>;
1919
isDeleting: boolean;
20+
error?: string | null;
2021
}
2122

2223
export function Destructive({
@@ -29,6 +30,7 @@ export function Destructive({
2930
resourceName,
3031
onDelete,
3132
isDeleting,
33+
error,
3234
}: DestructiveProps) {
3335
const [confirmValue, setConfirmValue] = useState('');
3436
const canSubmit = confirmValue === resourceName && !isDeleting;
@@ -52,6 +54,18 @@ export function Destructive({
5254
<>
5355
<Dialog.Title render={p => <Heading {...p} />}>{title}</Dialog.Title>
5456
<Dialog.Description render={p => <Text {...p} />}>{description}</Dialog.Description>
57+
{error && (
58+
<Box
59+
render={p => <p {...p} />}
60+
sx={t => ({
61+
...t.text('sm'),
62+
color: t.color.destructive,
63+
marginBlockStart: t.spacing(2),
64+
})}
65+
>
66+
{error}
67+
</Box>
68+
)}
5569
<form onSubmit={handleSubmit}>
5670
<Box
5771
render={p => <label {...p} />}

0 commit comments

Comments
 (0)