mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Show notice if any cred type supported
This commit is contained in:
parent
216d2e0379
commit
e543b0487f
|
@ -109,20 +109,18 @@ export default mixins(
|
||||||
this.node.parameters.authenticateWith === 'genericAuth';
|
this.node.parameters.authenticateWith === 'genericAuth';
|
||||||
},
|
},
|
||||||
credentialTypesNode (): string[] {
|
credentialTypesNode (): string[] {
|
||||||
return this.credentialTypesNodeDescription
|
const nodeCredentialTypes = this.credentialTypesNodeDescription
|
||||||
.map((credentialTypeDescription) => credentialTypeDescription.name);
|
.map((credentialTypeDescription) => credentialTypeDescription.name);
|
||||||
|
|
||||||
|
this.$emit('nodeCredentialTypes', nodeCredentialTypes);
|
||||||
|
|
||||||
|
return nodeCredentialTypes;
|
||||||
},
|
},
|
||||||
credentialTypesNodeDescriptionDisplayed (): INodeCredentialDescription[] {
|
credentialTypesNodeDescriptionDisplayed (): INodeCredentialDescription[] {
|
||||||
const descriptions = this.credentialTypesNodeDescription
|
return this.credentialTypesNodeDescription
|
||||||
.filter((credentialTypeDescription) => {
|
.filter((credentialTypeDescription) => {
|
||||||
return this.displayCredentials(credentialTypeDescription);
|
return this.displayCredentials(credentialTypeDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (descriptions.length === 1) {
|
|
||||||
this.$emit('newActiveCredentialType', descriptions[0].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return descriptions;
|
|
||||||
},
|
},
|
||||||
credentialTypesNodeDescription (): INodeCredentialDescription[] {
|
credentialTypesNodeDescription (): INodeCredentialDescription[] {
|
||||||
const node = this.node as INodeUi;
|
const node = this.node as INodeUi;
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
<node-credentials
|
<node-credentials
|
||||||
:node="node"
|
:node="node"
|
||||||
@credentialSelected="credentialSelected"
|
@credentialSelected="credentialSelected"
|
||||||
@newActiveCredentialType="checkIfSupportedByHttpRequestNode"
|
@nodeCredentialTypes="checkHttpRequestNodeSupport"
|
||||||
@newHttpRequestNodeCredentialType="loadScopesNoticeData"
|
@newHttpRequestNodeCredentialType="prepareScopesNotice"
|
||||||
/>
|
/>
|
||||||
</parameter-input-list>
|
</parameter-input-list>
|
||||||
<div v-if="parametersNoneSetting.length === 0" class="no-parameters">
|
<div v-if="parametersNoneSetting.length === 0" class="no-parameters">
|
||||||
|
@ -319,30 +319,31 @@ export default mixins(
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* Check if the node's currently active credential type may be used to make a request with the HTTP Request node v2.
|
* Check if any of the node's credential types may be used to make a request with the HTTP Request node v2.
|
||||||
*/
|
*/
|
||||||
checkIfSupportedByHttpRequestNode(activeCredentialTypeName: string) {
|
checkHttpRequestNodeSupport(credentialTypeNames: string[]) {
|
||||||
const credentialType = this.getCredentialTypeByName(activeCredentialTypeName);
|
if (!this.isHttpRequestNodeV2(this.node)) return;
|
||||||
|
|
||||||
this.isSupportedByHttpRequestNode = (
|
this.isSupportedByHttpRequestNode = credentialTypeNames.some(name => {
|
||||||
|
const credentialType = this.getCredentialTypeByName(name);
|
||||||
|
|
||||||
|
return (
|
||||||
credentialType.name.slice(0, -4).endsWith('OAuth') ||
|
credentialType.name.slice(0, -4).endsWith('OAuth') ||
|
||||||
credentialType.authenticate !== undefined
|
credentialType.authenticate !== undefined
|
||||||
);
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async loadScopesNoticeData(activeCredentialType: string) {
|
async prepareScopesNotice(activeCredentialType: string) {
|
||||||
if (!this.isHttpRequestNodeV2(this.node)) return;
|
if (!this.isHttpRequestNodeV2(this.node)) return;
|
||||||
|
|
||||||
if (
|
if (!activeCredentialType || !activeCredentialType.endsWith('OAuth2Api')) {
|
||||||
!activeCredentialType ||
|
|
||||||
!activeCredentialType.endsWith('OAuth2Api')
|
|
||||||
) {
|
|
||||||
this.scopes = [];
|
this.scopes = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeCredential = this.getCredentialTypeByName(activeCredentialType).displayName;
|
|
||||||
|
|
||||||
this.scopes = await this.restApi().getScopes(activeCredentialType);
|
this.scopes = await this.restApi().getScopes(activeCredentialType);
|
||||||
|
|
||||||
|
this.activeCredential = this.getCredentialTypeByName(activeCredentialType).displayName;
|
||||||
},
|
},
|
||||||
onNodeExecute () {
|
onNodeExecute () {
|
||||||
this.$emit('execute');
|
this.$emit('execute');
|
||||||
|
|
Loading…
Reference in a new issue