Add openDelete state and button to CollectionCardComponent
This commit is contained in:
parent
b7cfa211b3
commit
13ff4e1d26
2 changed files with 32 additions and 16 deletions
|
|
@ -61,6 +61,7 @@ export default function CollectionCardComponent({
|
||||||
const setNodes = useFlowStore((state) => state.setNodes);
|
const setNodes = useFlowStore((state) => state.setNodes);
|
||||||
const setEdges = useFlowStore((state) => state.setEdges);
|
const setEdges = useFlowStore((state) => state.setEdges);
|
||||||
const [openPlayground, setOpenPlayground] = useState(false);
|
const [openPlayground, setOpenPlayground] = useState(false);
|
||||||
|
const [openDelete, setOpenDelete] = useState(false);
|
||||||
const setCurrentFlowId = useFlowsManagerStore(
|
const setCurrentFlowId = useFlowsManagerStore(
|
||||||
(state) => state.setCurrentFlowId
|
(state) => state.setCurrentFlowId
|
||||||
);
|
);
|
||||||
|
|
@ -105,8 +106,7 @@ export default function CollectionCardComponent({
|
||||||
addFlow(true, newFlow)
|
addFlow(true, newFlow)
|
||||||
.then((id) => {
|
.then((id) => {
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: `${name} ${
|
title: `${name} ${isStore ? "Downloaded" : "Installed"
|
||||||
isStore ? "Downloaded" : "Installed"
|
|
||||||
} Successfully.`,
|
} Successfully.`,
|
||||||
});
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
@ -114,8 +114,7 @@ export default function CollectionCardComponent({
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title: `Error ${
|
title: `Error ${isStore ? "downloading" : "installing"
|
||||||
isStore ? "downloading" : "installing"
|
|
||||||
} the ${name}`,
|
} the ${name}`,
|
||||||
list: [error["response"]["data"]["detail"]],
|
list: [error["response"]["data"]["detail"]],
|
||||||
});
|
});
|
||||||
|
|
@ -236,16 +235,17 @@ export default function CollectionCardComponent({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{onDelete && data?.metadata === undefined && (
|
{onDelete && data?.metadata === undefined && (
|
||||||
<DeleteConfirmationModal
|
<button onClick={(e) => {
|
||||||
onConfirm={() => {
|
e.stopPropagation();
|
||||||
onDelete();
|
setOpenDelete(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Trash2"
|
name="Trash2"
|
||||||
className="h-5 w-5 text-primary opacity-0 transition-all hover:text-destructive group-hover:opacity-100"
|
className="h-5 w-5 text-primary opacity-0 transition-all hover:text-destructive group-hover:opacity-100"
|
||||||
/>
|
/>
|
||||||
</DeleteConfirmationModal>
|
</button>
|
||||||
)}
|
)}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -485,6 +485,18 @@ export default function CollectionCardComponent({
|
||||||
<></>
|
<></>
|
||||||
</IOModal>
|
</IOModal>
|
||||||
)}
|
)}
|
||||||
|
{openDelete && (
|
||||||
|
<DeleteConfirmationModal
|
||||||
|
open={openDelete}
|
||||||
|
setOpen={setOpenDelete}
|
||||||
|
onConfirm={() => {
|
||||||
|
if(onDelete) onDelete();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<></>
|
||||||
|
</DeleteConfirmationModal>
|
||||||
|
)
|
||||||
|
}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,18 @@ export default function DeleteConfirmationModal({
|
||||||
onConfirm,
|
onConfirm,
|
||||||
description,
|
description,
|
||||||
asChild,
|
asChild,
|
||||||
|
open,
|
||||||
|
setOpen,
|
||||||
}: {
|
}: {
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
onConfirm: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
onConfirm: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||||
description?: string;
|
description?: string;
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
|
open?: boolean;
|
||||||
|
setOpen?: (open: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<DialogTrigger asChild={asChild} tabIndex={-1}>
|
<DialogTrigger asChild={asChild} tabIndex={-1}>
|
||||||
{children}
|
{children}
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue