feat: add WorkflowEditorStatus component for displaying validation and node counts
This commit is contained in:
+1
-1
Submodule docs updated: b6d08c0964...5b69ec7539
@@ -0,0 +1,38 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { AlertTriangleIcon, CheckCircle2Icon } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
import type { WorkflowDraftValidation } from "./workflow-utils"
|
||||||
|
|
||||||
|
export function WorkflowEditorStatus({
|
||||||
|
validation,
|
||||||
|
nodeCount,
|
||||||
|
edgeCount,
|
||||||
|
}: {
|
||||||
|
validation: WorkflowDraftValidation
|
||||||
|
nodeCount: number
|
||||||
|
edgeCount: number
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="pointer-events-none inline-flex min-h-8 w-fit max-w-full items-center gap-2 rounded-md border border-slate-200/80 bg-white/90 px-2.5 py-1 text-xs text-slate-500 shadow-sm backdrop-blur">
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"inline-flex shrink-0 items-center gap-1",
|
||||||
|
validation.valid ? "text-emerald-600" : "text-amber-700"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{validation.valid ? (
|
||||||
|
<CheckCircle2Icon className="size-3.5" />
|
||||||
|
) : (
|
||||||
|
<AlertTriangleIcon className="size-3.5" />
|
||||||
|
)}
|
||||||
|
{validation.valid ? "检查通过" : `${validation.errors.length} 个问题`}
|
||||||
|
</span>
|
||||||
|
<span className="h-3 w-px shrink-0 bg-slate-200" />
|
||||||
|
<span className="shrink-0">{nodeCount} 节点</span>
|
||||||
|
<span className="shrink-0">{edgeCount} 连线</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
import {
|
import {
|
||||||
CheckCircle2Icon,
|
|
||||||
RotateCcwIcon,
|
RotateCcwIcon,
|
||||||
SaveIcon,
|
SaveIcon,
|
||||||
SendIcon,
|
SendIcon,
|
||||||
@@ -10,14 +9,8 @@ import {
|
|||||||
} from "lucide-react"
|
} from "lucide-react"
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
|
|
||||||
import type { WorkflowDraftValidation } from "./workflow-utils"
|
|
||||||
|
|
||||||
export function WorkflowEditorToolbar({
|
export function WorkflowEditorToolbar({
|
||||||
validation,
|
|
||||||
nodeCount,
|
|
||||||
edgeCount,
|
|
||||||
toolbarExtra,
|
toolbarExtra,
|
||||||
onUndo,
|
onUndo,
|
||||||
undoDisabled = false,
|
undoDisabled = false,
|
||||||
@@ -32,9 +25,6 @@ export function WorkflowEditorToolbar({
|
|||||||
onPublish,
|
onPublish,
|
||||||
publishDisabled = false,
|
publishDisabled = false,
|
||||||
}: {
|
}: {
|
||||||
validation: WorkflowDraftValidation
|
|
||||||
nodeCount: number
|
|
||||||
edgeCount: number
|
|
||||||
toolbarExtra?: ReactNode
|
toolbarExtra?: ReactNode
|
||||||
onUndo?: () => void
|
onUndo?: () => void
|
||||||
undoDisabled?: boolean
|
undoDisabled?: boolean
|
||||||
@@ -50,21 +40,7 @@ export function WorkflowEditorToolbar({
|
|||||||
publishDisabled?: boolean
|
publishDisabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="inline-flex min-h-10 w-fit max-w-full items-center gap-3 rounded-md bg-background/95 px-2 py-1 shadow-sm backdrop-blur">
|
<div className="inline-flex min-h-10 w-fit max-w-full items-center rounded-md bg-background/95 px-2 py-1 shadow-sm backdrop-blur">
|
||||||
<div className="flex min-w-0 shrink items-center gap-2">
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"inline-flex items-center gap-1 rounded-sm px-2 py-1 text-xs",
|
|
||||||
validation.valid ? "bg-muted text-muted-foreground" : "bg-amber-50 text-amber-700"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<CheckCircle2Icon className="size-3" />
|
|
||||||
{validation.valid ? "本地检查通过" : `${validation.errors.length} 个本地问题`}
|
|
||||||
</span>
|
|
||||||
<span className="truncate text-xs text-muted-foreground">
|
|
||||||
{nodeCount} 个节点 / {edgeCount} 条连线
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex min-w-0 items-center gap-1 overflow-x-auto">
|
<div className="flex min-w-0 items-center gap-1 overflow-x-auto">
|
||||||
{toolbarExtra}
|
{toolbarExtra}
|
||||||
<Button type="button" variant="ghost" size="sm" className="h-7 shrink-0 px-2 text-xs" disabled={undoDisabled} onClick={onUndo}>
|
<Button type="button" variant="ghost" size="sm" className="h-7 shrink-0 px-2 text-xs" disabled={undoDisabled} onClick={onUndo}>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
} from "./workflow-branch-selection"
|
} from "./workflow-branch-selection"
|
||||||
import { WorkflowCanvasControls } from "./workflow-canvas-controls"
|
import { WorkflowCanvasControls } from "./workflow-canvas-controls"
|
||||||
import { WorkflowConfigPanel } from "./workflow-config-sidebar"
|
import { WorkflowConfigPanel } from "./workflow-config-sidebar"
|
||||||
|
import { WorkflowEditorStatus } from "./workflow-editor-status"
|
||||||
import { WorkflowEditorToolbar } from "./workflow-editor-toolbar"
|
import { WorkflowEditorToolbar } from "./workflow-editor-toolbar"
|
||||||
import {
|
import {
|
||||||
WorkflowPortAddProvider,
|
WorkflowPortAddProvider,
|
||||||
@@ -329,14 +330,11 @@ function WorkflowEditorInner({
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute left-3 top-3 z-50 max-w-[calc(100%-1.5rem)]",
|
"absolute left-3 top-3 z-50 flex max-w-[calc(100%-1.5rem)] flex-col items-start gap-2",
|
||||||
selectedNodeId && "max-w-[calc(100%-25rem)]"
|
selectedNodeId && "max-w-[calc(100%-25rem)]"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<WorkflowEditorToolbar
|
<WorkflowEditorToolbar
|
||||||
validation={validation}
|
|
||||||
nodeCount={definition.nodes.length}
|
|
||||||
edgeCount={definition.edges.length}
|
|
||||||
toolbarExtra={toolbarExtra}
|
toolbarExtra={toolbarExtra}
|
||||||
onUndo={onUndo}
|
onUndo={onUndo}
|
||||||
undoDisabled={undoDisabled}
|
undoDisabled={undoDisabled}
|
||||||
@@ -351,6 +349,11 @@ function WorkflowEditorInner({
|
|||||||
onPublish={onPublish}
|
onPublish={onPublish}
|
||||||
publishDisabled={publishDisabled}
|
publishDisabled={publishDisabled}
|
||||||
/>
|
/>
|
||||||
|
<WorkflowEditorStatus
|
||||||
|
validation={validation}
|
||||||
|
nodeCount={definition.nodes.length}
|
||||||
|
edgeCount={definition.edges.length}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="absolute bottom-3 left-3 z-50">
|
<div className="absolute bottom-3 left-3 z-50">
|
||||||
|
|||||||
Reference in New Issue
Block a user