feat: loop var support bool type

feat/support-bool-variable-fe
Joel 7 months ago
parent 657d3d1dae
commit b72d977871

@ -18,33 +18,15 @@ import {
ValueType, ValueType,
VarType, VarType,
} from '@/app/components/workflow/types' } from '@/app/components/workflow/types'
import BoolValue from '@/app/components/workflow/panel/chat-variable-panel/components/bool-value'
const objectPlaceholder = `# example import {
# { arrayBoolPlaceholder,
# "name": "ray", arrayNumberPlaceholder,
# "age": 20 arrayObjectPlaceholder,
# }` arrayStringPlaceholder,
const arrayStringPlaceholder = `# example objectPlaceholder,
# [ } from '@/app/components/workflow/panel/chat-variable-panel/utils'
# "value1",
# "value2"
# ]`
const arrayNumberPlaceholder = `# example
# [
# 100,
# 200
# ]`
const arrayObjectPlaceholder = `# example
# [
# {
# "name": "ray",
# "age": 20
# },
# {
# "name": "lily",
# "age": 18
# }
# ]`
type FormItemProps = { type FormItemProps = {
nodeId: string nodeId: string
@ -83,6 +65,8 @@ const FormItem = ({
return arrayNumberPlaceholder return arrayNumberPlaceholder
if (var_type === VarType.arrayObject) if (var_type === VarType.arrayObject)
return arrayObjectPlaceholder return arrayObjectPlaceholder
if (var_type === VarType.arrayBoolean)
return arrayBoolPlaceholder
return objectPlaceholder return objectPlaceholder
}, [var_type]) }, [var_type])
@ -120,9 +104,17 @@ const FormItem = ({
/> />
) )
} }
{
value_type === ValueType.constant && var_type === VarType.boolean && (
<BoolValue
value={value}
onChange={handleChange}
/>
)
}
{ {
value_type === ValueType.constant 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)
&& ( && (
<div className='w-full rounded-[10px] bg-components-input-bg-normal py-2 pl-3 pr-1' style={{ height: editorMinHeight }}> <div className='w-full rounded-[10px] bg-components-input-bg-normal py-2 pl-3 pr-1' style={{ height: editorMinHeight }}>
<CodeEditor <CodeEditor

@ -22,6 +22,10 @@ const VariableTypeSelect = ({
label: 'Object', label: 'Object',
value: VarType.object, value: VarType.object,
}, },
{
label: 'Boolean',
value: VarType.boolean,
},
{ {
label: 'Array[string]', label: 'Array[string]',
value: VarType.arrayString, value: VarType.arrayString,
@ -34,6 +38,10 @@ const VariableTypeSelect = ({
label: 'Array[object]', label: 'Array[object]',
value: VarType.arrayObject, value: VarType.arrayObject,
}, },
{
label: 'Array[boolean]',
value: VarType.arrayBoolean,
},
] ]
return ( return (

@ -19,6 +19,13 @@ import cn from '@/utils/classnames'
import { checkKeys, replaceSpaceWithUnderscreInVarNameInput } from '@/utils/var' import { checkKeys, replaceSpaceWithUnderscreInVarNameInput } from '@/utils/var'
import BoolValue from './bool-value' import BoolValue from './bool-value'
import ArrayBoolList from './array-bool-list' import ArrayBoolList from './array-bool-list'
import {
arrayBoolPlaceholder,
arrayNumberPlaceholder,
arrayObjectPlaceholder,
arrayStringPlaceholder,
objectPlaceholder,
} from '@/app/components/workflow/panel/chat-variable-panel/utils'
export type ModalPropsType = { export type ModalPropsType = {
chatVar?: ConversationVariable chatVar?: ConversationVariable
@ -43,39 +50,6 @@ const typeList = [
ChatVarType.ArrayObject, ChatVarType.ArrayObject,
] ]
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
# }
# ]`
const arrayBoolPlaceholder = `# example
# [
# "True",
# "False"
# ]`
const ChatVariableModal = ({ const ChatVariableModal = ({
chatVar, chatVar,
onClose, onClose,

@ -0,0 +1,35 @@
export const objectPlaceholder = `# example
# {
# "name": "ray",
# "age": 20
# }`
export const arrayStringPlaceholder = `# example
# [
# "value1",
# "value2"
# ]`
export const arrayNumberPlaceholder = `# example
# [
# 100,
# 200
# ]`
export const arrayObjectPlaceholder = `# example
# [
# {
# "name": "ray",
# "age": 20
# },
# {
# "name": "lily",
# "age": 18
# }
# ]`
export const arrayBoolPlaceholder = `# example
# [
# "True",
# "False"
# ]`

@ -262,6 +262,7 @@ export enum VarType {
arrayString = 'array[string]', arrayString = 'array[string]',
arrayNumber = 'array[number]', arrayNumber = 'array[number]',
arrayObject = 'array[object]', arrayObject = 'array[object]',
arrayBoolean = 'array[boolean]',
arrayFile = 'array[file]', arrayFile = 'array[file]',
any = 'any', any = 'any',
arrayAny = 'array[any]', arrayAny = 'array[any]',

Loading…
Cancel
Save