From 831c888b84125b173edf911e24963decbc34e012 Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Tue, 30 Sep 2025 12:34:09 +0800 Subject: [PATCH] feat: sort output variables by table display order in webhook trigger --- .../trigger-webhook/utils/render-output-vars.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 index eaf6fbf483..d5d5da71f9 100644 --- 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 @@ -6,6 +6,9 @@ type OutputVariablesContentProps = { variables?: Variable[] } +// Define the display order for variable labels to match the table order in the UI +const LABEL_ORDER = { param: 1, header: 2, body: 3 } as const + const getLabelPrefix = (label: string): string => { const prefixMap: Record = { param: 'query_params', @@ -42,9 +45,18 @@ export const OutputVariablesContent: FC = ({ variab ) } + // Sort variables by label to match the table display order: param → header → body + // Unknown labels are placed at the end (order value 999) + const sortedVariables = [...variables].sort((a, b) => { + const labelA = typeof a.label === 'string' ? a.label : '' + const labelB = typeof b.label === 'string' ? b.label : '' + return (LABEL_ORDER[labelA as keyof typeof LABEL_ORDER] || 999) + - (LABEL_ORDER[labelB as keyof typeof LABEL_ORDER] || 999) + }) + return (
- {variables.map((variable, index) => { + {sortedVariables.map((variable, index) => { const label = typeof variable.label === 'string' ? variable.label : '' const varName = typeof variable.variable === 'string' ? variable.variable : ''