From 6fc8e29fca572f0769bff78ed146c52ef90da598 Mon Sep 17 00:00:00 2001 From: Ivan Atanasov Date: Fri, 6 Dec 2024 21:36:09 +0100 Subject: [PATCH] add map option to preserve field order --- .../src/components/ResourceMapper.test.ts | 21 +++++++++++++++++++ .../ResourceMapper/ResourceMapper.vue | 2 +- .../ExecuteWorkflow/ExecuteWorkflow.node.ts | 2 +- packages/workflow/src/Interfaces.ts | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/editor-ui/src/components/ResourceMapper.test.ts b/packages/editor-ui/src/components/ResourceMapper.test.ts index 25db059504..253c7dfdc7 100644 --- a/packages/editor-ui/src/components/ResourceMapper.test.ts +++ b/packages/editor-ui/src/components/ResourceMapper.test.ts @@ -74,6 +74,27 @@ describe('ResourceMapper.vue', () => { expect(queryByTestId('matching-column-select')).not.toBeInTheDocument(); }); + it('renders map mode properly', async () => { + const { getByTestId, queryByTestId } = renderComponent( + { + props: { + parameter: { + typeOptions: { + resourceMapper: { + mode: 'map', + }, + }, + }, + }, + }, + { merge: true }, + ); + await waitAllPromises(); + expect(getByTestId('resource-mapper-container')).toBeInTheDocument(); + // This mode doesn't render matching column selector + expect(queryByTestId('matching-column-select')).not.toBeInTheDocument(); + }); + it('renders multi-key match selector properly', async () => { const { container, getByTestId } = renderComponent( { diff --git a/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue b/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue index acff282cca..c313be66b6 100644 --- a/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue +++ b/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue @@ -164,7 +164,7 @@ const showMappingModeSelect = computed(() => { const showMatchingColumnsSelector = computed(() => { return ( !state.loading && - props.parameter.typeOptions?.resourceMapper?.mode !== 'add' && + ['upsert', 'update'].includes(props.parameter.typeOptions?.resourceMapper?.mode) && state.paramValue.schema.length > 0 ); }); diff --git a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow/ExecuteWorkflow.node.ts b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow/ExecuteWorkflow.node.ts index 60037305b0..a89a55a674 100644 --- a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow/ExecuteWorkflow.node.ts +++ b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow/ExecuteWorkflow.node.ts @@ -222,7 +222,7 @@ export class ExecuteWorkflow implements INodeType { resourceMapper: { localResourceMapperMethod: 'loadWorkflowInputMappings', valuesLabel: 'Workflow Inputs', - mode: 'add', + mode: 'map', fieldWords: { singular: 'workflow input', plural: 'workflow inputs', diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index afe6248698..9e6e99274a 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -1366,7 +1366,7 @@ export interface INodePropertyTypeOptions { } export interface ResourceMapperTypeOptionsBase { - mode: 'add' | 'update' | 'upsert'; + mode: 'add' | 'update' | 'upsert' | 'map'; valuesLabel?: string; fieldWords?: { singular: string;