feat: add providerType prop to form components for dynamic behavior

- Introduced `providerType` prop in `FormInputItem`, `ToolForm`, and `ToolFormItem` components to support both 'tool' and 'trigger' types, enhancing flexibility in handling different provider scenarios.
- Updated the `useFetchDynamicOptions` function to accept `provider_type` as 'tool' | 'trigger', allowing for more dynamic option fetching based on the provider type.

These changes improve the adaptability of the form components and streamline the integration of different provider types in the workflow.
This commit is contained in:
Harry 2025-09-08 18:29:48 +08:00
parent ac38614171
commit 01b2f9cff6
5 changed files with 11 additions and 2 deletions

View File

@ -34,6 +34,7 @@ type Props = {
currentTool?: Tool
currentProvider?: ToolWithProvider
extraParams?: Record<string, any>
providerType?: 'tool' | 'trigger'
}
const FormInputItem: FC<Props> = ({
@ -46,6 +47,7 @@ const FormInputItem: FC<Props> = ({
currentTool,
currentProvider,
extraParams,
providerType = 'tool',
}) => {
const language = useLanguage()
const [dynamicOptions, setDynamicOptions] = useState<FormOption[] | null>(null)
@ -138,7 +140,7 @@ const FormInputItem: FC<Props> = ({
currentProvider?.name || '',
currentTool?.name || '',
variable || '',
'tool',
providerType,
extraParams,
)

View File

@ -17,6 +17,7 @@ type Props = {
currentTool?: Tool
currentProvider?: ToolWithProvider
extraParams?: Record<string, any>
providerType?: 'tool' | 'trigger'
}
const ToolForm: FC<Props> = ({
@ -29,6 +30,7 @@ const ToolForm: FC<Props> = ({
currentTool,
currentProvider,
extraParams,
providerType = 'tool',
}) => {
return (
<div className='space-y-1'>
@ -45,6 +47,7 @@ const ToolForm: FC<Props> = ({
currentTool={currentTool}
currentProvider={currentProvider}
extraParams={extraParams}
providerType={providerType}
/>
))
}

View File

@ -25,6 +25,7 @@ type Props = {
currentTool?: Tool
currentProvider?: ToolWithProvider
extraParams?: Record<string, any>
providerType?: 'tool' | 'trigger'
}
const ToolFormItem: FC<Props> = ({
@ -37,6 +38,7 @@ const ToolFormItem: FC<Props> = ({
currentTool,
currentProvider,
extraParams,
providerType = 'tool',
}) => {
const language = useLanguage()
const { name, label, type, required, tooltip, input_schema } = schema
@ -92,6 +94,7 @@ const ToolFormItem: FC<Props> = ({
currentTool={currentTool}
currentProvider={currentProvider}
extraParams={extraParams}
providerType={providerType}
/>
{isShowSchema && (

View File

@ -42,6 +42,7 @@ const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
schema={triggerParameterSchema as any}
value={triggerParameterValue}
onChange={setTriggerParameterValue}
providerType="trigger"
/>
</div>
<Split />

View File

@ -613,7 +613,7 @@ export const usePluginInfo = (providerName?: string) => {
})
}
export const useFetchDynamicOptions = (plugin_id: string, provider: string, action: string, parameter: string, provider_type: 'tool', extra?: Record<string, any>) => {
export const useFetchDynamicOptions = (plugin_id: string, provider: string, action: string, parameter: string, provider_type: 'tool' | 'trigger', extra?: Record<string, any>) => {
return useMutation({
mutationFn: () => get<{ options: FormOption[] }>('/workspaces/current/plugin/parameters/dynamic-options', {
params: {