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 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

View file

@ -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;
},

View file

@ -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.

View file

@ -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;
}