mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:06:56 +08:00
refactor(trigger): improve config value formatting in PluginTriggerNode
This commit is contained in:
parent
380ef52331
commit
323e183775
@ -4,6 +4,35 @@ import type { PluginTriggerNodeType } from './types'
|
|||||||
import type { NodeProps } from '@/app/components/workflow/types'
|
import type { NodeProps } from '@/app/components/workflow/types'
|
||||||
import useConfig from './use-config'
|
import useConfig from './use-config'
|
||||||
|
|
||||||
|
const formatConfigValue = (rawValue: any): string => {
|
||||||
|
if (rawValue === null || rawValue === undefined)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
if (typeof rawValue === 'string' || typeof rawValue === 'number' || typeof rawValue === 'boolean')
|
||||||
|
return String(rawValue)
|
||||||
|
|
||||||
|
if (Array.isArray(rawValue))
|
||||||
|
return rawValue.join('.')
|
||||||
|
|
||||||
|
if (typeof rawValue === 'object') {
|
||||||
|
const { value } = rawValue as { value?: any }
|
||||||
|
if (value === null || value === undefined)
|
||||||
|
return ''
|
||||||
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
|
||||||
|
return String(value)
|
||||||
|
if (Array.isArray(value))
|
||||||
|
return value.join('.')
|
||||||
|
try {
|
||||||
|
return JSON.stringify(value)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
const Node: FC<NodeProps<PluginTriggerNodeType>> = ({
|
const Node: FC<NodeProps<PluginTriggerNodeType>> = ({
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
@ -31,12 +60,15 @@ const Node: FC<NodeProps<PluginTriggerNodeType>> = ({
|
|||||||
{key}
|
{key}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
title={String(config[key] || '')}
|
title={formatConfigValue(config[key])}
|
||||||
className="w-0 shrink-0 grow truncate text-right text-xs font-normal text-text-secondary"
|
className="w-0 shrink-0 grow truncate text-right text-xs font-normal text-text-secondary"
|
||||||
>
|
>
|
||||||
{typeof config[key] === 'string' && config[key].includes('secret')
|
{(() => {
|
||||||
? '********'
|
const displayValue = formatConfigValue(config[key])
|
||||||
: String(config[key] || '')}
|
if (displayValue.includes('secret'))
|
||||||
|
return '********'
|
||||||
|
return displayValue
|
||||||
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user