From fec2fc1b085bc9a01af114eea202abb05d114a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 5 May 2022 14:56:06 +0200 Subject: [PATCH] :zap: Consolidate HTTPRN check --- .../editor-ui/src/components/NodeCredentials.vue | 11 ++++------- .../editor-ui/src/components/ParameterInputList.vue | 4 +--- .../editor-ui/src/components/mixins/nodeHelpers.ts | 13 ++++++------- .../src/components/mixins/workflowHelpers.ts | 4 +--- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/packages/editor-ui/src/components/NodeCredentials.vue b/packages/editor-ui/src/components/NodeCredentials.vue index 3f9d33452d..07d8a04350 100644 --- a/packages/editor-ui/src/components/NodeCredentials.vue +++ b/packages/editor-ui/src/components/NodeCredentials.vue @@ -77,7 +77,6 @@ import { showMessage } from '@/components/mixins/showMessage'; import { mapGetters } from "vuex"; import mixins from 'vue-typed-mixins'; -import { HTTP_REQUEST_NODE_TYPE } from '@/constants'; export default mixins( genericHelpers, @@ -101,14 +100,12 @@ export default mixins( getCredentialTypeByName: 'getCredentialTypeByName', }), isProxyAuth(): boolean { - return this.node.type === HTTP_REQUEST_NODE_TYPE - && this.node.typeVersion === 2 - && this.node.parameters.authenticateWith === 'nodeCredential'; + return this.isHttpRequestNodeV2(this.node) && + this.node.parameters.authenticateWith === 'nodeCredential'; }, isGenericAuth(): boolean { - return this.node.type === HTTP_REQUEST_NODE_TYPE - && this.node.typeVersion === 2 - && this.node.parameters.authenticateWith === 'genericAuth'; + return this.isHttpRequestNodeV2(this.node) && + this.node.parameters.authenticateWith === 'genericAuth'; }, credentialTypesNode (): string[] { return this.credentialTypesNodeDescription diff --git a/packages/editor-ui/src/components/ParameterInputList.vue b/packages/editor-ui/src/components/ParameterInputList.vue index 89d2d3b838..760a1dccd2 100644 --- a/packages/editor-ui/src/components/ParameterInputList.vue +++ b/packages/editor-ui/src/components/ParameterInputList.vue @@ -134,9 +134,7 @@ export default mixins( return this.$store.getters.activeNode; }, indexToShowSlotAt (): number { - if (this.node.type === HTTP_REQUEST_NODE_TYPE && this.node.typeVersion === 2) { - return 2; - } + if (this.isHttpRequestNodeV2(this.node)) return 2; return 0; }, diff --git a/packages/editor-ui/src/components/mixins/nodeHelpers.ts b/packages/editor-ui/src/components/mixins/nodeHelpers.ts index c0e4939753..b188a26007 100644 --- a/packages/editor-ui/src/components/mixins/nodeHelpers.ts +++ b/packages/editor-ui/src/components/mixins/nodeHelpers.ts @@ -43,6 +43,9 @@ export const nodeHelpers = mixins( ...mapGetters('credentials', [ 'getCredentialTypeByName', 'getCredentialsByType' ]), }, methods: { + isHttpRequestNodeV2 (node: INodeUi): boolean { + return node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2; + }, // Returns the parameter value getParameterValue (nodeValues: INodeParameters, parameterName: string, path: string) { @@ -211,7 +214,7 @@ export const nodeHelpers = mixins( }; if ( - isHttpRequestNodeV2(node) && + this.isHttpRequestNodeV2(node) && authenticateWith === 'genericAuth' && selectedCredsAreUnusable(node, genericAuthType) ) { @@ -220,7 +223,7 @@ export const nodeHelpers = mixins( } if ( - isHttpRequestNodeV2(node) && + this.isHttpRequestNodeV2(node) && authenticateWith === 'nodeCredential' && nodeCredentialType !== '' && node.credentials !== undefined @@ -234,7 +237,7 @@ export const nodeHelpers = mixins( } if ( - isHttpRequestNodeV2(node) && + this.isHttpRequestNodeV2(node) && authenticateWith === 'nodeCredential' && nodeCredentialType !== '' && selectedCredsAreUnusable(node, nodeCredentialType) @@ -440,10 +443,6 @@ export const nodeHelpers = mixins( }, }); -function isHttpRequestNodeV2(node: INodeUi) { - return node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2; -} - /** * Whether the node has no selected credentials, or none of the node's * selected credentials are of the specified type. diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index f00f2230fe..dfc47b3a5c 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -327,13 +327,11 @@ export const workflowHelpers = mixins( const nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, false, false, node); nodeData.parameters = nodeParameters !== null ? nodeParameters : {}; - const fullAccess = node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2; - // Add the node credentials if there are some set and if they should be displayed if (node.credentials !== undefined && nodeType.credentials !== undefined) { const saveCredenetials: INodeCredentials = {}; for (const nodeCredentialTypeName of Object.keys(node.credentials)) { - if (fullAccess) { + if (this.isHttpRequestNodeV2(node)) { saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName]; continue; }