refactor: update layout and styling in WorkflowConfigPanel; enhance panel header and description display
This commit is contained in:
@@ -5,7 +5,6 @@ import { Trash2Icon } from "lucide-react"
|
|||||||
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
|
||||||
import { OptionCombobox } from "@/components/option-combobox"
|
import { OptionCombobox } from "@/components/option-combobox"
|
||||||
import type { AIWorkflowDefinition, AIWorkflowNodeSpec } from "@/lib/api/admin"
|
import type { AIWorkflowDefinition, AIWorkflowNodeSpec } from "@/lib/api/admin"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
@@ -41,8 +40,8 @@ const CONDITION_OPERATOR_OPTIONS = [
|
|||||||
{ value: "empty", label: "为空" },
|
{ value: "empty", label: "为空" },
|
||||||
]
|
]
|
||||||
|
|
||||||
const cardInputClassName = "h-8 rounded-md border-slate-200 bg-white text-xs shadow-none"
|
const inspectorInputClassName = "h-7 rounded-sm border-slate-200 bg-white px-2 text-xs shadow-none"
|
||||||
const cardComboboxClassName = "h-8 rounded-md border-slate-200 bg-white text-xs shadow-none"
|
const inspectorComboboxClassName = "h-7 rounded-sm border-slate-200 bg-white text-xs shadow-none"
|
||||||
|
|
||||||
export function NodeConfigPanel({
|
export function NodeConfigPanel({
|
||||||
node,
|
node,
|
||||||
@@ -108,7 +107,7 @@ export function NodeConfigPanel({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3 px-3 pb-3">
|
<div className="pb-3">
|
||||||
{showHeader ? (
|
{showHeader ? (
|
||||||
<div className="border-b px-4 py-3">
|
<div className="border-b px-4 py-3">
|
||||||
<div className="flex items-start justify-between gap-2">
|
<div className="flex items-start justify-between gap-2">
|
||||||
@@ -133,23 +132,24 @@ export function NodeConfigPanel({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="space-y-3">
|
<div className="overflow-hidden border-y border-slate-200 bg-white">
|
||||||
{inputSchema.length > 0 ? (
|
{inputSchema.length > 0 ? (
|
||||||
<ConfigCard title="输入" meta={`${inputSchema.length} 项`}>
|
<InspectorSection title="输入" meta={`${inputSchema.length} 项`}>
|
||||||
<div className="space-y-3">
|
|
||||||
{inputSchema.map((input) => {
|
{inputSchema.map((input) => {
|
||||||
const value = inputsValues[input.name]
|
const value = inputsValues[input.name]
|
||||||
return (
|
return (
|
||||||
<div key={input.name} className="space-y-1.5">
|
<InspectorField
|
||||||
<Label className="flex items-center gap-1 text-xs text-slate-600">
|
key={input.name}
|
||||||
<span>{input.label || input.name}</span>
|
label={input.label || input.name}
|
||||||
{input.required ? <span className="text-destructive">*</span> : null}
|
required={input.required}
|
||||||
</Label>
|
fieldName={input.name}
|
||||||
|
fieldType={input.type}
|
||||||
|
>
|
||||||
<VariableSelector
|
<VariableSelector
|
||||||
value={isRefValue(value) ? value : undefined}
|
value={isRefValue(value) ? value : undefined}
|
||||||
variables={availableVariables ?? []}
|
variables={availableVariables ?? []}
|
||||||
placeholder="选择变量"
|
placeholder="选择变量"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(next) => {
|
onChange={(next) => {
|
||||||
updateData({
|
updateData({
|
||||||
inputsValues: {
|
inputsValues: {
|
||||||
@@ -159,11 +159,11 @@ export function NodeConfigPanel({
|
|||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
{input.description ? <InspectorHint>{input.description}</InspectorHint> : null}
|
||||||
|
</InspectorField>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</InspectorSection>
|
||||||
</ConfigCard>
|
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showConditionBranches && (node.type === "condition" || branches.length > 0) ? (
|
{showConditionBranches && (node.type === "condition" || branches.length > 0) ? (
|
||||||
@@ -179,22 +179,16 @@ export function NodeConfigPanel({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{outputSchema.length > 0 ? (
|
{outputSchema.length > 0 ? (
|
||||||
<ConfigCard title="输出" meta={`${outputSchema.length} 项`}>
|
<InspectorSection title="输出" meta={`${outputSchema.length} 项`}>
|
||||||
<div className="space-y-2">
|
{outputSchema.map((output) => {
|
||||||
{outputSchema.map((output) => {
|
const item = buildVariableSpecDisplay(output)
|
||||||
const item = buildVariableSpecDisplay(output)
|
return (
|
||||||
return (
|
<InspectorField key={item.key} label={item.label} detail={item.subtitle}>
|
||||||
<div key={item.key} className="rounded-md border border-slate-200 bg-slate-50/60 px-2.5 py-2">
|
{item.description ? <InspectorHint>{item.description}</InspectorHint> : null}
|
||||||
<div className="truncate text-xs font-medium text-slate-700">{item.label}</div>
|
</InspectorField>
|
||||||
<div className="mt-1 truncate font-mono text-[11px] leading-4 text-slate-500">{item.subtitle}</div>
|
)
|
||||||
{item.description ? (
|
})}
|
||||||
<div className="mt-1 text-xs leading-4 text-muted-foreground">{item.description}</div>
|
</InspectorSection>
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</ConfigCard>
|
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -238,45 +232,48 @@ export function ConditionBranchConfigPanel({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3 px-3 pb-3">
|
<div className="pb-3">
|
||||||
<ConfigCard title="分支目标" meta={branch.default ? "默认" : "条件"}>
|
<div className="overflow-hidden border-y border-slate-200 bg-white">
|
||||||
<div className="space-y-3">
|
<InspectorSection title="分支" meta={branch.default ? "默认" : "条件"}>
|
||||||
<div className="space-y-1.5">
|
<InspectorRow label="目标节点">
|
||||||
<Label className="text-xs text-slate-600">目标节点</Label>
|
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={branch.targetNodeId}
|
value={branch.targetNodeId}
|
||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</InspectorRow>
|
||||||
|
|
||||||
<label className="flex items-center gap-2 text-xs text-slate-600">
|
<InspectorRow label="默认分支">
|
||||||
<input
|
<label className="inline-flex h-7 items-center gap-2 text-xs text-slate-700">
|
||||||
type="checkbox"
|
<input
|
||||||
checked={branch.default === true}
|
type="checkbox"
|
||||||
className="size-3.5"
|
checked={branch.default === true}
|
||||||
onChange={(event) => updateBranch({
|
className="size-3.5"
|
||||||
...branch,
|
onChange={(event) => updateBranch({
|
||||||
default: event.target.checked,
|
...branch,
|
||||||
condition: event.target.checked ? undefined : branch.condition,
|
default: event.target.checked,
|
||||||
})}
|
condition: event.target.checked ? undefined : branch.condition,
|
||||||
/>
|
})}
|
||||||
默认分支
|
/>
|
||||||
</label>
|
其他条件不匹配时执行
|
||||||
</div>
|
</label>
|
||||||
</ConfigCard>
|
</InspectorRow>
|
||||||
|
</InspectorSection>
|
||||||
|
|
||||||
{branch.default ? (
|
{branch.default ? (
|
||||||
<div className="rounded-md border border-slate-200 bg-white px-3 py-2 text-xs text-slate-500">
|
<InspectorSection title="条件表达式">
|
||||||
默认分支不需要条件表达式,会在其他条件不匹配时执行。
|
<div className="px-3 py-2 text-xs text-slate-500">
|
||||||
</div>
|
默认分支不需要条件表达式,会在其他条件不匹配时执行。
|
||||||
) : (
|
</div>
|
||||||
<ConfigCard title="条件表达式">
|
</InspectorSection>
|
||||||
<ConditionFields branch={branch} variables={variables} onChange={updateBranch} />
|
) : (
|
||||||
</ConfigCard>
|
<InspectorSection title="条件表达式">
|
||||||
)}
|
<ConditionFields branch={branch} variables={variables} onChange={updateBranch} />
|
||||||
|
</InspectorSection>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -301,32 +298,32 @@ function ConditionBranchesEditor({
|
|||||||
const targetOptions = buildTargetOptions(nodes, currentNodeId)
|
const targetOptions = buildTargetOptions(nodes, currentNodeId)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigCard
|
<InspectorSection
|
||||||
title="条件分支"
|
title="条件分支"
|
||||||
meta={`${branches.length} 项`}
|
meta={`${branches.length} 项`}
|
||||||
action={
|
action={
|
||||||
<Button type="button" variant="ghost" size="sm" className="h-7 px-2 text-xs" onClick={onAdd}>
|
<Button type="button" variant="ghost" size="sm" className="h-6 px-2 text-xs text-slate-600" onClick={onAdd}>
|
||||||
添加
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{branches.length === 0 ? (
|
{branches.length === 0 ? (
|
||||||
<div className="rounded-md border border-dashed border-slate-200 bg-slate-50 px-3 py-3 text-xs text-slate-500">
|
<div className="px-3 py-3 text-xs text-slate-500">
|
||||||
暂无分支。条件节点需要至少一个默认分支或条件分支。
|
暂无分支。条件节点需要至少一个默认分支或条件分支。
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="space-y-2">
|
<div className="divide-y divide-slate-100">
|
||||||
{branches.map((branch) => {
|
{branches.map((branch) => {
|
||||||
return (
|
return (
|
||||||
<div key={branch.id} className="space-y-2 rounded-md border border-slate-200 bg-slate-50/60 p-2.5">
|
<div key={branch.id} className="bg-white px-3 py-2">
|
||||||
<div className="flex items-center justify-between gap-2">
|
<div className="grid grid-cols-[44px_minmax(0,1fr)_auto] items-center gap-2">
|
||||||
<span className="inline-flex h-5 shrink-0 items-center rounded-full border border-slate-200 bg-white px-2 font-mono text-[10px] font-semibold text-slate-600">
|
<span className="inline-flex h-5 shrink-0 items-center justify-center rounded-sm border border-slate-200 bg-slate-50 px-1.5 font-mono text-[10px] font-semibold text-slate-600">
|
||||||
{branch.default ? "ELSE" : "IF"}
|
{branch.default ? "ELSE" : "IF"}
|
||||||
</span>
|
</span>
|
||||||
<Input
|
<Input
|
||||||
value={branch.name ?? ""}
|
value={branch.name ?? ""}
|
||||||
placeholder={branch.id}
|
placeholder={branch.id}
|
||||||
className={cn(cardInputClassName, "min-w-0 flex-1 border-transparent bg-white font-medium")}
|
className={cn(inspectorInputClassName, "min-w-0 border-transparent bg-transparent px-1 font-medium")}
|
||||||
onChange={(event) => onChange({ ...branch, name: event.target.value })}
|
onChange={(event) => onChange({ ...branch, name: event.target.value })}
|
||||||
/>
|
/>
|
||||||
{branch.default ? null : (
|
{branch.default ? null : (
|
||||||
@@ -342,18 +339,18 @@ function ConditionBranchesEditor({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-[64px_minmax(0,1fr)] items-center gap-2">
|
<div className="mt-2 grid grid-cols-[72px_minmax(0,1fr)] items-center gap-2">
|
||||||
<Label className="text-xs text-slate-500">目标节点</Label>
|
<div className="text-xs text-slate-500">目标节点</div>
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={branch.targetNodeId}
|
value={branch.targetNodeId}
|
||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label className="flex items-center gap-2 text-xs text-slate-500">
|
<label className="mt-2 flex items-center gap-2 pl-[72px] text-xs text-slate-500">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={branch.default === true}
|
checked={branch.default === true}
|
||||||
@@ -376,7 +373,7 @@ function ConditionBranchesEditor({
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</ConfigCard>
|
</InspectorSection>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,37 +396,35 @@ function ConditionFields({
|
|||||||
const rightDisabled = ["exists", "empty"].includes(condition.operator ?? "")
|
const rightDisabled = ["exists", "empty"].includes(condition.operator ?? "")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("space-y-3", compact && "space-y-2")}>
|
<div className={cn("divide-y divide-slate-100", compact && "divide-y-0")}>
|
||||||
<div className={cn("space-y-1.5", compact && "grid grid-cols-[64px_minmax(0,1fr)] items-center gap-2 space-y-0")}>
|
<div className={cn("grid grid-cols-[92px_minmax(0,1fr)] items-start gap-2 px-3 py-2", compact && "grid-cols-[72px_minmax(0,1fr)] px-0 py-1")}>
|
||||||
<Label className="text-xs text-slate-500">左值</Label>
|
<div className="pt-1.5 text-xs text-slate-500">左值</div>
|
||||||
<VariableSelector
|
<VariableSelector
|
||||||
value={isRefValue(condition.left) ? condition.left : undefined}
|
value={isRefValue(condition.left) ? condition.left : undefined}
|
||||||
variables={variables}
|
variables={variables}
|
||||||
placeholder="选择变量"
|
placeholder="选择变量"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(left) => onChange({
|
onChange={(left) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, left },
|
condition: { ...condition, left },
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={cn("grid grid-cols-[1fr_1fr] gap-2", compact && "grid-cols-[64px_minmax(0,1fr)_96px] items-center")}>
|
<div className={cn("grid grid-cols-[92px_minmax(0,1fr)_minmax(0,1fr)] items-start gap-2 px-3 py-2", compact && "grid-cols-[72px_minmax(0,1fr)_96px] px-0 py-1")}>
|
||||||
{compact ? <Label className="text-xs text-slate-500">判断</Label> : null}
|
<div className="pt-1.5 text-xs text-slate-500">判断</div>
|
||||||
<div className={cn("space-y-1.5", compact && "space-y-0")}>
|
<div>
|
||||||
{compact ? null : <Label className="text-xs text-slate-500">操作符</Label>}
|
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={condition.operator ?? ""}
|
value={condition.operator ?? ""}
|
||||||
options={CONDITION_OPERATOR_OPTIONS}
|
options={CONDITION_OPERATOR_OPTIONS}
|
||||||
placeholder="选择操作符"
|
placeholder="选择操作符"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(operator) => onChange({
|
onChange={(operator) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, operator },
|
condition: { ...condition, operator },
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={cn("space-y-1.5", compact && "space-y-0", rightDisabled && "opacity-50")}>
|
<div className={cn(rightDisabled && "opacity-50")}>
|
||||||
{compact ? null : <Label className="text-xs text-slate-500">右值</Label>}
|
|
||||||
{valueOptions.length > 0 && !rightDisabled ? (
|
{valueOptions.length > 0 && !rightDisabled ? (
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={stringifyConditionRight(condition.right)}
|
value={stringifyConditionRight(condition.right)}
|
||||||
@@ -439,7 +434,7 @@ function ConditionFields({
|
|||||||
description: option.description,
|
description: option.description,
|
||||||
}))}
|
}))}
|
||||||
placeholder="选择取值"
|
placeholder="选择取值"
|
||||||
triggerClassName={cardComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
onChange={(nextValue) => {
|
onChange={(nextValue) => {
|
||||||
const selectedOption = valueOptions.find((option) => stringifyConditionRight(option.value) === nextValue)
|
const selectedOption = valueOptions.find((option) => stringifyConditionRight(option.value) === nextValue)
|
||||||
onChange({
|
onChange({
|
||||||
@@ -452,7 +447,7 @@ function ConditionFields({
|
|||||||
<Input
|
<Input
|
||||||
value={stringifyConditionRight(condition.right)}
|
value={stringifyConditionRight(condition.right)}
|
||||||
disabled={rightDisabled}
|
disabled={rightDisabled}
|
||||||
className={cardInputClassName}
|
className={inspectorInputClassName}
|
||||||
onChange={(event) => onChange({
|
onChange={(event) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, right: event.target.value },
|
condition: { ...condition, right: event.target.value },
|
||||||
@@ -465,7 +460,7 @@ function ConditionFields({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ConfigCard({
|
function InspectorSection({
|
||||||
title,
|
title,
|
||||||
meta,
|
meta,
|
||||||
action,
|
action,
|
||||||
@@ -477,21 +472,99 @@ function ConfigCard({
|
|||||||
children: ReactNode
|
children: ReactNode
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="overflow-hidden rounded-md border border-slate-200 bg-white">
|
<section className="border-b border-slate-200 last:border-b-0">
|
||||||
<div className="flex min-h-10 items-center justify-between gap-2 border-b border-slate-100 px-3 py-2">
|
<div className="flex min-h-8 items-center justify-between gap-2 border-b border-slate-100 bg-slate-50/80 px-3 py-1">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="truncate text-[13px] font-semibold text-slate-900">{title}</div>
|
<div className="truncate text-[11px] font-semibold uppercase tracking-wide text-slate-500">{title}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
{meta ? <span className="text-xs text-slate-500">{meta}</span> : null}
|
{meta ? <span className="font-mono text-[10px] text-slate-400">{meta}</span> : null}
|
||||||
{action}
|
{action}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-3">{children}</div>
|
<div>{children}</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function InspectorRow({
|
||||||
|
label,
|
||||||
|
detail,
|
||||||
|
required,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
detail?: string
|
||||||
|
required?: boolean
|
||||||
|
children: ReactNode
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-[112px_minmax(0,1fr)] gap-3 border-b border-slate-100 px-3 py-2 last:border-b-0">
|
||||||
|
<div className="min-w-0 pt-1">
|
||||||
|
<div className="flex min-w-0 items-center gap-1">
|
||||||
|
<span className="truncate text-xs font-medium text-slate-700">{label}</span>
|
||||||
|
{required ? <span className="text-[10px] text-destructive">*</span> : null}
|
||||||
|
</div>
|
||||||
|
{detail ? <div className="mt-0.5 truncate font-mono text-[10px] leading-4 text-slate-400">{detail}</div> : null}
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">{children}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InspectorField({
|
||||||
|
label,
|
||||||
|
detail,
|
||||||
|
fieldName,
|
||||||
|
fieldType,
|
||||||
|
required,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
detail?: string
|
||||||
|
fieldName?: string
|
||||||
|
fieldType?: string
|
||||||
|
required?: boolean
|
||||||
|
children: ReactNode
|
||||||
|
}) {
|
||||||
|
const metaItems = [
|
||||||
|
fieldName ? { label: "字段", value: fieldName } : null,
|
||||||
|
fieldType ? { label: "类型", value: fieldType } : null,
|
||||||
|
].filter((item): item is { label: string; value: string } => Boolean(item))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="border-b border-slate-100 px-3 py-2.5 last:border-b-0">
|
||||||
|
<div className="flex min-w-0 items-start justify-between gap-3">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="flex min-w-0 items-start gap-1">
|
||||||
|
<span className="min-w-0 break-words text-xs font-medium leading-4 text-slate-700">{label}</span>
|
||||||
|
{required ? <span className="shrink-0 text-[10px] text-destructive">*</span> : null}
|
||||||
|
</div>
|
||||||
|
{detail ? <div className="mt-1 break-all font-mono text-[10px] leading-4 text-slate-400">{detail}</div> : null}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{metaItems.length > 0 ? (
|
||||||
|
<div className="mt-1.5 flex flex-wrap gap-1">
|
||||||
|
{metaItems.map((item) => (
|
||||||
|
<span
|
||||||
|
key={item.label}
|
||||||
|
className="inline-flex min-w-0 max-w-full items-center gap-1 rounded-sm border border-slate-200 bg-slate-50 px-1.5 py-0.5 font-mono text-[10px] leading-4 text-slate-500"
|
||||||
|
>
|
||||||
|
<span className="shrink-0 text-slate-400">{item.label}</span>
|
||||||
|
<span className="min-w-0 break-all">{item.value}</span>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div className="mt-2 min-w-0">{children}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InspectorHint({ children }: { children: ReactNode }) {
|
||||||
|
return <div className="mt-1.5 text-xs leading-4 text-slate-500">{children}</div>
|
||||||
|
}
|
||||||
|
|
||||||
function buildTargetOptions(nodes: AIWorkflowDefinition["nodes"], currentNodeId: string) {
|
function buildTargetOptions(nodes: AIWorkflowDefinition["nodes"], currentNodeId: string) {
|
||||||
return nodes
|
return nodes
|
||||||
.filter((node) => node.id !== currentNodeId && node.type !== "start")
|
.filter((node) => node.id !== currentNodeId && node.type !== "start")
|
||||||
|
|||||||
@@ -115,42 +115,42 @@ export function WorkflowConfigPanel({
|
|||||||
<span className="h-12 w-1 rounded-full bg-slate-300/80 transition-colors group-hover:bg-blue-400" />
|
<span className="h-12 w-1 rounded-full bg-slate-300/80 transition-colors group-hover:bg-blue-400" />
|
||||||
</div>
|
</div>
|
||||||
<section className="pointer-events-auto flex min-h-0 w-full flex-col overflow-hidden rounded-lg bg-white shadow-[0_18px_45px_rgba(15,23,42,0.18)] backdrop-blur">
|
<section className="pointer-events-auto flex min-h-0 w-full flex-col overflow-hidden rounded-lg bg-white shadow-[0_18px_45px_rgba(15,23,42,0.18)] backdrop-blur">
|
||||||
<ScrollArea className="min-h-0 flex-1">
|
<div className="shrink-0 border-b border-slate-200 px-4 py-3">
|
||||||
<div className="py-3">
|
<div className="flex min-w-0 items-center justify-between gap-3">
|
||||||
<div className="px-4 pb-3">
|
<div className="flex min-w-0 flex-1 items-center gap-2.5">
|
||||||
<div className="flex min-w-0 items-center justify-between gap-3">
|
<WorkflowNodeIcon
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2.5">
|
icon={panelIcon}
|
||||||
<WorkflowNodeIcon
|
size="sm"
|
||||||
icon={panelIcon}
|
className="rounded-md shadow-none"
|
||||||
size="sm"
|
/>
|
||||||
className="rounded-md shadow-none"
|
<div className="min-w-0 flex-1">
|
||||||
/>
|
<Input
|
||||||
<div className="min-w-0 flex-1">
|
value={panelTitle}
|
||||||
<Input
|
placeholder={selectedBranchItem ? selectedBranchItem.id : selectedNodeSpec?.title || selectedNode.type}
|
||||||
value={panelTitle}
|
className="h-7 w-full rounded-md border-transparent bg-transparent px-1 text-sm font-semibold leading-5 text-slate-900 shadow-none transition-colors hover:border-slate-200 hover:bg-slate-50 focus-visible:border-blue-300 focus-visible:bg-white focus-visible:ring-2 focus-visible:ring-blue-100"
|
||||||
placeholder={selectedBranchItem ? selectedBranchItem.id : selectedNodeSpec?.title || selectedNode.type}
|
onChange={(event) => updatePanelTitle(event.target.value)}
|
||||||
className="h-7 w-full rounded-md border-transparent bg-transparent px-1 text-sm font-semibold leading-5 text-slate-900 shadow-none transition-colors hover:border-slate-200 hover:bg-slate-50 focus-visible:border-blue-300 focus-visible:bg-white focus-visible:ring-2 focus-visible:ring-blue-100"
|
/>
|
||||||
onChange={(event) => updatePanelTitle(event.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="size-7 shrink-0 rounded-md text-slate-500 hover:bg-slate-100 hover:text-slate-700"
|
|
||||||
aria-label="关闭属性面板"
|
|
||||||
onClick={onClose}
|
|
||||||
>
|
|
||||||
<XIcon className="size-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
{panelDescription ? (
|
|
||||||
<div className="mt-1 text-xs leading-5 text-slate-500">
|
|
||||||
{panelDescription}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-7 shrink-0 rounded-md text-slate-500 hover:bg-slate-100 hover:text-slate-700"
|
||||||
|
aria-label="关闭属性面板"
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<XIcon className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{panelDescription ? (
|
||||||
|
<div className="mt-1 text-xs leading-5 text-slate-500">
|
||||||
|
{panelDescription}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<ScrollArea className="min-h-0 flex-1">
|
||||||
|
<div>
|
||||||
{selectedBranchItem && selectedBranch ? (
|
{selectedBranchItem && selectedBranch ? (
|
||||||
<ConditionBranchConfigPanel
|
<ConditionBranchConfigPanel
|
||||||
node={selectedNode}
|
node={selectedNode}
|
||||||
|
|||||||
Reference in New Issue
Block a user