diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/email-configure-modal.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/email-configure-modal.tsx index 27813ac20f..1f30380ffa 100644 --- a/web/app/components/workflow/nodes/human-input/components/delivery-method/email-configure-modal.tsx +++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/email-configure-modal.tsx @@ -41,7 +41,7 @@ const EmailConfigureModal = ({ const [recipients, setRecipients] = useState(config?.recipients || { whole_workspace: false, items: [] }) const [subject, setSubject] = useState(config?.subject || '') const [body, setBody] = useState(config?.body || '') - const [debugMode, setDebugMode] = useState(config?.debug || false) + const [debugMode, setDebugMode] = useState(config?.debug_mode || false) const checkValidConfig = () => { if (!subject.trim()) { @@ -81,7 +81,7 @@ const EmailConfigureModal = ({ recipients, subject, body, - debug: debugMode, + debug_mode: debugMode, }) }, [recipients, subject, body, debugMode, onConfirm]) diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-item.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-item.tsx index 5ea46ca481..d1c1df131c 100644 --- a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-item.tsx +++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-item.tsx @@ -13,7 +13,7 @@ import Button from '@/app/components/base/button' import Switch from '@/app/components/base/switch' import Indicator from '@/app/components/header/indicator' import EmailConfigureModal from './email-configure-modal' -import type { DeliveryMethod } from '../../types' +import type { DeliveryMethod, EmailConfig } from '../../types' import { DeliveryMethodType } from '../../types' import type { Node, @@ -75,7 +75,7 @@ const DeliveryMethodItem: React.FC = ({ )}
{method.type}
- {method.type === DeliveryMethodType.Email && method.config?.debug && DEBUG} + {method.type === DeliveryMethodType.Email && (method.config as EmailConfig)?.debug_mode && DEBUG}
@@ -122,7 +122,7 @@ const DeliveryMethodItem: React.FC = ({ {showEmailModal && ( setShowEmailModal(false)} @@ -135,7 +135,7 @@ const DeliveryMethodItem: React.FC = ({ {showTestEmailModal && ( setShowTestEmailModal(false)} diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx index 1977059c23..502398a756 100644 --- a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx +++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx @@ -20,6 +20,7 @@ import Badge from '@/app/components/base/badge' import type { DeliveryMethod } from '../../types' import { DeliveryMethodType } from '../../types' import { IS_CE_EDITION } from '@/config' +import { v4 as uuid4 } from 'uuid' import cn from '@/utils/classnames' const i18nPrefix = 'workflow.nodes.humanInput' @@ -71,8 +72,10 @@ const MethodSelector: FC = ({ if (data.some(method => method.type === DeliveryMethodType.WebApp)) return onAdd({ + id: uuid4(), type: DeliveryMethodType.WebApp, enabled: true, + config: {}, }) }} > @@ -93,6 +96,7 @@ const MethodSelector: FC = ({ if (data.some(method => method.type === DeliveryMethodType.Email)) return onAdd({ + id: uuid4(), type: DeliveryMethodType.Email, enabled: false, }) diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/test-email-sender.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/test-email-sender.tsx index e7e22ee35b..dcaff5ea9e 100644 --- a/web/app/components/workflow/nodes/human-input/components/delivery-method/test-email-sender.tsx +++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/test-email-sender.tsx @@ -39,24 +39,24 @@ type EmailConfigureModalProps = { const getOriginVar = (valueSelector: string[], list: NodeOutPutVar[]) => { const targetVar = list.find(item => item.nodeId === valueSelector[0]) - if (!targetVar) - return undefined - - let curr: any = targetVar.vars - for (let i = 1; i < valueSelector.length; i++) { - const key = valueSelector[i] - const isLast = i === valueSelector.length - 1 - - if (Array.isArray(curr)) - curr = curr.find((v: any) => v.variable.replace('conversation.', '') === key) - - if (isLast) - return curr - else if (curr?.type === VarType.object || curr?.type === VarType.file) - curr = curr.children - } - + if (!targetVar) return undefined + + let curr: any = targetVar.vars + for (let i = 1; i < valueSelector.length; i++) { + const key = valueSelector[i] + const isLast = i === valueSelector.length - 1 + + if (Array.isArray(curr)) + curr = curr.find((v: any) => v.variable.replace('conversation.', '') === key) + + if (isLast) + return curr + else if (curr?.type === VarType.object || curr?.type === VarType.file) + curr = curr.children + } + + return undefined } const EmailSenderModal = ({ @@ -70,7 +70,7 @@ const EmailSenderModal = ({ const { t } = useTranslation() const { userProfile, currentWorkspace } = useAppContext() - const debugEnabled = !!config?.debug + const debugEnabled = !!config?.debug_mode const onlyWholeTeam = config?.recipients?.whole_workspace && (!config?.recipients?.items || config?.recipients?.items.length === 0) const onlySpecificUsers = !config?.recipients?.whole_workspace && config?.recipients?.items && config?.recipients?.items.length > 0 const combinedRecipients = config?.recipients?.whole_workspace && config?.recipients?.items && config?.recipients?.items.length > 0 diff --git a/web/app/components/workflow/nodes/human-input/types.ts b/web/app/components/workflow/nodes/human-input/types.ts index 4a2b30e10c..9eb8822155 100644 --- a/web/app/components/workflow/nodes/human-input/types.ts +++ b/web/app/components/workflow/nodes/human-input/types.ts @@ -33,13 +33,14 @@ export type EmailConfig = { recipients: RecipientData subject: string body: string - debug: boolean + debug_mode: boolean } export type DeliveryMethod = { + id: string type: DeliveryMethodType enabled: boolean - config?: EmailConfig + config?: EmailConfig | {} } export type FormInputItemPlaceholder = {