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';
|
||||
},
|
||||
credentialTypesNode (): string[] {
|
||||
return this.credentialTypesNodeDescription
|
||||
const nodeCredentialTypes = this.credentialTypesNodeDescription
|
||||
.map((credentialTypeDescription) => credentialTypeDescription.name);
|
||||
|
||||
this.$emit('nodeCredentialTypes', nodeCredentialTypes);
|
||||
|
||||
return nodeCredentialTypes;
|
||||
},
|
||||
credentialTypesNodeDescriptionDisplayed (): INodeCredentialDescription[] {
|
||||
const descriptions = this.credentialTypesNodeDescription
|
||||
return this.credentialTypesNodeDescription
|
||||
.filter((credentialTypeDescription) => {
|
||||
return this.displayCredentials(credentialTypeDescription);
|
||||
});
|
||||
|
||||
if (descriptions.length === 1) {
|
||||
this.$emit('newActiveCredentialType', descriptions[0].name);
|
||||
}
|
||||
|
||||
return descriptions;
|
||||
},
|
||||
credentialTypesNodeDescription (): INodeCredentialDescription[] {
|
||||
const node = this.node as INodeUi;
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<node-credentials
|
||||
:node="node"
|
||||
@credentialSelected="credentialSelected"
|
||||
@newActiveCredentialType="checkIfSupportedByHttpRequestNode"
|
||||
@newHttpRequestNodeCredentialType="loadScopesNoticeData"
|
||||
@nodeCredentialTypes="checkHttpRequestNodeSupport"
|
||||
@newHttpRequestNodeCredentialType="prepareScopesNotice"
|
||||
/>
|
||||
</parameter-input-list>
|
||||
<div v-if="parametersNoneSetting.length === 0" class="no-parameters">
|
||||
|
@ -319,30 +319,31 @@ export default mixins(
|
|||
},
|
||||
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) {
|
||||
const credentialType = this.getCredentialTypeByName(activeCredentialTypeName);
|
||||
|
||||
this.isSupportedByHttpRequestNode = (
|
||||
credentialType.name.slice(0, -4).endsWith('OAuth') ||
|
||||
credentialType.authenticate !== undefined
|
||||
);
|
||||
},
|
||||
async loadScopesNoticeData(activeCredentialType: string) {
|
||||
checkHttpRequestNodeSupport(credentialTypeNames: string[]) {
|
||||
if (!this.isHttpRequestNodeV2(this.node)) return;
|
||||
|
||||
if (
|
||||
!activeCredentialType ||
|
||||
!activeCredentialType.endsWith('OAuth2Api')
|
||||
) {
|
||||
this.isSupportedByHttpRequestNode = credentialTypeNames.some(name => {
|
||||
const credentialType = this.getCredentialTypeByName(name);
|
||||
|
||||
return (
|
||||
credentialType.name.slice(0, -4).endsWith('OAuth') ||
|
||||
credentialType.authenticate !== undefined
|
||||
);
|
||||
});
|
||||
},
|
||||
async prepareScopesNotice(activeCredentialType: string) {
|
||||
if (!this.isHttpRequestNodeV2(this.node)) return;
|
||||
|
||||
if (!activeCredentialType || !activeCredentialType.endsWith('OAuth2Api')) {
|
||||
this.scopes = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeCredential = this.getCredentialTypeByName(activeCredentialType).displayName;
|
||||
|
||||
this.scopes = await this.restApi().getScopes(activeCredentialType);
|
||||
|
||||
this.activeCredential = this.getCredentialTypeByName(activeCredentialType).displayName;
|
||||
},
|
||||
onNodeExecute () {
|
||||
this.$emit('execute');
|
||||
|
|
Loading…
Reference in a new issue