From b72d9778714e3eed3e477e2baa207a88d3f60fd8 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 8 Jul 2025 15:23:24 +0800 Subject: [PATCH] feat: loop var support bool type --- .../components/loop-variables/form-item.tsx | 46 ++++++++----------- .../loop-variables/variable-type-select.tsx | 8 ++++ .../components/variable-modal.tsx | 40 +++------------- .../panel/chat-variable-panel/utils.ts | 35 ++++++++++++++ web/app/components/workflow/types.ts | 1 + 5 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 web/app/components/workflow/panel/chat-variable-panel/utils.ts diff --git a/web/app/components/workflow/nodes/loop/components/loop-variables/form-item.tsx b/web/app/components/workflow/nodes/loop/components/loop-variables/form-item.tsx index 4a05e457b3..6a66c242ba 100644 --- a/web/app/components/workflow/nodes/loop/components/loop-variables/form-item.tsx +++ b/web/app/components/workflow/nodes/loop/components/loop-variables/form-item.tsx @@ -18,33 +18,15 @@ import { ValueType, VarType, } from '@/app/components/workflow/types' +import BoolValue from '@/app/components/workflow/panel/chat-variable-panel/components/bool-value' -const objectPlaceholder = `# example -# { -# "name": "ray", -# "age": 20 -# }` -const arrayStringPlaceholder = `# example -# [ -# "value1", -# "value2" -# ]` -const arrayNumberPlaceholder = `# example -# [ -# 100, -# 200 -# ]` -const arrayObjectPlaceholder = `# example -# [ -# { -# "name": "ray", -# "age": 20 -# }, -# { -# "name": "lily", -# "age": 18 -# } -# ]` +import { + arrayBoolPlaceholder, + arrayNumberPlaceholder, + arrayObjectPlaceholder, + arrayStringPlaceholder, + objectPlaceholder, +} from '@/app/components/workflow/panel/chat-variable-panel/utils' type FormItemProps = { nodeId: string @@ -83,6 +65,8 @@ const FormItem = ({ return arrayNumberPlaceholder if (var_type === VarType.arrayObject) return arrayObjectPlaceholder + if (var_type === VarType.arrayBoolean) + return arrayBoolPlaceholder return objectPlaceholder }, [var_type]) @@ -120,9 +104,17 @@ const FormItem = ({ /> ) } + { + value_type === ValueType.constant && var_type === VarType.boolean && ( + + ) + } { value_type === ValueType.constant - && (var_type === VarType.object || var_type === VarType.arrayString || var_type === VarType.arrayNumber || var_type === VarType.arrayObject) + && (var_type === VarType.object || var_type === VarType.arrayString || var_type === VarType.arrayNumber || var_type === VarType.arrayObject || var_type === VarType.arrayBoolean) && (