delivery methods config update

This commit is contained in:
JzoNg 2025-10-27 11:55:57 +08:00
parent 4e3bded902
commit f71a632cdc
5 changed files with 31 additions and 26 deletions

View File

@ -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])

View File

@ -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<Props> = ({
</div>
)}
<div className='system-xs-medium capitalize text-text-secondary'>{method.type}</div>
{method.type === DeliveryMethodType.Email && method.config?.debug && <Badge size='s' className='!px-1 !py-0.5'>DEBUG</Badge>}
{method.type === DeliveryMethodType.Email && (method.config as EmailConfig)?.debug_mode && <Badge size='s' className='!px-1 !py-0.5'>DEBUG</Badge>}
</div>
<div className='flex items-center gap-1'>
<div className='hidden items-end gap-1 group-hover:flex'>
@ -122,7 +122,7 @@ const DeliveryMethodItem: React.FC<Props> = ({
{showEmailModal && (
<EmailConfigureModal
isShow={showEmailModal}
config={method.config}
config={method.config as EmailConfig}
nodesOutputVars={nodesOutputVars}
availableNodes={availableNodes}
onClose={() => setShowEmailModal(false)}
@ -135,7 +135,7 @@ const DeliveryMethodItem: React.FC<Props> = ({
{showTestEmailModal && (
<TestEmailSender
isShow={showTestEmailModal}
config={method.config}
config={method.config as EmailConfig}
nodesOutputVars={nodesOutputVars}
availableNodes={availableNodes}
onClose={() => setShowTestEmailModal(false)}

View File

@ -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<Props> = ({
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<Props> = ({
if (data.some(method => method.type === DeliveryMethodType.Email))
return
onAdd({
id: uuid4(),
type: DeliveryMethodType.Email,
enabled: false,
})

View File

@ -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

View File

@ -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 = {