From ed69c3cc18d47f906f8cf5c2a6784ee20ae390bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 27 May 2022 17:07:14 +0200 Subject: [PATCH] fix(editor): Fix credential display bug (#3372) * :zap: Filter credentials by version * :zap: Reuse helper --- .../src/components/mixins/workflowHelpers.ts | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index 001ed6efff302..80da1a2e29794 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -330,24 +330,25 @@ export const workflowHelpers = mixins( if (node.credentials !== undefined && nodeType.credentials !== undefined) { const saveCredenetials: INodeCredentials = {}; for (const nodeCredentialTypeName of Object.keys(node.credentials)) { - // todo revert to only set actually used credentials on workflow - // if (this.hasProxyAuth(node) || Object.keys(node.parameters).includes('genericAuthType')) { - // saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName]; - // continue; - // } - - // const credentialTypeDescription = nodeType.credentials - // .find((credentialTypeDescription) => credentialTypeDescription.name === nodeCredentialTypeName); - - // if (credentialTypeDescription === undefined) { - // // Credential type is not know so do not save - // continue; - // } - - // if (this.displayParameter(node.parameters, credentialTypeDescription, '', node) === false) { - // // Credential should not be displayed so do also not save - // continue; - // } + if (this.hasProxyAuth(node) || Object.keys(node.parameters).includes('genericAuthType')) { + saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName]; + continue; + } + + const credentialTypeDescription = nodeType.credentials + // filter out credentials with same name in different node versions + .filter((c) => this.displayParameter(node.parameters, c, '', node)) + .find((c) => c.name === nodeCredentialTypeName); + + if (credentialTypeDescription === undefined) { + // Credential type is not know so do not save + continue; + } + + if (this.displayParameter(node.parameters, credentialTypeDescription, '', node) === false) { + // Credential should not be displayed so do also not save + continue; + } saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName]; }