"use client"; /** * Editor header — flow name / description, status badge, dirty * indicator, and the action buttons (Save, Activate/Pause, Delete, * View runs, Back). * * Lifted out of flow-builder.tsx so the same header renders above * both views in FlowEditorShell. Without this, canvas users had no * way to save without toggling to list view. * * Reads everything from the editor context (`useFlowEditor`) so it * stays in sync with whichever view is mutating state, and routes * router navigation locally (back to /flows, View runs to * /flows/[id]/runs) — those don't belong in the hook. */ import { useRouter } from "next/navigation"; import { ArrowLeft, History, Loader2, PauseCircle, PlayCircle, Save, Trash2, Workflow, } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { cn } from "@/lib/utils"; import { useFlowEditor, type BuilderState, } from "./flow-editor-state"; export function EditorHeader() { const router = useRouter(); const { flow, state, setState, dirty, saving, activating, canActivate, save, setStatus, deleteFlow, } = useFlowEditor(); return (
setState((s) => ({ ...s, name: e.target.value })) } placeholder="Flow name" className="max-w-md bg-slate-900 text-lg font-semibold" /> {dirty && ( Edited )}
{state.status === "active" ? ( ) : ( )}
setState((s) => ({ ...s, description: e.target.value })) } placeholder="Optional description (internal — customers don't see this)" className="bg-slate-900 text-sm" />
); } function StatusBadge({ status }: { status: BuilderState["status"] }) { const cls = { draft: "border-slate-700 bg-slate-800 text-slate-300", active: "border-emerald-600/40 bg-emerald-500/10 text-emerald-300", archived: "border-slate-700 bg-slate-800/50 text-slate-500", }[status]; return ( {status.charAt(0).toUpperCase() + status.slice(1)} ); }