mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
email debug switch
This commit is contained in:
parent
f22dcee6d9
commit
527736b8e4
@ -1,9 +1,12 @@
|
|||||||
import { memo, useCallback, useState } from 'react'
|
import { memo, useCallback, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
import { RiCloseLine } from '@remixicon/react'
|
import { useAppContext } from '@/context/app-context'
|
||||||
|
import { RiBugLine, RiCloseLine } from '@remixicon/react'
|
||||||
import Modal from '@/app/components/base/modal'
|
import Modal from '@/app/components/base/modal'
|
||||||
import Input from '@/app/components/base/input'
|
import Input from '@/app/components/base/input'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
|
import Divider from '@/app/components/base/divider'
|
||||||
|
import Switch from '@/app/components/base/switch'
|
||||||
import Recipient from './recipient'
|
import Recipient from './recipient'
|
||||||
import MailBodyInput from './mail-body-input'
|
import MailBodyInput from './mail-body-input'
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
@ -34,10 +37,11 @@ const EmailConfigureModal = ({
|
|||||||
availableNodes = [],
|
availableNodes = [],
|
||||||
}: EmailConfigureModalProps) => {
|
}: EmailConfigureModalProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const { userProfile } = useAppContext()
|
||||||
const [recipients, setRecipients] = useState(config?.recipients || { whole_workspace: false, items: [] })
|
const [recipients, setRecipients] = useState(config?.recipients || { whole_workspace: false, items: [] })
|
||||||
const [subject, setSubject] = useState(config?.subject || '')
|
const [subject, setSubject] = useState(config?.subject || '')
|
||||||
const [body, setBody] = useState(config?.body || '')
|
const [body, setBody] = useState(config?.body || '')
|
||||||
|
const [debugMode, setDebugMode] = useState(config?.debug || false)
|
||||||
|
|
||||||
const checkValidConfig = () => {
|
const checkValidConfig = () => {
|
||||||
if (!subject.trim()) {
|
if (!subject.trim()) {
|
||||||
@ -77,6 +81,7 @@ const EmailConfigureModal = ({
|
|||||||
recipients,
|
recipients,
|
||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
|
debug: debugMode,
|
||||||
})
|
})
|
||||||
}, [subject, body, onConfirm])
|
}, [subject, body, onConfirm])
|
||||||
|
|
||||||
@ -94,15 +99,6 @@ const EmailConfigureModal = ({
|
|||||||
<div className='system-xs-regular text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.emailConfigure.description`)}</div>
|
<div className='system-xs-regular text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.emailConfigure.description`)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='space-y-5 px-6 py-3'>
|
<div className='space-y-5 px-6 py-3'>
|
||||||
<div>
|
|
||||||
<div className='system-sm-medium mb-1 flex h-6 items-center text-text-secondary'>
|
|
||||||
{t(`${i18nPrefix}.deliveryMethod.emailConfigure.recipient`)}
|
|
||||||
</div>
|
|
||||||
<Recipient
|
|
||||||
data={recipients}
|
|
||||||
onChange={setRecipients}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<div className='system-sm-medium mb-1 flex h-6 items-center text-text-secondary'>
|
<div className='system-sm-medium mb-1 flex h-6 items-center text-text-secondary'>
|
||||||
{t(`${i18nPrefix}.deliveryMethod.emailConfigure.subject`)}
|
{t(`${i18nPrefix}.deliveryMethod.emailConfigure.subject`)}
|
||||||
@ -125,6 +121,36 @@ const EmailConfigureModal = ({
|
|||||||
availableNodes={availableNodes}
|
availableNodes={availableNodes}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className='system-sm-medium mb-1 flex h-6 items-center text-text-secondary'>
|
||||||
|
{t(`${i18nPrefix}.deliveryMethod.emailConfigure.recipient`)}
|
||||||
|
</div>
|
||||||
|
<Recipient
|
||||||
|
data={recipients}
|
||||||
|
onChange={setRecipients}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Divider className='!my-0 !mt-5 !h-px' />
|
||||||
|
<div className='flex items-start justify-between gap-2 rounded-[10px] border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-3 pl-2.5 shadow-xs'>
|
||||||
|
<div className='rounded-[4px] border border-divider-regular bg-components-icon-bg-orange-dark-solid p-0.5'>
|
||||||
|
<RiBugLine className='h-3.5 w-3.5 text-text-primary-on-surface' />
|
||||||
|
</div>
|
||||||
|
<div className='space-y-1'>
|
||||||
|
<div className='system-sm-medium text-text-secondary'>{t(`${i18nPrefix}.deliveryMethod.emailConfigure.debugMode`)}</div>
|
||||||
|
<div className='body-xs-regular text-text-tertiary'>
|
||||||
|
<Trans
|
||||||
|
i18nKey={`${i18nPrefix}.deliveryMethod.emailConfigure.debugModeTip1`}
|
||||||
|
components={{ email: <span className='body-md-medium text-text-primary'>{userProfile.email}</span> }}
|
||||||
|
values={{ email: userProfile.email }}
|
||||||
|
/>
|
||||||
|
<div>{t(`${i18nPrefix}.deliveryMethod.emailConfigure.debugModeTip2`)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
defaultValue={debugMode}
|
||||||
|
onChange={checked => setDebugMode(checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row-reverse gap-2 p-6 pt-5'>
|
<div className='flex flex-row-reverse gap-2 p-6 pt-5'>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -5,8 +5,10 @@ import {
|
|||||||
RiEqualizer2Line,
|
RiEqualizer2Line,
|
||||||
RiMailSendFill,
|
RiMailSendFill,
|
||||||
RiRobot2Fill,
|
RiRobot2Fill,
|
||||||
|
RiSendPlane2Line,
|
||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
|
import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
|
||||||
|
import Badge from '@/app/components/base/badge/index'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import Switch from '@/app/components/base/switch'
|
import Switch from '@/app/components/base/switch'
|
||||||
import Indicator from '@/app/components/header/indicator'
|
import Indicator from '@/app/components/header/indicator'
|
||||||
@ -71,13 +73,19 @@ const DeliveryMethodItem: React.FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className='system-xs-medium capitalize text-text-secondary'>{method.type}</div>
|
<div className='system-xs-medium capitalize text-text-secondary'>{method.type}</div>
|
||||||
|
{method.type === DeliveryMethodType.Email && method.config?.debug && <Badge size='s'>DEBUG</Badge>}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex items-center gap-1'>
|
<div className='flex items-center gap-1'>
|
||||||
<div className='hidden items-end gap-1 group-hover:flex'>
|
<div className='hidden items-end gap-1 group-hover:flex'>
|
||||||
{method.type === DeliveryMethodType.Email && method.config && (
|
{method.type === DeliveryMethodType.Email && method.config && (
|
||||||
<ActionButton onClick={() => setShowEmailModal(true)}>
|
<>
|
||||||
<RiEqualizer2Line className='h-4 w-4' />
|
<ActionButton onClick={() => setShowEmailModal(true)}>
|
||||||
</ActionButton>
|
<RiSendPlane2Line className='h-4 w-4' />
|
||||||
|
</ActionButton>
|
||||||
|
<ActionButton onClick={() => setShowEmailModal(true)}>
|
||||||
|
<RiEqualizer2Line className='h-4 w-4' />
|
||||||
|
</ActionButton>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
onMouseEnter={() => setIsHovering(true)}
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ export type EmailConfig = {
|
|||||||
recipients: RecipientData
|
recipients: RecipientData
|
||||||
subject: string
|
subject: string
|
||||||
body: string
|
body: string
|
||||||
|
debug: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DeliveryMethod = {
|
export type DeliveryMethod = {
|
||||||
|
|||||||
@ -959,6 +959,9 @@ const translation = {
|
|||||||
add: '+ Add',
|
add: '+ Add',
|
||||||
added: 'Added',
|
added: 'Added',
|
||||||
},
|
},
|
||||||
|
debugMode: 'Debug Mode',
|
||||||
|
debugModeTip1: 'During debug mode, emails will only be sent to your account email <email>{{email}}</email>.',
|
||||||
|
debugModeTip2: 'The production environment is not affected.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
formContent: {
|
formContent: {
|
||||||
|
|||||||
@ -959,6 +959,9 @@ const translation = {
|
|||||||
add: '+ 添加',
|
add: '+ 添加',
|
||||||
added: '已添加',
|
added: '已添加',
|
||||||
},
|
},
|
||||||
|
debugMode: '调试模式',
|
||||||
|
debugModeTip1: '在调试模式下,电子邮件将仅发送到您的帐户电子邮件 <email>{{email}}</email>。',
|
||||||
|
debugModeTip2: '生产环境不受影响。',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
formContent: {
|
formContent: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user