From 8541836b26fad601a6ef69e9aba0eecc55af5ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:03:57 -0400 Subject: [PATCH] refactor(automation): use Modal for WorkflowEditor --- .../components/automation/WorkflowEditor.tsx | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/renderer/components/automation/WorkflowEditor.tsx b/src/renderer/components/automation/WorkflowEditor.tsx index 4ed90c03..dc001d43 100644 --- a/src/renderer/components/automation/WorkflowEditor.tsx +++ b/src/renderer/components/automation/WorkflowEditor.tsx @@ -1,9 +1,8 @@ import { useCallback, useEffect, useState } from "react" -import { motion } from "framer-motion" -import { ArrowsClockwise, Gear, X } from "@phosphor-icons/react" +import { ArrowsClockwise, Gear } from "@phosphor-icons/react" import type { AutomationTrigger, WorkflowPipelineRecord, WorkflowStatus } from "@shared/types" -import { ActionButton, Select, useFocusTrap } from "../ui" -import { ACCENT, LINE, triggerConfig, safeJsonStringify } from "./automation-config" +import { ActionButton, Modal, Select } from "../ui" +import { triggerConfig, safeJsonStringify } from "./automation-config" interface WorkflowFormState { name: string; description: string; triggerType: AutomationTrigger; triggerConfigJson: string; status: WorkflowStatus; stepsJson: string } const defaultWorkflowForm: WorkflowFormState = { name: "", description: "", triggerType: "task_created", triggerConfigJson: "{}", status: "draft", stepsJson: "[]" } @@ -20,28 +19,22 @@ export function WorkflowFormModal({ open, editingWorkflow, companyId, onClose, o setSaving(true); setError(null) try { const result = await window.agentCompany.saveWorkflow({ id: editingWorkflow?.id ?? null, companyId, name: form.name.trim(), description: form.description.trim(), triggerType: form.triggerType, triggerConfigJson: form.triggerConfigJson, status: form.status, stepsJson: form.stepsJson }); if (!result.ok) { setError(result.error.message); return }; onSaved(); onClose() } catch (err) { setError(err instanceof Error ? err.message : "Failed to save workflow") } finally { setSaving(false) } }, [form, editingWorkflow, companyId, onSaved, onClose]) - const trapRef = useFocusTrap(open) - useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose() }; document.addEventListener("keydown", onKey); return () => document.removeEventListener("keydown", onKey) }, [open, onClose]) - if (!open) return null const triggerOptions = Object.entries(triggerConfig).map(([key, c]) => ({ value: key, label: c.label })) const statusOptions = [{ value: "draft", label: "Draft" }, { value: "active", label: "Active" }, { value: "paused", label: "Paused" }] return ( - - e.stopPropagation()}> -

{isEditing ? "Edit Workflow" : "New Workflow"}

-
- {error ?
{error}
: null} -
updateField("name", e.target.value)} placeholder="e.g., Bug Fix Pipeline" className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 w-full rounded-lg border bg-card px-3.5 py-2.5 text-[14px] text-foreground placeholder:text-muted-foreground" style={{ borderColor: LINE }} />
-