From 686db1bae504ddc116baa2cf4d0aa4a56209ec42 Mon Sep 17 00:00:00 2001 From: Nikhil-Doye Date: Mon, 27 Oct 2025 15:53:58 -0400 Subject: [PATCH] Add clear all workflows functionality and confirmation dialog - Enhanced WorkflowList component to include a "Clear All" button for deleting all workflows, with a confirmation prompt to prevent accidental deletions. - Updated WorkflowToolbar component to implement a dialog for confirming the reset of all nodes in the current workflow, ensuring user awareness of irreversible actions. - Improved user interface with visual feedback for critical actions, enhancing overall usability and safety in workflow management. --- src/components/WorkflowList.tsx | 23 ++++++++++++++++- src/components/WorkflowToolbar.tsx | 40 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/components/WorkflowList.tsx b/src/components/WorkflowList.tsx index 6233396..a4bfb0a 100644 --- a/src/components/WorkflowList.tsx +++ b/src/components/WorkflowList.tsx @@ -28,7 +28,8 @@ export const WorkflowList: React.FC = ({ onOpenWorkflow, onCreateWorkflow, }) => { - const { workflows, deleteWorkflow, updateWorkflow } = useWorkflowStore(); + const { workflows, deleteWorkflow, updateWorkflow, clearAllWorkflows } = + useWorkflowStore(); const [newWorkflowName, setNewWorkflowName] = useState(""); const [showCreateForm, setShowCreateForm] = useState(false); const [editingWorkflowId, setEditingWorkflowId] = useState( @@ -102,6 +103,16 @@ export const WorkflowList: React.FC = ({ setShowOnboarding(true); }; + const handleClearAllWorkflows = () => { + if ( + window.confirm( + "Are you sure you want to permanently delete ALL workflows? This cannot be undone." + ) + ) { + clearAllWorkflows(); + } + }; + return (
{/* Hero Section */} @@ -206,6 +217,16 @@ export const WorkflowList: React.FC = ({ New Workflow + {workflows.length > 0 && ( + + )}
diff --git a/src/components/WorkflowToolbar.tsx b/src/components/WorkflowToolbar.tsx index 71a7c38..e1abada 100644 --- a/src/components/WorkflowToolbar.tsx +++ b/src/components/WorkflowToolbar.tsx @@ -22,6 +22,13 @@ import { ApiKeysSettings } from "./ApiKeysSettings"; import { DatabaseConnectionManager } from "./DatabaseConnectionManager"; import { WorkflowScheduler } from "./WorkflowScheduler"; import { Button } from "./ui/button"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogFooter, +} from "./ui/dialog"; export const WorkflowToolbar: React.FC = () => { const { @@ -39,6 +46,7 @@ export const WorkflowToolbar: React.FC = () => { const [showDatabaseManager, setShowDatabaseManager] = useState(false); const [showScheduler, setShowScheduler] = useState(false); const [showSaveSuccess, setShowSaveSuccess] = useState(false); + const [showResetConfirm, setShowResetConfirm] = useState(false); const handleSave = () => { if (currentWorkflow) { @@ -81,7 +89,12 @@ export const WorkflowToolbar: React.FC = () => { }; const handleClear = () => { + setShowResetConfirm(true); + }; + + const confirmClearNodes = () => { clearAllNodes(); + setShowResetConfirm(false); }; if (!currentWorkflow) return null; @@ -262,6 +275,33 @@ export const WorkflowToolbar: React.FC = () => { workflowId={currentWorkflow?.id} /> )} + + {/* Confirm Reset (Clear All Nodes) Dialog */} + + + + Reset workflow? + +
+ This will remove all nodes and connections from the current + workflow. This action cannot be undone. +
+ + + + +
+
); };