diff --git a/web/src/components/create-new-workflow-button/create-new-workflow-button.tsx b/web/src/components/create-new-workflow-button/create-new-workflow-button.tsx index c109700e..a50339e1 100644 --- a/web/src/components/create-new-workflow-button/create-new-workflow-button.tsx +++ b/web/src/components/create-new-workflow-button/create-new-workflow-button.tsx @@ -12,7 +12,7 @@ export default function CreateNewWorkflowButton() { const handleCreateNewWorkflow = () => { const workflowId = uuidv4(); initWorkflow(workflowId, window.innerWidth); - router.replace(`/editor/${workflowId}`); + router.push(`/editor/${workflowId}`); }; return ( diff --git a/web/src/components/workflow-editor/new-workflow-modal.tsx b/web/src/components/workflow-editor/new-workflow-modal.tsx new file mode 100644 index 00000000..ce96e6f8 --- /dev/null +++ b/web/src/components/workflow-editor/new-workflow-modal.tsx @@ -0,0 +1,87 @@ +"use client"; + +import { isValidWorkflowName } from "@/lib/workflow-validation"; +import useSaveWorkflow from "@/providers/save-workflow"; +import { useWorkflowStore } from "@/stores/workflow-store"; +import { Button, Dialog, Flex, Text, TextField } from "@radix-ui/themes"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export default function NewWorkflowModal() { + const router = useRouter(); + const { isNew, setIsNew, workflowName, setWorkflowName } = + useWorkflowStore(); + const { saveWorkflow, isPending } = useSaveWorkflow(); + const [validWorkflowName, setValidWorkflowName] = useState(true); + + const handleCancelWorkflow = () => router.push("/"); + + const handleCreateWorkflow = async () => { + await saveWorkflow(); + setIsNew(false); + }; + + return ( + + + New Workflow + + Give your workflow a unique name. The workflow name must + start with a letter. After the first letter, the name must + only contain letters, numbers, and spaces. + + + + + + + + + + + + + ); +} diff --git a/web/src/components/workflow-editor/workflow-editor.tsx b/web/src/components/workflow-editor/workflow-editor.tsx index ceca890c..f384c195 100644 --- a/web/src/components/workflow-editor/workflow-editor.tsx +++ b/web/src/components/workflow-editor/workflow-editor.tsx @@ -21,6 +21,7 @@ import { useToast } from "@/providers/toast"; import { AxiosError } from "axios"; import { useRouter } from "next/navigation"; import { SaveWorkflowProvider } from "@/providers/save-workflow"; +import NewWorkflowModal from "./new-workflow-modal"; type View = "workflowBuilder" | "runHistory"; @@ -72,7 +73,7 @@ export default function WorkflowEditor({ workflowError instanceof AxiosError && (workflowError as AxiosError).response?.status === 404 ) { - router.replace("/"); + router.push("/"); errorToast("Workflow does not exist."); } else { errorToast("Failed to load workflow. Please refresh the page."); @@ -104,6 +105,8 @@ export default function WorkflowEditor({ return ( + + { await deleteWorkflow.mutateAsync(workflowId); - router.replace("/"); + router.push("/"); }; return ( diff --git a/web/src/stores/workflow-store.ts b/web/src/stores/workflow-store.ts index ed568fdf..41d9bddc 100644 --- a/web/src/stores/workflow-store.ts +++ b/web/src/stores/workflow-store.ts @@ -127,7 +127,7 @@ export const useWorkflowStore = create((set, get) => ({ nextId: 0, webhookId: null, webhookSecret: null, - detailPageType: "workflow", + detailPageType: null, selectedNodeIdx: null, }); }, @@ -144,7 +144,7 @@ export const useWorkflowStore = create((set, get) => ({ isNew: true, webhookId: null, webhookSecret: null, - detailPageType: "workflow", + detailPageType: null, selectedNodeIdx: null, }); }, @@ -398,7 +398,7 @@ export const useWorkflowStore = create((set, get) => ({ }), ), // Settings Side Panel - detailPageType: "workflow", + detailPageType: null, selectedNodeIdx: null, clickWorkflowSettings: () => set(