Commit 32c6431d authored by Joel's avatar Joel

feat: assign node no var list tip

parent 925964ac
...@@ -5,9 +5,9 @@ import { memo } from 'react' ...@@ -5,9 +5,9 @@ import { memo } from 'react'
import Workflow from '@/app/components/workflow' import Workflow from '@/app/components/workflow'
import { BlockEnum } from '@/app/components/workflow/types' import { BlockEnum } from '@/app/components/workflow/types'
const nodes = [ 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.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) => ({ ].map((item, i) => ({
id: `${i + 1}`, id: `${i + 1}`,
type: 'custom', type: 'custom',
......
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
import React, { useCallback } from 'react' import React, { useCallback } from 'react'
import produce from 'immer' import produce from 'immer'
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
...@@ -17,6 +18,7 @@ const VarList: FC<Props> = ({ ...@@ -17,6 +18,7 @@ const VarList: FC<Props> = ({
list, list,
onChange, onChange,
}) => { }) => {
const { t } = useTranslation()
const handleVarReferenceChange = useCallback((index: number) => { const handleVarReferenceChange = useCallback((index: number) => {
return (value: ValueSelector) => { return (value: ValueSelector) => {
const newList = produce(list, (draft) => { const newList = produce(list, (draft) => {
...@@ -35,6 +37,14 @@ const VarList: FC<Props> = ({ ...@@ -35,6 +37,14 @@ const VarList: FC<Props> = ({
} }
}, [list, onChange]) }, [list, onChange])
if (list.length === 0) {
return (
<div className='flex rounded-md bg-gray-50 items-center h-[42px] justify-center leading-[18px] text-xs font-normal text-gray-500'>
{t('workflow.nodes.variableAssigner.noVarTip')}
</div>
)
}
return ( return (
<div className='space-y-2'> <div className='space-y-2'>
{list.map((item, index) => ( {list.map((item, index) => (
......
...@@ -92,6 +92,7 @@ const translation = { ...@@ -92,6 +92,7 @@ const translation = {
outputType: 'Output Type', outputType: 'Output Type',
outputVarType: 'Output Variable Type', outputVarType: 'Output Variable Type',
varNotSet: 'Variable not set', varNotSet: 'Variable not set',
noVarTip: 'Add the variables to be assigned',
type: { type: {
string: 'String', string: 'String',
number: 'Number', number: 'Number',
......
...@@ -91,6 +91,7 @@ const translation = { ...@@ -91,6 +91,7 @@ const translation = {
outputType: '输出类型', outputType: '输出类型',
outputVarType: '输出变量类型', outputVarType: '输出变量类型',
varNotSet: '未设置变量', varNotSet: '未设置变量',
noVarTip: '添加需要赋值的变量',
type: { type: {
string: 'String', string: 'String',
number: 'Number', number: 'Number',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment