diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsx index bf8b86bcc7..07f381d941 100644 --- a/web/app/components/workflow/variable-inspect/right.tsx +++ b/web/app/components/workflow/variable-inspect/right.tsx @@ -9,6 +9,7 @@ import { useStore } from '../store' import { BlockEnum } from '../types' import useCurrentVars from '../hooks/use-current-vars' import Empty from './empty' +import ValueContent from './value-content' import ActionButton from '@/app/components/base/action-button' import Badge from '@/app/components/base/badge' import CopyFeedback from '@/app/components/base/copy-feedback' @@ -32,6 +33,7 @@ export const currentVar = { // var_type: 'file', // var_type: 'array[file]', value: 'tuituitui', + edited: true, } type Props = { @@ -90,15 +92,19 @@ const Right = ({ handleOpenMenu }: Props) => {
{current && ( <> - - - {t('workflow.debug.variableInspect.edited')} - - - - - - + {current.edited && ( + + + {t('workflow.debug.variableInspect.edited')} + + )} + {current.edited && ( + + + + + + )} {(current.type !== 'environment' || current.var_type !== 'secret') && ( )} @@ -112,6 +118,7 @@ const Right = ({ handleOpenMenu }: Props) => { {/* content */}
{!current && } + {current && }
) diff --git a/web/app/components/workflow/variable-inspect/value-content.tsx b/web/app/components/workflow/variable-inspect/value-content.tsx new file mode 100644 index 0000000000..81115b1234 --- /dev/null +++ b/web/app/components/workflow/variable-inspect/value-content.tsx @@ -0,0 +1,75 @@ +import { useState } from 'react' +// import { useTranslation } from 'react-i18next' +import Textarea from '@/app/components/base/textarea' +// import cn from '@/utils/classnames' + +export const currentVar = { + id: 'var-jfkldjjfkldaf-dfhekdfj', + type: 'node', + // type: 'conversation', + // type: 'environment', + name: 'out_put', + // var_type: 'string', + var_type: 'number', + // var_type: 'object', + // var_type: 'array[string]', + // var_type: 'array[number]', + // var_type: 'array[object]', + // var_type: 'file', + // var_type: 'array[file]', + // value: 'tuituitui', + value: 123, + edited: true, +} + +const ValueContent = () => { + const current = currentVar + const [value, setValue] = useState(current.value ? JSON.stringify(current.value) : '') + + const handleValueChange = (value: string) => { + if (current.var_type === 'string') + setValue(value) + + if (current.var_type === 'number') { + if (/^-?\d+(\.)?(\d+)?$/.test(value)) { + console.log(value) + setValue(value) + } + return + } + if (current.var_type === 'object') { + // TODO update object + } + if (current.var_type === 'array[string]') { + // TODO update array[string] + } + if (current.var_type === 'array[number]') { + // TODO update array[number] + } + if (current.var_type === 'array[object]') { + // TODO update array[object] + } + if (current.var_type === 'file') { + // TODO update file + } + if (current.var_type === 'array[file]') { + // TODO update array[file] + } + } + + return ( +
+ {(current.var_type === 'secret' || current.var_type === 'string' || current.var_type === 'number') && ( +