From 32c6431dbcf05e8920cdd1b1b5c807fba7d359e7 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 27 Feb 2024 10:58:46 +0800 Subject: [PATCH] feat: assign node no var list tip --- web/app/(commonLayout)/workflow/nodes/page.tsx | 4 ++-- .../variable-assigner/components/var-list/index.tsx | 10 ++++++++++ web/i18n/en-US/workflow.ts | 1 + web/i18n/zh-Hans/workflow.ts | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/web/app/(commonLayout)/workflow/nodes/page.tsx b/web/app/(commonLayout)/workflow/nodes/page.tsx index 117e9b4cf7..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.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 */, + BlockEnum.End/* 12 */, ].map((item, i) => ({ id: `${i + 1}`, type: 'custom', diff --git a/web/app/components/workflow/nodes/variable-assigner/components/var-list/index.tsx b/web/app/components/workflow/nodes/variable-assigner/components/var-list/index.tsx index 450d4cd447..5688b52097 100644 --- a/web/app/components/workflow/nodes/variable-assigner/components/var-list/index.tsx +++ b/web/app/components/workflow/nodes/variable-assigner/components/var-list/index.tsx @@ -1,5 +1,6 @@ 'use client' import type { FC } from 'react' +import { useTranslation } from 'react-i18next' import React, { useCallback } from 'react' import produce from 'immer' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' @@ -17,6 +18,7 @@ const VarList: FC = ({ list, onChange, }) => { + const { t } = useTranslation() const handleVarReferenceChange = useCallback((index: number) => { return (value: ValueSelector) => { const newList = produce(list, (draft) => { @@ -35,6 +37,14 @@ const VarList: FC = ({ } }, [list, onChange]) + if (list.length === 0) { + return ( +
+ {t('workflow.nodes.variableAssigner.noVarTip')} +
+ ) + } + return (
{list.map((item, index) => ( diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 3cd3022877..d76a0d906c 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -92,6 +92,7 @@ const translation = { outputType: 'Output Type', outputVarType: 'Output Variable Type', varNotSet: 'Variable not set', + noVarTip: 'Add the variables to be assigned', type: { string: 'String', number: 'Number', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 55487189a7..eb8c5765ec 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -91,6 +91,7 @@ const translation = { outputType: '输出类型', outputVarType: '输出变量类型', varNotSet: '未设置变量', + noVarTip: '添加需要赋值的变量', type: { string: 'String', number: 'Number',