feat: add var type

feat/support-bool-variable-fe
Joel 11 months ago
parent 77aa35ff15
commit 1094b3da23

@ -12,6 +12,8 @@ import {
import InputVarTypeIcon from '@/app/components/workflow/nodes/_base/components/input-var-type-icon' import InputVarTypeIcon from '@/app/components/workflow/nodes/_base/components/input-var-type-icon'
import type { InputVarType } from '@/app/components/workflow/types' import type { InputVarType } from '@/app/components/workflow/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import Badge from '@/app/components/base/badge'
import { inputVarTypeToVarType } from '@/app/components/workflow/nodes/_base/components/variable/utils'
export type Item = { export type Item = {
value: InputVarType value: InputVarType
@ -60,7 +62,8 @@ const TypeSelector: FC<Props> = ({
{selectedItem?.name} {selectedItem?.name}
</span> </span>
</div> </div>
<div> <div className='flex items-center space-x-1'>
<Badge uppercase={false}>{inputVarTypeToVarType(selectedItem?.value as InputVarType)}</Badge>
<ChevronDownIcon className={cn('h-4 w-4 shrink-0 text-text-quaternary group-hover:text-text-secondary', open && 'text-text-secondary')} /> <ChevronDownIcon className={cn('h-4 w-4 shrink-0 text-text-quaternary group-hover:text-text-secondary', open && 'text-text-secondary')} />
</div> </div>
</div> </div>
@ -84,7 +87,7 @@ const TypeSelector: FC<Props> = ({
<InputVarTypeIcon type={item.value} className='size-4 shrink-0 text-text-secondary' /> <InputVarTypeIcon type={item.value} className='size-4 shrink-0 text-text-secondary' />
<span title={item.name}>{item.name}</span> <span title={item.name}>{item.name}</span>
</div> </div>
<Badge uppercase={false}>{inputVarTypeToVarType(item.value)}</Badge>
</div> </div>
))} ))}
</div> </div>

@ -49,9 +49,10 @@ export const isConversationVar = (valueSelector: ValueSelector) => {
return valueSelector[0] === 'conversation' return valueSelector[0] === 'conversation'
} }
const inputVarTypeToVarType = (type: InputVarType): VarType => { export const inputVarTypeToVarType = (type: InputVarType): VarType => {
return ({ return ({
[InputVarType.number]: VarType.number, [InputVarType.number]: VarType.number,
[InputVarType.boolean]: VarType.boolean,
[InputVarType.singleFile]: VarType.file, [InputVarType.singleFile]: VarType.file,
[InputVarType.multiFiles]: VarType.arrayFile, [InputVarType.multiFiles]: VarType.arrayFile,
} as any)[type] || VarType.string } as any)[type] || VarType.string

Loading…
Cancel
Save