diff --git a/web/app/components/workflow/nodes/human-input/default.ts b/web/app/components/workflow/nodes/human-input/default.ts index a007a65a28..db2ff304ed 100644 --- a/web/app/components/workflow/nodes/human-input/default.ts +++ b/web/app/components/workflow/nodes/human-input/default.ts @@ -3,6 +3,8 @@ import type { HumanInputNodeType } from './types' import { DeliveryMethodType, UserActionButtonType } from './types' import { ALL_CHAT_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks' +const i18nPrefix = 'workflow.nodes.humanInput.errorMsg' + const nodeDefault: NodeDefault = { defaultValue: { delivery_methods: [ @@ -50,12 +52,24 @@ const nodeDefault: NodeDefault = { const nodes = ALL_CHAT_AVAILABLE_BLOCKS return nodes }, - checkValid() { - return { - isValid: true, - errorMessage: '', - } - }, + checkValid(payload: HumanInputNodeType, t: any) { + let errorMessages = '' + if (!errorMessages && !payload.delivery_methods.length) + errorMessages = t(`${i18nPrefix}.noDeliveryMethod`) + + if (!errorMessages && payload.delivery_methods.length > 0 && !payload.delivery_methods.some(method => method.enabled)) + errorMessages = t(`${i18nPrefix}.noDeliveryMethodEnabled`) + + // TODO : Add more validation for form content + + if (!errorMessages && !payload.user_actions.length) + errorMessages = t(`${i18nPrefix}.noUserActions`) + + return { + isValid: !errorMessages, + errorMessage: errorMessages, + } + }, } export default nodeDefault diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 2785f3238c..c3e0b38b71 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -977,6 +977,11 @@ const translation = { editor: { notes: 'notes', }, + errorMsg: { + noDeliveryMethod: 'Please select at least one delivery method', + noDeliveryMethodEnabled: 'Please enable at least one delivery method', + noUserActions: 'Please add at least one user action', + }, }, }, tracing: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index d6d766543e..2e6ef82e69 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -978,6 +978,11 @@ const translation = { editor: { notes: ' 笔记', }, + errorMsg: { + noDeliveryMethod: '请至少选择一种提交方式', + noDeliveryMethodEnabled: '请至少启用一种提交方式', + noUserActions: '请添加至少一个用户操作', + }, }, }, tracing: {