feat: enhance FlowgramNodeForm and WorkflowNodeCard by removing unused spec prop and adding node description display
This commit is contained in:
@@ -49,7 +49,6 @@ export function buildFlowgramNodeRegistries(nodeSpecs: AIWorkflowNodeSpec[]): Wo
|
|||||||
<FlowgramNodeForm
|
<FlowgramNodeForm
|
||||||
nodeType={spec.type}
|
nodeType={spec.type}
|
||||||
fallbackTitle={spec.title || spec.type}
|
fallbackTitle={spec.title || spec.type}
|
||||||
spec={spec}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -59,11 +58,9 @@ export function buildFlowgramNodeRegistries(nodeSpecs: AIWorkflowNodeSpec[]): Wo
|
|||||||
function FlowgramNodeForm({
|
function FlowgramNodeForm({
|
||||||
nodeType,
|
nodeType,
|
||||||
fallbackTitle,
|
fallbackTitle,
|
||||||
spec,
|
|
||||||
}: {
|
}: {
|
||||||
nodeType: string
|
nodeType: string
|
||||||
fallbackTitle: string
|
fallbackTitle: string
|
||||||
spec?: AIWorkflowNodeSpec
|
|
||||||
}) {
|
}) {
|
||||||
const { node, selected } = useNodeRender()
|
const { node, selected } = useNodeRender()
|
||||||
const nodeId = String(node.id ?? "")
|
const nodeId = String(node.id ?? "")
|
||||||
@@ -74,7 +71,6 @@ function FlowgramNodeForm({
|
|||||||
<WorkflowNodeCard
|
<WorkflowNodeCard
|
||||||
nodeType={nodeType}
|
nodeType={nodeType}
|
||||||
title={field.value || fallbackTitle}
|
title={field.value || fallbackTitle}
|
||||||
spec={spec}
|
|
||||||
selected={selected}
|
selected={selected}
|
||||||
width={nodeType === "condition" ? "wide" : "normal"}
|
width={nodeType === "condition" ? "wide" : "normal"}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -150,6 +150,15 @@ export function NodeConfigPanel({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{nodeSpec?.description ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label>节点说明</Label>
|
||||||
|
<div className="rounded-md border bg-muted/30 px-3 py-2 text-xs leading-5 text-muted-foreground">
|
||||||
|
{nodeSpec.description}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{inputSchema.length > 0 ? (
|
{inputSchema.length > 0 ? (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div className="text-sm font-medium">输入</div>
|
<div className="text-sm font-medium">输入</div>
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import type { AIWorkflowNodeSpec } from "@/lib/api/admin"
|
|
||||||
import { WorkflowNodeIcon } from "./workflow-node-icon"
|
import { WorkflowNodeIcon } from "./workflow-node-icon"
|
||||||
|
|
||||||
export function WorkflowNodeCard({
|
export function WorkflowNodeCard({
|
||||||
nodeType,
|
nodeType,
|
||||||
title,
|
title,
|
||||||
spec,
|
|
||||||
selected,
|
selected,
|
||||||
width = "normal",
|
width = "normal",
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
nodeType: string
|
nodeType: string
|
||||||
title: string
|
title: string
|
||||||
spec?: AIWorkflowNodeSpec
|
|
||||||
selected: boolean
|
selected: boolean
|
||||||
width?: "normal" | "wide"
|
width?: "normal" | "wide"
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
@@ -38,11 +35,6 @@ export function WorkflowNodeCard({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{spec?.description ? (
|
|
||||||
<div className="mx-3 mb-2 line-clamp-2 rounded-lg bg-muted/45 px-2 py-1.5 text-xs leading-4 text-muted-foreground">
|
|
||||||
{spec.description}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
{children ? <div className="border-t bg-muted/20 px-3 py-2.5">{children}</div> : null}
|
{children ? <div className="border-t bg-muted/20 px-3 py-2.5">{children}</div> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user