From 13ff4e1d26183b7817adcfb21d6c4910a2080550 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 2 May 2024 21:45:03 -0300 Subject: [PATCH] Add openDelete state and button to CollectionCardComponent --- .../src/components/cardComponent/index.tsx | 42 ++++++++++++------- .../modals/deleteConfirmationModal/index.tsx | 6 ++- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index e6e90483f..8b3510f45 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -61,6 +61,7 @@ export default function CollectionCardComponent({ const setNodes = useFlowStore((state) => state.setNodes); const setEdges = useFlowStore((state) => state.setEdges); const [openPlayground, setOpenPlayground] = useState(false); + const [openDelete, setOpenDelete] = useState(false); const setCurrentFlowId = useFlowsManagerStore( (state) => state.setCurrentFlowId ); @@ -105,18 +106,16 @@ export default function CollectionCardComponent({ addFlow(true, newFlow) .then((id) => { setSuccessData({ - title: `${name} ${ - isStore ? "Downloaded" : "Installed" - } Successfully.`, + title: `${name} ${isStore ? "Downloaded" : "Installed" + } Successfully.`, }); setLoading(false); }) .catch((error) => { setLoading(false); setErrorData({ - title: `Error ${ - isStore ? "downloading" : "installing" - } the ${name}`, + title: `Error ${isStore ? "downloading" : "installing" + } the ${name}`, list: [error["response"]["data"]["detail"]], }); }); @@ -236,16 +235,17 @@ export default function CollectionCardComponent({ )} {onDelete && data?.metadata === undefined && ( - { - onDelete(); + )} @@ -485,6 +485,18 @@ export default function CollectionCardComponent({ <> )} + {openDelete && ( + { + if(onDelete) onDelete(); + }} + > + <> + + ) + } ); } diff --git a/src/frontend/src/modals/deleteConfirmationModal/index.tsx b/src/frontend/src/modals/deleteConfirmationModal/index.tsx index 3621e27cf..e412e741a 100644 --- a/src/frontend/src/modals/deleteConfirmationModal/index.tsx +++ b/src/frontend/src/modals/deleteConfirmationModal/index.tsx @@ -15,14 +15,18 @@ export default function DeleteConfirmationModal({ onConfirm, description, asChild, + open, + setOpen, }: { children: JSX.Element; onConfirm: (e: React.MouseEvent) => void; description?: string; asChild?: boolean; + open?: boolean; + setOpen?: (open: boolean) => void; }) { return ( - + {children}