diff --git a/ui/admin/app/components/workflow-triggers/DeleteWorkflowTrigger.tsx b/ui/admin/app/components/workflow-triggers/DeleteWorkflowTrigger.tsx
index 62cf0bc8..d33f00e8 100644
--- a/ui/admin/app/components/workflow-triggers/DeleteWorkflowTrigger.tsx
+++ b/ui/admin/app/components/workflow-triggers/DeleteWorkflowTrigger.tsx
@@ -1,29 +1,28 @@
-import { useState } from "react";
import { toast } from "sonner";
import { mutate } from "swr";
import { CronJobApiService } from "~/lib/service/api/cronjobApiService";
import { WebhookApiService } from "~/lib/service/api/webhookApiService";
+import { TypographyP } from "~/components/Typography";
import { ConfirmationDialog } from "~/components/composed/ConfirmationDialog";
+import { DropdownMenuItem } from "~/components/ui/dropdown-menu";
+import { useConfirmationDialog } from "~/hooks/component-helpers/useConfirmationDialog";
import { useAsync } from "~/hooks/useAsync";
export function DeleteWorkflowTrigger({
id,
+ name,
type,
- children,
}: {
id: string;
+ name?: string;
type: "webhook" | "schedule";
- children?: React.ReactNode;
}) {
- const [open, setOpen] = useState(false);
-
const deleteWebhook = useAsync(WebhookApiService.deleteWebhook, {
onSuccess: () => {
mutate(WebhookApiService.getWebhooks.key());
toast.success("Webhook workflow trigger has been deleted.");
- setOpen(false);
},
});
@@ -31,36 +30,48 @@ export function DeleteWorkflowTrigger({
onSuccess: () => {
mutate(CronJobApiService.getCronJobs.key());
toast.success("Schedule workflow trigger has been deleted.");
- setOpen(false);
},
});
- const handleConfirmDelete = () => {
+ const handleConfirmDelete = async () => {
if (type === "webhook") {
- deleteWebhook.execute(id);
+ await deleteWebhook.executeAsync(id);
} else {
- deleteCronjob.execute(id);
+ await deleteCronjob.executeAsync(id);
}
};
- const loading = deleteWebhook.isLoading || deleteCronjob.isLoading;
+ const { interceptAsync, dialogProps } = useConfirmationDialog();
return (
-
- {children}
-
+ <>
+ {
+ e.preventDefault();
+ interceptAsync(handleConfirmDelete);
+ }}
+ >
+ Delete
+
+
+
+
+ Are you sure you want to delete workflow trigger:{" "}
+ {name || id}?
+
+ The action cannot be undone.
+
+ }
+ confirmProps={{
+ children: "Delete",
+ variant: "destructive",
+ }}
+ />
+ >
);
}
diff --git a/ui/admin/app/components/workflow-triggers/WorkflowTriggerActions.tsx b/ui/admin/app/components/workflow-triggers/WorkflowTriggerActions.tsx
index 3768fc32..f6c3f03a 100644
--- a/ui/admin/app/components/workflow-triggers/WorkflowTriggerActions.tsx
+++ b/ui/admin/app/components/workflow-triggers/WorkflowTriggerActions.tsx
@@ -46,14 +46,11 @@ export function WorkflowTriggerActions({ item }: { item: WorkflowTrigger }) {
Edit
-
- e.preventDefault()}
- >
- Delete
-
-
+