import { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiArrowRightSLine, // RiErrorWarningFill, // RiLoader2Line, } from '@remixicon/react' // 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, Env, } from '@/app/components/base/icons/src/vender/line/others' 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 = { currentVar?: currentVarType varType: VarInInspectType varList: VarInInspect[] handleSelect: (state: any) => void } const Group = ({ currentVar, varType, varList, handleSelect, }: Props) => { const { t } = useTranslation() 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 === VarInInspectType.environment) { handleSelect({ nodeId: 'env', nodeTitle: 'env', nodeType: VarInInspectType.environment, var: { ...varItem, type: VarInInspectType.environment, ...(varItem.value_type === 'secret' ? { value: '******************' } : {}), }, }) return } if (type === VarInInspectType.conversation) { handleSelect({ nodeId: 'conversation', nodeTitle: 'conversation', nodeType: VarInInspectType.conversation, var: { ...varItem, type: VarInInspectType.conversation, }, }) return } if (type === VarInInspectType.system) { handleSelect({ nodeId: 'sys', nodeTitle: 'sys', nodeType: VarInInspectType.system, var: { ...varItem, type: VarInInspectType.system, }, }) return } handleSelect({ nodeId: varItem.nodeId, nodeTitle: varItem.nodeTitle, nodeType: varItem.nodeType, var: varItem.var, }) } return (
{/* node item */}
setIsCollapsed(!isCollapsed)}>
{isEnv && t('workflow.debug.variableInspect.envNode')} {isChatVar && t('workflow.debug.variableInspect.chatNode')} {isSystem && t('workflow.debug.variableInspect.systemNode')}
{/* var item list */} {!isCollapsed && (
{varList.length > 0 && varList.map(varItem => (
handleSelectVar(varItem, varType)} > {isEnv && } {isChatVar && } {isSystem && }
{varItem.name}
{varItem.value_type}
))}
)}
) } export default Group