feat: add WorkflowValidationBadge component for improved validation feedback
This commit is contained in:
@@ -19,6 +19,11 @@ import { useCallback, useEffect, useMemo, useState } from "react"
|
|||||||
|
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from "@/components/ui/popover"
|
||||||
import {
|
import {
|
||||||
ResizableHandle,
|
ResizableHandle,
|
||||||
ResizablePanel,
|
ResizablePanel,
|
||||||
@@ -217,11 +222,7 @@ export function WorkflowEditor({
|
|||||||
<Controls />
|
<Controls />
|
||||||
<MiniMap pannable zoomable />
|
<MiniMap pannable zoomable />
|
||||||
</ReactFlow>
|
</ReactFlow>
|
||||||
<div className="absolute left-3 top-3 flex gap-2">
|
<WorkflowValidationBadge errors={validation.errors} valid={validation.valid} />
|
||||||
<Badge variant={validation.valid ? "default" : "destructive"}>
|
|
||||||
{validation.valid ? "Valid draft" : `${validation.errors.length} issues`}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
<ResizableHandle withHandle />
|
<ResizableHandle withHandle />
|
||||||
@@ -252,3 +253,44 @@ export function WorkflowEditor({
|
|||||||
</ResizablePanelGroup>
|
</ResizablePanelGroup>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WorkflowValidationBadge({
|
||||||
|
errors,
|
||||||
|
valid,
|
||||||
|
}: {
|
||||||
|
errors: string[]
|
||||||
|
valid: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="absolute left-3 top-3 flex gap-2">
|
||||||
|
{valid ? (
|
||||||
|
<Badge variant="default">Valid draft</Badge>
|
||||||
|
) : (
|
||||||
|
<Popover>
|
||||||
|
<PopoverTrigger
|
||||||
|
render={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Badge variant="destructive" className="cursor-pointer">
|
||||||
|
{errors.length} issues
|
||||||
|
</Badge>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent side="bottom" align="start" className="w-80">
|
||||||
|
<div className="text-sm font-medium">Validation issues</div>
|
||||||
|
<ul className="mt-2 max-h-72 space-y-1 overflow-y-auto text-xs text-destructive">
|
||||||
|
{errors.map((error) => (
|
||||||
|
<li key={error} className="rounded-md bg-destructive/10 px-2 py-1.5">
|
||||||
|
{error}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user