Skip to content

Commit 6c3f347

Browse files
committed
feat: add DFlowFolderDeleteDialog component for folder and flow removal confirmation
1 parent 207cfcf commit 6c3f347

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {Dialog, DialogClose, DialogContent, DialogPortal} from "../dialog/Dialog";
2+
import {Text} from "../text/Text";
3+
import {Badge} from "../badge/Badge";
4+
import {Flex} from "../flex/Flex";
5+
import {Button} from "../button/Button";
6+
import React from "react";
7+
import {DFlowFolderContextMenuGroupData, DFlowFolderContextMenuItemData} from "./DFlowFolderContextMenu";
8+
import {Flow} from "@code0-tech/sagittarius-graphql-types";
9+
10+
export interface DFlowFolderDeleteDialogProps {
11+
open?: boolean
12+
onOpenChange?: (open: boolean) => void
13+
contextData: DFlowFolderContextMenuGroupData | DFlowFolderContextMenuItemData
14+
onDelete?: (flow: Flow) => void
15+
}
16+
17+
export const DFlowFolderDeleteDialog: React.FC<DFlowFolderDeleteDialogProps> = (props) => {
18+
19+
const {open} = props
20+
21+
const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(open)
22+
23+
return <Dialog open={deleteDialogOpen} onOpenChange={(open) => setDeleteDialogOpen(open)}>
24+
<DialogPortal>
25+
<DialogContent autoFocus showCloseButton
26+
title={props.contextData.type == "item" ? "Remove flow" : "Remove folder"}>
27+
<Text size={"md"} hierarchy={"secondary"}>
28+
{props.contextData.type == "item" ? "Are you sure you want to remove flow" : "Are you sure you want to remove folder"} {" "}
29+
<Badge color={"info"}>
30+
<Text size={"md"} style={{color: "inherit"}}>{props.contextData.name}</Text>
31+
</Badge> {" "}
32+
{props.contextData.type == "folder" ? ", all flows and sub-folders inside " : ""}from the this
33+
project?
34+
</Text>
35+
<Flex justify={"space-between"} align={"center"}>
36+
<DialogClose asChild>
37+
<Button color={"secondary"}>No, go back!</Button>
38+
</DialogClose>
39+
<DialogClose asChild>
40+
<Button color={"error"} onClick={() => {
41+
if (props.contextData.type === "item") {
42+
props.onDelete?.(props.contextData.flow)
43+
} else if (props.contextData.type === "folder") {
44+
props.contextData.flow.forEach(flow => {
45+
props.onDelete?.(flow)
46+
})
47+
}
48+
}}>Yes, remove!</Button>
49+
</DialogClose>
50+
</Flex>
51+
</DialogContent>
52+
</DialogPortal>
53+
</Dialog>
54+
}

0 commit comments

Comments
 (0)