mirror of https://github.com/langgenius/dify.git
feat(humanInput): add email configuration validation and tooltip for delivery method
This commit is contained in:
parent
4e34fa3d70
commit
2ac20ced26
|
|
@ -70,15 +70,30 @@ const DeliveryMethodItem: FC<DeliveryMethodItemProps> = ({
|
|||
})
|
||||
}
|
||||
|
||||
const isEmailConfigComplete = useMemo(() => {
|
||||
if (method.type !== DeliveryMethodType.Email || !method.config)
|
||||
return false
|
||||
|
||||
const config = method.config as EmailConfig
|
||||
const hasSubject = !!config.subject
|
||||
const hasBody = !!config.body
|
||||
const hasRecipients = config.recipients?.whole_workspace || (config.recipients?.items?.length > 0)
|
||||
|
||||
return hasSubject && hasBody && hasRecipients
|
||||
}, [method.type, method.config])
|
||||
|
||||
const emailSenderTooltipContent = useMemo(() => {
|
||||
if (method.type !== DeliveryMethodType.Email) {
|
||||
return ''
|
||||
}
|
||||
if (!isEmailConfigComplete) {
|
||||
return t(`${i18nPrefix}.deliveryMethod.emailSender.configIncomplete`, { ns: 'workflow' })
|
||||
}
|
||||
if (method.config?.debug_mode) {
|
||||
return t(`${i18nPrefix}.deliveryMethod.emailSender.testSendTipInDebugMode`, { ns: 'workflow', email })
|
||||
}
|
||||
return t(`${i18nPrefix}.deliveryMethod.emailSender.testSendTip`, { ns: 'workflow' })
|
||||
}, [method.type, method.config?.debug_mode, t, email])
|
||||
}, [method.type, method.config?.debug_mode, isEmailConfigComplete, t, email])
|
||||
|
||||
const jumpToEmailConfigModal = useCallback(() => {
|
||||
setShowTestEmailModal(false)
|
||||
|
|
@ -119,7 +134,13 @@ const DeliveryMethodItem: FC<DeliveryMethodItemProps> = ({
|
|||
asChild={false}
|
||||
needsDelay={false}
|
||||
>
|
||||
<ActionButton onClick={() => setShowTestEmailModal(true)}>
|
||||
<ActionButton
|
||||
disabled={!isEmailConfigComplete}
|
||||
onClick={() => {
|
||||
if (isEmailConfigComplete)
|
||||
setShowTestEmailModal(true)
|
||||
}}
|
||||
>
|
||||
<RiSendPlane2Line className="h-4 w-4" />
|
||||
</ActionButton>
|
||||
</Tooltip>
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@
|
|||
"nodes.humanInput.deliveryMethod.emailConfigure.subject": "Subject",
|
||||
"nodes.humanInput.deliveryMethod.emailConfigure.subjectPlaceholder": "Enter email subject",
|
||||
"nodes.humanInput.deliveryMethod.emailConfigure.title": "Email Configuration",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.configIncomplete": "Please complete email configuration first (subject, body, and recipients)",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugDone": "A test email has been sent to <email>{{email}}</email>. Please check your inbox.",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugModeTip": "Debug mode is enabled.",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugModeTip2": "Email will be sent to <email>{{email}}</email>.",
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@
|
|||
"nodes.humanInput.deliveryMethod.emailConfigure.subject": "邮件主题",
|
||||
"nodes.humanInput.deliveryMethod.emailConfigure.subjectPlaceholder": "输入邮件主题",
|
||||
"nodes.humanInput.deliveryMethod.emailConfigure.title": "电子邮件配置",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.configIncomplete": "请先完成邮件配置(主题、正文和收件人)",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugDone": "测试邮件已发送到 <email>{{email}}</email>。请检查您的收件箱。",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugModeTip": "调试模式已启用。",
|
||||
"nodes.humanInput.deliveryMethod.emailSender.debugModeTip2": "邮件将发送到 <email>{{email}}</email>。",
|
||||
|
|
|
|||
Loading…
Reference in New Issue