diff --git a/web/app/(commonLayout)/workflow/nodes/page.tsx b/web/app/(commonLayout)/workflow/nodes/page.tsx index ea6542d771..a13fd8c802 100644 --- a/web/app/(commonLayout)/workflow/nodes/page.tsx +++ b/web/app/(commonLayout)/workflow/nodes/page.tsx @@ -5,9 +5,9 @@ import { memo } from 'react' import Workflow from '@/app/components/workflow' import { BlockEnum } from '@/app/components/workflow/types' const nodes = [ - BlockEnum.End/* 12 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.QuestionClassifier/* 5 */, + BlockEnum.VariableAssigner/* 11 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.QuestionClassifier/* 5 */, BlockEnum.IfElse/* 6 */, BlockEnum.Code/* 7 */, BlockEnum.TemplateTransform/* 8 */, BlockEnum.HttpRequest/* 9 */, BlockEnum.Tool/* 10 */, - BlockEnum.VariableAssigner/* 11 */, + BlockEnum.End/* 12 */, ].map((item, i) => ({ id: `${i + 1}`, type: 'custom', diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx index 9be0b44477..d5ba0e368e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx @@ -30,7 +30,7 @@ type Props = { // } // TODO: get data from context -const getNodeInfoById = (id: string) => { +export const getNodeInfoById = (id: string) => { return mockNodesData[id] } diff --git a/web/app/components/workflow/nodes/variable-assigner/mock.ts b/web/app/components/workflow/nodes/variable-assigner/mock.ts index ace6c8800f..505de87adc 100644 --- a/web/app/components/workflow/nodes/variable-assigner/mock.ts +++ b/web/app/components/workflow/nodes/variable-assigner/mock.ts @@ -1,9 +1,10 @@ +import { BlockEnum } from '../../types' import type { VariableAssignerNodeType } from './types' export const mockData: VariableAssignerNodeType = { title: 'Test', desc: 'Test', - type: 'Test', + type: BlockEnum.VariableAssigner, output_type: 'string', variables: [ ['aaa', 'name'], diff --git a/web/app/components/workflow/nodes/variable-assigner/node.tsx b/web/app/components/workflow/nodes/variable-assigner/node.tsx index d0863bd5e2..37922e4209 100644 --- a/web/app/components/workflow/nodes/variable-assigner/node.tsx +++ b/web/app/components/workflow/nodes/variable-assigner/node.tsx @@ -1,15 +1,71 @@ import type { FC } from 'react' import { useTranslation } from 'react-i18next' -// import { mockData } from './mock' +import { mockData } from './mock' +import { getNodeInfoById } from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' +import { VarBlockIcon } from '@/app/components/workflow/block-icon' +import { Line3 } from '@/app/components/base/icons/src/public/common' +import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' const i18nPrefix = 'workflow.nodes.variableAssigner' const Node: FC = () => { const { t } = useTranslation() - // const { variables } = mockData + const { variables, output_type } = mockData + // TODO: get var type through node and value + const getVarType = () => { + return 'string' + } + return (
-
{t(`${i18nPrefix}.title`)}
-
+
{t(`${i18nPrefix}.title`)}
+ { + variables.length === 0 && ( +
+ {t(`${i18nPrefix}.varNotSet`)} +
+ ) + } + {variables.length > 0 && ( + <> +
+ {variables.map((item, index) => { + const node = getNodeInfoById(item[0]) + const varName = item[item.length - 1] + return ( +
+
+
+ +
+
{node?.title}
+ +
+
+ +
{varName}
+
+
{getVarType()}
+
+ ) + }, + + )} +
+
+
+ {t(`${i18nPrefix}.outputType`)} +
+
+ {t(`${i18nPrefix}.type.${output_type}`)} +
+
+ + ) + } + ) } diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 915838ac39..5511f1bc27 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -89,6 +89,14 @@ const translation = { }, variableAssigner: { title: 'Assign variables', + outputType: 'Output Type', + varNotSet: 'Variable not set', + type: { + string: 'String', + number: 'Number', + object: 'Object', + arrayObject: 'Array[Object]', + }, }, }, } diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 5cf60f3330..9d48f72e08 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -88,6 +88,14 @@ const translation = { }, variableAssigner: { title: '变量赋值', + outputType: '输出类型', + varNotSet: '未设置变量', + type: { + string: 'String', + number: 'Number', + object: 'Object', + arrayObject: 'Array[Object]', + }, }, }, }