feat(workflow): Plugin Trigger Node with Unified Entry Node System (#24205)

This commit is contained in:
lyzno1
2025-08-20 23:49:10 +08:00
committed by GitHub
parent 6eaea64b3f
commit 833c902b2b
19 changed files with 518 additions and 57 deletions

View File

@ -1,24 +1,53 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import type { PluginTriggerNodeType } from './types'
import type { NodeProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.triggerPlugin'
const Node: FC<NodeProps<PluginTriggerNodeType>> = ({
data,
}) => {
const { t } = useTranslation()
const { config = {} } = data
const configKeys = Object.keys(config)
if (!data.plugin_name && configKeys.length === 0)
return null
return (
<div className="mb-1 px-3 py-1">
<div className="text-xs text-gray-700">
{t(`${i18nPrefix}.nodeTitle`)}
</div>
{data.plugin_name && (
<div className="text-xs text-gray-500">
<div className="mb-1 text-xs font-medium text-gray-700">
{data.plugin_name}
{data.event_type && (
<div className="text-xs text-gray-500">
{data.event_type}
</div>
)}
</div>
)}
{configKeys.length > 0 && (
<div className="space-y-0.5">
{configKeys.map((key, index) => (
<div
key={index}
className="flex h-6 items-center justify-between space-x-1 rounded-md bg-workflow-block-parma-bg px-1 text-xs font-normal text-text-secondary"
>
<div
title={key}
className="max-w-[100px] shrink-0 truncate text-xs font-medium uppercase text-text-tertiary"
>
{key}
</div>
<div
title={String(config[key] || '')}
className="w-0 shrink-0 grow truncate text-right text-xs font-normal text-text-secondary"
>
{typeof config[key] === 'string' && config[key].includes('secret')
? '********'
: String(config[key] || '')}
</div>
</div>
))}
</div>
)}
</div>

View File

@ -1,25 +1,35 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import type { PluginTriggerNodeType } from './types'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.triggerPlugin'
const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
id,
data,
}) => {
const { t } = useTranslation()
return (
<div className='mt-2'>
<div className='space-y-4 px-4 pb-2'>
<Field title={t(`${i18nPrefix}.title`)}>
<div className="text-sm text-gray-500">
{t(`${i18nPrefix}.configPlaceholder`)}
</div>
<Field title="Plugin Trigger">
{data.plugin_name ? (
<div className="space-y-2">
<div className="flex items-center space-x-2">
<span className="text-sm font-medium">{data.plugin_name}</span>
{data.event_type && (
<span className="rounded bg-blue-100 px-2 py-1 text-xs text-blue-800">
{data.event_type}
</span>
)}
</div>
<div className="text-xs text-gray-500">
Plugin trigger configured
</div>
</div>
) : (
<div className="text-sm text-gray-500">
No plugin selected. Configure this trigger in the workflow canvas.
</div>
)}
</Field>
</div>
</div>

View File

@ -1,8 +1,12 @@
import type { CommonNodeType } from '@/app/components/workflow/types'
import type { CollectionType } from '@/app/components/tools/types'
export type PluginTriggerNodeType = CommonNodeType & {
plugin_id?: string
plugin_name?: string
event_type?: string
config?: Record<string, any>
provider_id?: string
provider_type?: CollectionType
provider_name?: string
}