mirror of
https://github.com/langgenius/dify.git
synced 2026-01-29 15:13:53 +08:00
- Refactored `PluginFetchDynamicSelectOptionsApi` to replace the `extra` argument with `credential_id`, improving clarity in dynamic option fetching. - Updated `ProviderConfigEncrypter` to rename `mask_tool_credentials` to `mask_credentials` for consistency, and added a new method to maintain backward compatibility. - Enhanced `PluginParameterService` to utilize `credential_id` for fetching subscriptions, improving the handling of trigger credentials. - Adjusted various components and types in the frontend to replace `tool_name` with `trigger_name`, ensuring consistency across the application. - Introduced `multiple` property in `TriggerParameter` to support multi-select functionality. These changes improve the integration of triggers and plugins, enhance code clarity, and align naming conventions across the codebase.
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
import type { FC } from 'react'
|
|
import React from 'react'
|
|
import type { PluginTriggerNodeType } from './types'
|
|
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
|
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
|
import type { NodePanelProps } from '@/app/components/workflow/types'
|
|
import useConfig from './use-config'
|
|
import TriggerForm from './trigger-form'
|
|
import StructureOutputItem from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show'
|
|
import { Type } from '../llm/types'
|
|
|
|
const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
|
|
id,
|
|
data,
|
|
}) => {
|
|
const {
|
|
readOnly,
|
|
triggerParameterSchema,
|
|
triggerParameterValue,
|
|
setTriggerParameterValue,
|
|
outputSchema,
|
|
hasObjectOutput,
|
|
isAuthenticated,
|
|
currentProvider,
|
|
currentTrigger,
|
|
} = useConfig(id, data)
|
|
|
|
// Convert output schema to VarItem format
|
|
const outputVars = Object.entries(outputSchema.properties || {}).map(([name, schema]: [string, any]) => ({
|
|
name,
|
|
type: schema.type || 'string',
|
|
description: schema.description || '',
|
|
}))
|
|
|
|
return (
|
|
<div className='mt-2'>
|
|
{/* Dynamic Parameters Form - Only show when authenticated */}
|
|
{isAuthenticated && triggerParameterSchema.length > 0 && (
|
|
<>
|
|
<div className='px-4 pb-4'>
|
|
<TriggerForm
|
|
readOnly={readOnly}
|
|
nodeId={id}
|
|
schema={triggerParameterSchema as any}
|
|
value={triggerParameterValue}
|
|
onChange={setTriggerParameterValue}
|
|
currentProvider={currentProvider}
|
|
currentTrigger={currentTrigger}
|
|
/>
|
|
</div>
|
|
<Split />
|
|
</>
|
|
)}
|
|
|
|
{/* Output Variables - Always show */}
|
|
<OutputVars>
|
|
<>
|
|
{outputVars.map(varItem => (
|
|
<VarItem
|
|
key={varItem.name}
|
|
name={varItem.name}
|
|
type={varItem.type}
|
|
description={varItem.description}
|
|
isIndent={hasObjectOutput}
|
|
/>
|
|
))}
|
|
{Object.entries(outputSchema.properties || {}).map(([name, schema]: [string, any]) => (
|
|
<div key={name}>
|
|
{schema.type === 'object' ? (
|
|
<StructureOutputItem
|
|
rootClassName='code-sm-semibold text-text-secondary'
|
|
payload={{
|
|
schema: {
|
|
type: Type.object,
|
|
properties: {
|
|
[name]: schema,
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
}}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
))}
|
|
</>
|
|
</OutputVars>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default React.memo(Panel)
|