diff --git a/web/app/components/workflow/store/workflow/debug/mock-data.ts b/web/app/components/workflow/store/workflow/debug/mock-data.ts index 85bc574bba..03a37bd264 100644 --- a/web/app/components/workflow/store/workflow/debug/mock-data.ts +++ b/web/app/components/workflow/store/workflow/debug/mock-data.ts @@ -26,6 +26,16 @@ export const conversationVars: VarInInspect[] = [ value: 'conversation var value...', edited: false, }, + { + id: 'con2', + type: VarInInspectType.conversation, + name: 'conversationVar 2', + description: '', + selector: ['conversation', 'var2'], + value_type: VarType.number, + value: 456, + edited: false, + }, ] export const systemVars: VarInInspect[] = [ diff --git a/web/app/components/workflow/variable-inspect/group.tsx b/web/app/components/workflow/variable-inspect/group.tsx index 67a06e331d..d24a94c31f 100644 --- a/web/app/components/workflow/variable-inspect/group.tsx +++ b/web/app/components/workflow/variable-inspect/group.tsx @@ -5,79 +5,76 @@ import { // RiErrorWarningFill, // RiLoader2Line, } from '@remixicon/react' -import { useStore } from '../store' // import { BlockEnum } from '../types' // import Button from '@/app/components/base/button' // import ActionButton from '@/app/components/base/action-button' // import Tooltip from '@/app/components/base/tooltip' // import BlockIcon from '@/app/components/workflow/block-icon' import { - // BubbleX, + BubbleX, Env, } from '@/app/components/base/icons/src/vender/line/others' -// import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' -// import useCurrentVars from '../hooks/use-inspect-vars-crud' +import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import type { currentVarType } from './panel' +import { VarInInspectType } from '@/types/workflow' +import type { VarInInspect } from '@/types/workflow' import cn from '@/utils/classnames' type Props = { - isEnv?: boolean - isChatVar?: boolean - isSystem?: boolean currentVar?: currentVarType + varType: VarInInspectType + varList: VarInInspect[] handleSelect: (state: any) => void } const Group = ({ - isEnv, - isChatVar, - isSystem, currentVar, + varType, + varList, handleSelect, }: Props) => { const { t } = useTranslation() - - const environmentVariables = useStore(s => s.environmentVariables) - // const { - // conversationVars, - // systemVars, - // nodesWithInspectVars, - // } = useCurrentVars() - const [isCollapsed, setIsCollapsed] = useState(false) + const isEnv = varType === VarInInspectType.environment + const isChatVar = varType === VarInInspectType.conversation + const isSystem = varType === VarInInspectType.system + const handleSelectVar = (varItem: any, type?: string) => { - if (type === 'env') { + if (type === VarInInspectType.environment) { handleSelect({ nodeId: 'env', nodeTitle: 'env', - nodeType: 'env', + nodeType: VarInInspectType.environment, var: { ...varItem, - type: 'env', + type: VarInInspectType.environment, ...(varItem.value_type === 'secret' ? { value: '******************' } : {}), }, }) return } - if (type === 'chat') { + if (type === VarInInspectType.conversation) { handleSelect({ nodeId: 'conversation', nodeTitle: 'conversation', - nodeType: 'conversation', + nodeType: VarInInspectType.conversation, var: { ...varItem, - type: 'conversation', + type: VarInInspectType.conversation, }, }) return } - if (type === 'system') { + if (type === VarInInspectType.system) { handleSelect({ nodeId: 'sys', nodeTitle: 'sys', - nodeType: 'sys', - var: varItem, + nodeType: VarInInspectType.system, + var: { + ...varItem, + type: VarInInspectType.system, + }, }) return } @@ -105,18 +102,20 @@ const Group = ({ {/* var item list */} {!isCollapsed && (