diff --git a/web/app/components/workflow/nodes/trigger-webhook/panel.tsx b/web/app/components/workflow/nodes/trigger-webhook/panel.tsx index bbdadc69a3..581a0514b1 100644 --- a/web/app/components/workflow/nodes/trigger-webhook/panel.tsx +++ b/web/app/components/workflow/nodes/trigger-webhook/panel.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react' -import React, { useEffect, useRef } from 'react' +import React, { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import type { HttpMethod, WebhookTriggerNodeType } from './types' @@ -7,8 +7,10 @@ import useConfig from './use-config' import ParameterTable from './components/parameter-table' import HeaderTable from './components/header-table' import ParagraphInput from './components/paragraph-input' +import { OutputVariablesContent } from './utils/render-output-vars' import Field from '@/app/components/workflow/nodes/_base/components/field' import Split from '@/app/components/workflow/nodes/_base/components/split' +import OutputVars from '@/app/components/workflow/nodes/_base/components/output-vars' import type { NodePanelProps } from '@/app/components/workflow/types' import InputWithCopy from '@/app/components/base/input-with-copy' import { InputNumber } from '@/app/components/base/input-number' @@ -42,6 +44,7 @@ const Panel: FC> = ({ }) => { const { t } = useTranslation() const [debugUrlCopied, setDebugUrlCopied] = React.useState(false) + const [outputVarsCollapsed, setOutputVarsCollapsed] = useState(false) const { readOnly, inputs, @@ -214,6 +217,17 @@ const Panel: FC> = ({ + + + +
+ + + +
) } diff --git a/web/app/components/workflow/nodes/trigger-webhook/utils/render-output-vars.tsx b/web/app/components/workflow/nodes/trigger-webhook/utils/render-output-vars.tsx new file mode 100644 index 0000000000..eaf6fbf483 --- /dev/null +++ b/web/app/components/workflow/nodes/trigger-webhook/utils/render-output-vars.tsx @@ -0,0 +1,62 @@ +import type { FC } from 'react' +import React from 'react' +import type { Variable } from '@/app/components/workflow/types' + +type OutputVariablesContentProps = { + variables?: Variable[] +} + +const getLabelPrefix = (label: string): string => { + const prefixMap: Record = { + param: 'query_params', + header: 'header_params', + body: 'req_body_params', + } + return prefixMap[label] || label +} + +type VarItemProps = { + prefix: string + name: string + type: string +} + +const VarItem: FC = ({ prefix, name, type }) => { + return ( +
+
+ {prefix}. + {name} + {type} +
+
+ ) +} + +export const OutputVariablesContent: FC = ({ variables = [] }) => { + if (!variables || variables.length === 0) { + return ( +
+ No output variables +
+ ) + } + + return ( +
+ {variables.map((variable, index) => { + const label = typeof variable.label === 'string' ? variable.label : '' + const varName = typeof variable.variable === 'string' ? variable.variable : '' + + return ( + + ) + })} +
+ ) +}