feat: enhance NodeConfigPanel and VariableSelector with improved styling and description handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import type { ReactNode } from "react"
|
||||||
import { Trash2Icon } from "lucide-react"
|
import { Trash2Icon } from "lucide-react"
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
@@ -37,6 +38,9 @@ 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 cardComboboxClassName = "h-8 rounded-md border-slate-200 bg-white text-xs shadow-none"
|
||||||
|
|
||||||
export function NodeConfigPanel({
|
export function NodeConfigPanel({
|
||||||
node,
|
node,
|
||||||
nodeSpec,
|
nodeSpec,
|
||||||
@@ -125,25 +129,36 @@ export function NodeConfigPanel({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="min-h-0 flex-1 space-y-5 overflow-y-auto p-4">
|
<div className="min-h-0 flex-1 space-y-3 overflow-y-auto px-3 pb-3">
|
||||||
<div className="space-y-2">
|
<ConfigCard
|
||||||
<Label htmlFor={`node-title-${node.id}`}>标题</Label>
|
title="基础信息"
|
||||||
<Input
|
meta={nodeSpec?.description ? "说明" : undefined}
|
||||||
id={`node-title-${node.id}`}
|
>
|
||||||
value={node.data?.title ?? ""}
|
<div className="space-y-2">
|
||||||
placeholder={nodeSpec?.title || node.type}
|
<Label htmlFor={`node-title-${node.id}`} className="text-xs text-slate-600">
|
||||||
onChange={(event) => updateData({ title: event.target.value })}
|
标题
|
||||||
/>
|
</Label>
|
||||||
</div>
|
<Input
|
||||||
|
id={`node-title-${node.id}`}
|
||||||
|
value={node.data?.title ?? ""}
|
||||||
|
placeholder={nodeSpec?.title || node.type}
|
||||||
|
className={cardInputClassName}
|
||||||
|
onChange={(event) => updateData({ title: event.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{nodeSpec?.description ? (
|
||||||
|
<p className="mt-3 text-xs leading-5 text-slate-500">{nodeSpec.description}</p>
|
||||||
|
) : null}
|
||||||
|
</ConfigCard>
|
||||||
|
|
||||||
{inputSchema.length > 0 ? (
|
{inputSchema.length > 0 ? (
|
||||||
<div className="space-y-3">
|
<ConfigCard title="输入" meta={`${inputSchema.length} 项`}>
|
||||||
<div className="text-sm font-medium">输入</div>
|
<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">
|
<div key={input.name} className="space-y-1.5">
|
||||||
<Label className="flex items-center gap-1">
|
<Label className="flex items-center gap-1 text-xs text-slate-600">
|
||||||
<span>{input.label || input.name}</span>
|
<span>{input.label || input.name}</span>
|
||||||
{input.required ? <span className="text-destructive">*</span> : null}
|
{input.required ? <span className="text-destructive">*</span> : null}
|
||||||
</Label>
|
</Label>
|
||||||
@@ -151,6 +166,7 @@ export function NodeConfigPanel({
|
|||||||
value={isRefValue(value) ? value : undefined}
|
value={isRefValue(value) ? value : undefined}
|
||||||
variables={availableVariables ?? []}
|
variables={availableVariables ?? []}
|
||||||
placeholder="选择变量"
|
placeholder="选择变量"
|
||||||
|
triggerClassName={cardComboboxClassName}
|
||||||
onChange={(next) => {
|
onChange={(next) => {
|
||||||
updateData({
|
updateData({
|
||||||
inputsValues: {
|
inputsValues: {
|
||||||
@@ -163,7 +179,8 @@ export function NodeConfigPanel({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
</ConfigCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showConditionBranches && (node.type === "condition" || branches.length > 0) ? (
|
{showConditionBranches && (node.type === "condition" || branches.length > 0) ? (
|
||||||
@@ -221,51 +238,57 @@ export function ConditionBranchConfigPanel({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-0 flex-1 space-y-5 overflow-y-auto p-4">
|
<div className="min-h-0 flex-1 space-y-3 overflow-y-auto px-3 pb-3">
|
||||||
<div className="space-y-2">
|
<ConfigCard title="基础信息" meta={branch.default ? "默认" : "条件"}>
|
||||||
<Label htmlFor={`condition-branch-name-${node.id}-${branch.id}`}>分支名称</Label>
|
<div className="space-y-3">
|
||||||
<Input
|
<div className="space-y-1.5">
|
||||||
id={`condition-branch-name-${node.id}-${branch.id}`}
|
<Label htmlFor={`condition-branch-name-${node.id}-${branch.id}`} className="text-xs text-slate-600">
|
||||||
value={branch.name ?? ""}
|
分支名称
|
||||||
placeholder={branch.id}
|
</Label>
|
||||||
onChange={(event) => updateBranch({ ...branch, name: event.target.value })}
|
<Input
|
||||||
/>
|
id={`condition-branch-name-${node.id}-${branch.id}`}
|
||||||
</div>
|
value={branch.name ?? ""}
|
||||||
|
placeholder={branch.id}
|
||||||
|
className={cardInputClassName}
|
||||||
|
onChange={(event) => updateBranch({ ...branch, name: event.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-1.5">
|
||||||
<Label>目标节点</Label>
|
<Label className="text-xs text-slate-600">目标节点</Label>
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={branch.targetNodeId}
|
value={branch.targetNodeId}
|
||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
triggerClassName={cardComboboxClassName}
|
||||||
/>
|
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label className="flex items-center gap-2 text-sm">
|
<label className="flex items-center gap-2 text-xs text-slate-600">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={branch.default === true}
|
checked={branch.default === true}
|
||||||
className="size-4"
|
className="size-3.5"
|
||||||
onChange={(event) => updateBranch({
|
onChange={(event) => updateBranch({
|
||||||
...branch,
|
...branch,
|
||||||
default: event.target.checked,
|
default: event.target.checked,
|
||||||
condition: event.target.checked ? undefined : branch.condition,
|
condition: event.target.checked ? undefined : branch.condition,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
默认分支
|
默认分支
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
|
</ConfigCard>
|
||||||
|
|
||||||
{branch.default ? (
|
{branch.default ? (
|
||||||
<div className="rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground">
|
<div className="rounded-lg border border-slate-200 bg-white px-3 py-2 text-xs text-slate-500">
|
||||||
默认分支不需要条件表达式,会在其他条件不匹配时执行。
|
默认分支不需要条件表达式,会在其他条件不匹配时执行。
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<ConditionFields
|
<ConfigCard title="条件表达式">
|
||||||
branch={branch}
|
<ConditionFields branch={branch} variables={variables} onChange={updateBranch} />
|
||||||
variables={variables}
|
</ConfigCard>
|
||||||
onChange={updateBranch}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{branch.default ? null : (
|
{branch.default ? null : (
|
||||||
@@ -273,7 +296,7 @@ export function ConditionBranchConfigPanel({
|
|||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 px-2 text-xs text-muted-foreground hover:text-destructive"
|
className="h-8 px-2 text-xs text-slate-500 hover:text-destructive"
|
||||||
onClick={() => onDelete(branch.id)}
|
onClick={() => onDelete(branch.id)}
|
||||||
>
|
>
|
||||||
删除条件
|
删除条件
|
||||||
@@ -303,27 +326,32 @@ function ConditionBranchesEditor({
|
|||||||
const targetOptions = buildTargetOptions(nodes, currentNodeId)
|
const targetOptions = buildTargetOptions(nodes, currentNodeId)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<ConfigCard
|
||||||
<div className="flex items-center justify-between gap-2">
|
title="条件分支"
|
||||||
<div className="text-sm font-medium">条件分支</div>
|
meta={`${branches.length} 项`}
|
||||||
<Button type="button" variant="outline" size="sm" className="h-7 px-2 text-xs" onClick={onAdd}>
|
action={
|
||||||
|
<Button type="button" variant="ghost" size="sm" className="h-7 px-2 text-xs" onClick={onAdd}>
|
||||||
添加
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
}
|
||||||
|
>
|
||||||
{branches.length === 0 ? (
|
{branches.length === 0 ? (
|
||||||
<div className="rounded-md border bg-muted/20 p-3 text-xs text-muted-foreground">
|
<div className="rounded-md border border-dashed border-slate-200 bg-slate-50 px-3 py-3 text-xs text-slate-500">
|
||||||
暂无分支。条件节点需要至少一个默认分支或条件分支。
|
暂无分支。条件节点需要至少一个默认分支或条件分支。
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="space-y-3">
|
<div className="space-y-2">
|
||||||
{branches.map((branch) => {
|
{branches.map((branch) => {
|
||||||
return (
|
return (
|
||||||
<div key={branch.id} className="space-y-3 rounded-md border p-3">
|
<div key={branch.id} className="space-y-2 rounded-lg border border-slate-200 bg-slate-50/60 p-2.5">
|
||||||
<div className="flex items-center justify-between gap-2">
|
<div className="flex items-center justify-between 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">
|
||||||
|
{branch.default ? "ELSE" : "IF"}
|
||||||
|
</span>
|
||||||
<Input
|
<Input
|
||||||
value={branch.name ?? ""}
|
value={branch.name ?? ""}
|
||||||
placeholder={branch.id}
|
placeholder={branch.id}
|
||||||
className="h-8"
|
className={cn(cardInputClassName, "min-w-0 flex-1 border-transparent bg-white font-medium")}
|
||||||
onChange={(event) => onChange({ ...branch, name: event.target.value })}
|
onChange={(event) => onChange({ ...branch, name: event.target.value })}
|
||||||
/>
|
/>
|
||||||
{branch.default ? null : (
|
{branch.default ? null : (
|
||||||
@@ -331,7 +359,7 @@ function ConditionBranchesEditor({
|
|||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 px-2 text-xs text-muted-foreground hover:text-destructive"
|
className="h-7 px-2 text-xs text-slate-500 hover:text-destructive"
|
||||||
onClick={() => onDelete(branch.id)}
|
onClick={() => onDelete(branch.id)}
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
@@ -339,21 +367,22 @@ function ConditionBranchesEditor({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
<div className="grid grid-cols-[64px_minmax(0,1fr)] items-center gap-2">
|
||||||
<Label>目标节点</Label>
|
<Label className="text-xs text-slate-500">目标节点</Label>
|
||||||
<OptionCombobox
|
<OptionCombobox
|
||||||
value={branch.targetNodeId}
|
value={branch.targetNodeId}
|
||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
|
triggerClassName={cardComboboxClassName}
|
||||||
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label className="flex items-center gap-2 text-sm">
|
<label className="flex items-center gap-2 text-xs text-slate-500">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={branch.default === true}
|
checked={branch.default === true}
|
||||||
className="size-4"
|
className="size-3.5"
|
||||||
onChange={(event) => onChange({
|
onChange={(event) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
default: event.target.checked,
|
default: event.target.checked,
|
||||||
@@ -364,13 +393,15 @@ function ConditionBranchesEditor({
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
{branch.default ? null : (
|
{branch.default ? null : (
|
||||||
<ConditionFields branch={branch} variables={variables} onChange={onChange} />
|
<div className="border-t border-slate-200 pt-2">
|
||||||
|
<ConditionFields branch={branch} variables={variables} onChange={onChange} compact />
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ConfigCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,45 +409,51 @@ function ConditionFields({
|
|||||||
branch,
|
branch,
|
||||||
variables,
|
variables,
|
||||||
onChange,
|
onChange,
|
||||||
|
compact = false,
|
||||||
}: {
|
}: {
|
||||||
branch: WorkflowConditionBranch
|
branch: WorkflowConditionBranch
|
||||||
variables: WorkflowVariableRef[]
|
variables: WorkflowVariableRef[]
|
||||||
onChange: (branch: WorkflowConditionBranch) => void
|
onChange: (branch: WorkflowConditionBranch) => void
|
||||||
|
compact?: boolean
|
||||||
}) {
|
}) {
|
||||||
const condition = branch.condition ?? {}
|
const condition = branch.condition ?? {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className={cn("space-y-3", compact && "space-y-2")}>
|
||||||
<div className="space-y-1.5">
|
<div className={cn("space-y-1.5", compact && "grid grid-cols-[64px_minmax(0,1fr)] items-center gap-2 space-y-0")}>
|
||||||
<Label>左值</Label>
|
<Label className="text-xs text-slate-500">左值</Label>
|
||||||
<VariableSelector
|
<VariableSelector
|
||||||
value={isRefValue(condition.left) ? condition.left : undefined}
|
value={isRefValue(condition.left) ? condition.left : undefined}
|
||||||
variables={variables}
|
variables={variables}
|
||||||
placeholder="选择变量"
|
placeholder="选择变量"
|
||||||
|
triggerClassName={cardComboboxClassName}
|
||||||
onChange={(left) => onChange({
|
onChange={(left) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, left },
|
condition: { ...condition, left },
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-[1fr_1fr] gap-2">
|
<div className={cn("grid grid-cols-[1fr_1fr] gap-2", compact && "grid-cols-[64px_minmax(0,1fr)_96px] items-center")}>
|
||||||
<div className="space-y-1.5">
|
{compact ? <Label className="text-xs text-slate-500">判断</Label> : null}
|
||||||
<Label>操作符</Label>
|
<div className={cn("space-y-1.5", compact && "space-y-0")}>
|
||||||
|
{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}
|
||||||
onChange={(operator) => onChange({
|
onChange={(operator) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, operator },
|
condition: { ...condition, operator },
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={cn("space-y-1.5", ["exists", "empty"].includes(condition.operator ?? "") && "opacity-50")}>
|
<div className={cn("space-y-1.5", compact && "space-y-0", ["exists", "empty"].includes(condition.operator ?? "") && "opacity-50")}>
|
||||||
<Label>右值</Label>
|
{compact ? null : <Label className="text-xs text-slate-500">右值</Label>}
|
||||||
<Input
|
<Input
|
||||||
value={stringifyConditionRight(condition.right)}
|
value={stringifyConditionRight(condition.right)}
|
||||||
disabled={["exists", "empty"].includes(condition.operator ?? "")}
|
disabled={["exists", "empty"].includes(condition.operator ?? "")}
|
||||||
|
className={cardInputClassName}
|
||||||
onChange={(event) => onChange({
|
onChange={(event) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, right: event.target.value },
|
condition: { ...condition, right: event.target.value },
|
||||||
@@ -428,6 +465,33 @@ function ConditionFields({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ConfigCard({
|
||||||
|
title,
|
||||||
|
meta,
|
||||||
|
action,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
title: string
|
||||||
|
meta?: string
|
||||||
|
action?: ReactNode
|
||||||
|
children: ReactNode
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<section className="overflow-hidden rounded-lg border border-slate-200 bg-white">
|
||||||
|
<div className="flex min-h-10 items-center justify-between gap-2 border-b border-slate-100 px-3 py-2">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="truncate text-[13px] font-semibold text-slate-900">{title}</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
|
{meta ? <span className="text-xs text-slate-500">{meta}</span> : null}
|
||||||
|
{action}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="p-3">{children}</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
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")
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ export function VariableSelector({
|
|||||||
variables,
|
variables,
|
||||||
onChange,
|
onChange,
|
||||||
placeholder = "选择变量",
|
placeholder = "选择变量",
|
||||||
|
triggerClassName,
|
||||||
}: {
|
}: {
|
||||||
value?: WorkflowVariableSelector
|
value?: WorkflowVariableSelector
|
||||||
variables: WorkflowVariableRef[]
|
variables: WorkflowVariableRef[]
|
||||||
onChange: (value: WorkflowVariableSelector) => void
|
onChange: (value: WorkflowVariableSelector) => void
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
|
triggerClassName?: string
|
||||||
}) {
|
}) {
|
||||||
const selected = value ? `${refNodeId(value)}.${refField(value)}` : ""
|
const selected = value ? `${refNodeId(value)}.${refField(value)}` : ""
|
||||||
const options = variables.map((variable) => ({
|
const options = variables.map((variable) => ({
|
||||||
@@ -33,6 +35,7 @@ export function VariableSelector({
|
|||||||
value={selected}
|
value={selected}
|
||||||
options={options}
|
options={options}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
triggerClassName={triggerClassName}
|
||||||
onChange={(next) => {
|
onChange={(next) => {
|
||||||
const variable = variables.find((item) => `${item.nodeId}.${item.field}` === next)
|
const variable = variables.find((item) => `${item.nodeId}.${item.field}` === next)
|
||||||
if (variable) {
|
if (variable) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { AIWorkflowDefinition, AIWorkflowNodeSpec } from "@/lib/api/admin"
|
|||||||
|
|
||||||
import type { SelectedWorkflowBranch } from "./workflow-branch-selection"
|
import type { SelectedWorkflowBranch } from "./workflow-branch-selection"
|
||||||
import { ConditionBranchConfigPanel, NodeConfigPanel } from "./node-config-panel"
|
import { ConditionBranchConfigPanel, NodeConfigPanel } from "./node-config-panel"
|
||||||
|
import { WorkflowNodeIcon } from "./workflow-node-icon"
|
||||||
import {
|
import {
|
||||||
getAvailableVariables,
|
getAvailableVariables,
|
||||||
normalizeNodeConfig,
|
normalizeNodeConfig,
|
||||||
@@ -49,6 +50,7 @@ export function WorkflowConfigPanel({
|
|||||||
const panelDescription = selectedBranchItem
|
const panelDescription = selectedBranchItem
|
||||||
? "配置该条件分支的匹配规则和目标节点。"
|
? "配置该条件分支的匹配规则和目标节点。"
|
||||||
: selectedNodeSpec?.description || ""
|
: selectedNodeSpec?.description || ""
|
||||||
|
const panelIcon = selectedBranchItem ? "GitBranchIcon" : selectedNodeSpec?.icon
|
||||||
|
|
||||||
if (!selectedNode) {
|
if (!selectedNode) {
|
||||||
return null
|
return null
|
||||||
@@ -67,30 +69,52 @@ export function WorkflowConfigPanel({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pointer-events-none absolute inset-y-3 right-3 z-50 flex w-[360px] max-w-[calc(100%-1.5rem)]">
|
<div className="pointer-events-none absolute inset-y-3 right-3 z-50 flex w-[380px] max-w-[calc(100%-1.5rem)]">
|
||||||
<section className="pointer-events-auto flex min-h-0 w-full flex-col overflow-hidden rounded-md border bg-background/95 shadow-sm backdrop-blur">
|
<section className="pointer-events-auto flex min-h-0 w-full flex-col overflow-hidden rounded-xl border border-slate-200 bg-[#f8fafc] shadow-lg backdrop-blur">
|
||||||
<div className="flex shrink-0 items-start justify-between gap-3 border-b px-4 py-3">
|
<div className="shrink-0 p-3 pb-2">
|
||||||
<div className="min-w-0">
|
<div className="overflow-hidden rounded-lg border border-slate-200 bg-white">
|
||||||
<div className="truncate text-sm font-medium">{panelTitle}</div>
|
<div className="flex items-start justify-between gap-3 px-3 py-3">
|
||||||
|
<div className="flex min-w-0 items-start gap-2.5">
|
||||||
|
<WorkflowNodeIcon
|
||||||
|
icon={panelIcon}
|
||||||
|
size="sm"
|
||||||
|
className="rounded-md bg-slate-100 text-slate-600 shadow-none"
|
||||||
|
/>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="truncate text-sm font-semibold leading-5 text-slate-900">
|
||||||
|
{panelTitle}
|
||||||
|
</div>
|
||||||
|
{panelDescription ? (
|
||||||
|
<div className="mt-1 line-clamp-2 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>
|
||||||
{panelMeta ? (
|
{panelMeta ? (
|
||||||
<div className="mt-1 truncate font-mono text-xs text-muted-foreground">{panelMeta}</div>
|
<div className="border-t border-slate-100 px-3 py-2">
|
||||||
) : null}
|
<div className="flex flex-wrap gap-1.5">
|
||||||
{panelDescription ? (
|
<span className="inline-flex h-6 items-center rounded-full border border-slate-200 bg-slate-50 px-2 font-mono text-[11px] text-slate-600">
|
||||||
<div className="mt-2 line-clamp-3 text-xs leading-5 text-muted-foreground">
|
{panelMeta}
|
||||||
{panelDescription}
|
</span>
|
||||||
|
<span className="inline-flex h-6 items-center rounded-full border border-blue-100 bg-blue-50 px-2 text-[11px] text-blue-700">
|
||||||
|
可配置
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="size-8 shrink-0 text-muted-foreground"
|
|
||||||
aria-label="关闭属性面板"
|
|
||||||
onClick={onClose}
|
|
||||||
>
|
|
||||||
<XIcon className="size-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="min-h-0 flex-1">
|
<div className="min-h-0 flex-1">
|
||||||
{selectedBranchItem && selectedBranch ? (
|
{selectedBranchItem && selectedBranch ? (
|
||||||
@@ -109,7 +133,6 @@ export function WorkflowConfigPanel({
|
|||||||
nodes={definition.nodes}
|
nodes={definition.nodes}
|
||||||
availableVariables={availableVariables}
|
availableVariables={availableVariables}
|
||||||
showHeader={false}
|
showHeader={false}
|
||||||
showConditionBranches={selectedNode.type !== "condition"}
|
|
||||||
onChange={onChangeNodeData}
|
onChange={onChangeNodeData}
|
||||||
onDelete={onDeleteNode}
|
onDelete={onDeleteNode}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ type OptionComboboxProps = {
|
|||||||
searchPlaceholder?: string
|
searchPlaceholder?: string
|
||||||
emptyText?: string
|
emptyText?: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
triggerClassName?: string
|
||||||
onChange: (value: string) => void
|
onChange: (value: string) => void
|
||||||
renderOptionAction?: (option: ComboboxOption) => ReactNode
|
renderOptionAction?: (option: ComboboxOption) => ReactNode
|
||||||
}
|
}
|
||||||
@@ -44,6 +45,7 @@ export function OptionCombobox({
|
|||||||
searchPlaceholder,
|
searchPlaceholder,
|
||||||
emptyText,
|
emptyText,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
triggerClassName,
|
||||||
onChange,
|
onChange,
|
||||||
renderOptionAction,
|
renderOptionAction,
|
||||||
}: OptionComboboxProps) {
|
}: OptionComboboxProps) {
|
||||||
@@ -59,7 +61,7 @@ export function OptionCombobox({
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
role="combobox"
|
role="combobox"
|
||||||
className="m-0 w-full justify-between font-normal"
|
className={cn("m-0 w-full justify-between font-normal", triggerClassName)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user