diff --git a/frontend/src/components/agents/playbooks/agent-playbooks-configuration.tsx b/frontend/src/components/agents/playbooks/agent-playbooks-configuration.tsx index 5a63509b..95192d54 100644 --- a/frontend/src/components/agents/playbooks/agent-playbooks-configuration.tsx +++ b/frontend/src/components/agents/playbooks/agent-playbooks-configuration.tsx @@ -9,7 +9,7 @@ import { useAgentWorkflows, useDeleteAgentWorkflow } from '@/hooks/react-query/a import type { AgentWorkflow } from '@/hooks/react-query/agents/workflow-utils'; import { PlaybookCreateModal } from '@/components/playbooks/playbook-create-modal'; import { PlaybookExecuteDialog } from '@/components/playbooks/playbook-execute-dialog'; -import { toast } from 'sonner'; +import { DeleteConfirmationDialog } from '@/components/thread/DeleteConfirmationDialog'; interface AgentPlaybooksConfigurationProps { agentId: string; @@ -38,13 +38,21 @@ export function AgentPlaybooksConfiguration({ agentId, agentName }: AgentPlayboo const [isCreateOpen, setIsCreateOpen] = useState(false); const [editing, setEditing] = useState(null); const [executing, setExecuting] = useState(null); + const [isDeleteOpen, setIsDeleteOpen] = useState(false); + const [toDelete, setToDelete] = useState(null); - const handleDelete = async (w: AgentWorkflow) => { + const handleDelete = (w: AgentWorkflow) => { + setToDelete(w); + setIsDeleteOpen(true); + }; + + const confirmDelete = async () => { + if (!toDelete) return; try { - await deleteWorkflowMutation.mutateAsync({ agentId, workflowId: w.id }); - toast.success('Deleted'); - } catch (e) { - toast.error('Failed to delete'); + await deleteWorkflowMutation.mutateAsync({ agentId, workflowId: toDelete.id }); + } finally { + setIsDeleteOpen(false); + setToDelete(null); } }; @@ -112,6 +120,14 @@ export function AgentPlaybooksConfiguration({ agentId, agentName }: AgentPlayboo playbook={executing} /> )} + + { if (!deleteWorkflowMutation.isPending) { setIsDeleteOpen(false); setToDelete(null); } }} + onConfirm={confirmDelete} + threadName={toDelete?.name ?? ''} + isDeleting={deleteWorkflowMutation.isPending} + /> ); }