Consolidate HTTPRN check

This commit is contained in:
Iván Ovejero 2022-05-05 14:56:06 +02:00
parent 2eaf05ea21
commit fec2fc1b08
4 changed files with 12 additions and 20 deletions

View file

@ -77,7 +77,6 @@ import { showMessage } from '@/components/mixins/showMessage';
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
import { HTTP_REQUEST_NODE_TYPE } from '@/constants';
export default mixins( export default mixins(
genericHelpers, genericHelpers,
@ -101,14 +100,12 @@ export default mixins(
getCredentialTypeByName: 'getCredentialTypeByName', getCredentialTypeByName: 'getCredentialTypeByName',
}), }),
isProxyAuth(): boolean { isProxyAuth(): boolean {
return this.node.type === HTTP_REQUEST_NODE_TYPE return this.isHttpRequestNodeV2(this.node) &&
&& this.node.typeVersion === 2 this.node.parameters.authenticateWith === 'nodeCredential';
&& this.node.parameters.authenticateWith === 'nodeCredential';
}, },
isGenericAuth(): boolean { isGenericAuth(): boolean {
return this.node.type === HTTP_REQUEST_NODE_TYPE return this.isHttpRequestNodeV2(this.node) &&
&& this.node.typeVersion === 2 this.node.parameters.authenticateWith === 'genericAuth';
&& this.node.parameters.authenticateWith === 'genericAuth';
}, },
credentialTypesNode (): string[] { credentialTypesNode (): string[] {
return this.credentialTypesNodeDescription return this.credentialTypesNodeDescription

View file

@ -134,9 +134,7 @@ export default mixins(
return this.$store.getters.activeNode; return this.$store.getters.activeNode;
}, },
indexToShowSlotAt (): number { indexToShowSlotAt (): number {
if (this.node.type === HTTP_REQUEST_NODE_TYPE && this.node.typeVersion === 2) { if (this.isHttpRequestNodeV2(this.node)) return 2;
return 2;
}
return 0; return 0;
}, },

View file

@ -43,6 +43,9 @@ export const nodeHelpers = mixins(
...mapGetters('credentials', [ 'getCredentialTypeByName', 'getCredentialsByType' ]), ...mapGetters('credentials', [ 'getCredentialTypeByName', 'getCredentialsByType' ]),
}, },
methods: { methods: {
isHttpRequestNodeV2 (node: INodeUi): boolean {
return node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2;
},
// Returns the parameter value // Returns the parameter value
getParameterValue (nodeValues: INodeParameters, parameterName: string, path: string) { getParameterValue (nodeValues: INodeParameters, parameterName: string, path: string) {
@ -211,7 +214,7 @@ export const nodeHelpers = mixins(
}; };
if ( if (
isHttpRequestNodeV2(node) && this.isHttpRequestNodeV2(node) &&
authenticateWith === 'genericAuth' && authenticateWith === 'genericAuth' &&
selectedCredsAreUnusable(node, genericAuthType) selectedCredsAreUnusable(node, genericAuthType)
) { ) {
@ -220,7 +223,7 @@ export const nodeHelpers = mixins(
} }
if ( if (
isHttpRequestNodeV2(node) && this.isHttpRequestNodeV2(node) &&
authenticateWith === 'nodeCredential' && authenticateWith === 'nodeCredential' &&
nodeCredentialType !== '' && nodeCredentialType !== '' &&
node.credentials !== undefined node.credentials !== undefined
@ -234,7 +237,7 @@ export const nodeHelpers = mixins(
} }
if ( if (
isHttpRequestNodeV2(node) && this.isHttpRequestNodeV2(node) &&
authenticateWith === 'nodeCredential' && authenticateWith === 'nodeCredential' &&
nodeCredentialType !== '' && nodeCredentialType !== '' &&
selectedCredsAreUnusable(node, 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 * Whether the node has no selected credentials, or none of the node's
* selected credentials are of the specified type. * selected credentials are of the specified type.

View file

@ -327,13 +327,11 @@ export const workflowHelpers = mixins(
const nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, false, false, node); const nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, false, false, node);
nodeData.parameters = nodeParameters !== null ? nodeParameters : {}; 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 // Add the node credentials if there are some set and if they should be displayed
if (node.credentials !== undefined && nodeType.credentials !== undefined) { if (node.credentials !== undefined && nodeType.credentials !== undefined) {
const saveCredenetials: INodeCredentials = {}; const saveCredenetials: INodeCredentials = {};
for (const nodeCredentialTypeName of Object.keys(node.credentials)) { for (const nodeCredentialTypeName of Object.keys(node.credentials)) {
if (fullAccess) { if (this.isHttpRequestNodeV2(node)) {
saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName]; saveCredenetials[nodeCredentialTypeName] = node.credentials[nodeCredentialTypeName];
continue; continue;
} }