Skip to content

Commit

Permalink
fix(editor): Issue showing Auth2 callback section when all properties…
Browse files Browse the repository at this point in the history
… are overriden (#8999)
  • Loading branch information
RicardoE105 committed Apr 4, 2024
1 parent bc6575a commit dff8f7a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
25 changes: 25 additions & 0 deletions cypress/e2e/2-credentials.cy.ts
Expand Up @@ -236,4 +236,29 @@ describe('Credentials', () => {
.find('input')
.should('have.value', NEW_QUERY_AUTH_ACCOUNT_NAME);
});

it('should not show OAuth redirect URL section when OAuth2 credentials are overridden', () => {
cy.intercept('/types/credentials.json', { middleware: true }, (req) => {
req.headers['cache-control'] = 'no-cache, no-store';

req.on('response', (res) => {
const credentials = res.body || [];

const index = credentials.findIndex((c) => c.name === 'slackOAuth2Api');

credentials[index] = {
...credentials[index],
__overwrittenProperties: ['clientId', 'clientSecret'],
};
});
});

workflowPage.actions.visit(true);
workflowPage.actions.addNodeToCanvas('Slack');
workflowPage.actions.openNode('Slack');
workflowPage.getters.nodeCredentialsSelect().click();
getVisibleSelect().find('li').last().click();
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
nodeDetailsView.getters.copyInput().should('not.exist');
});
});
Expand Up @@ -78,7 +78,7 @@
/>

<CopyInput
v-if="isOAuthType && credentialProperties.length"
v-if="isOAuthType && !allOAuth2BasePropertiesOverridden"
:label="$locale.baseText('credentialEdit.credentialConfig.oAuthRedirectUrl')"
:value="oAuthCallbackUrl"
:copy-button-text="$locale.baseText('credentialEdit.credentialConfig.clickToCopy')"
Expand Down Expand Up @@ -204,6 +204,9 @@ export default defineComponent({
isOAuthType: {
type: Boolean,
},
allOAuth2BasePropertiesOverridden: {
type: Boolean,
},
isOAuthConnected: {
type: Boolean,
},
Expand Down
Expand Up @@ -75,6 +75,7 @@
:parent-types="parentTypes"
:required-properties-filled="requiredPropertiesFilled"
:credential-permissions="credentialPermissions"
:all-o-auth2-base-properties-overridden="allOAuth2BasePropertiesOverridden"
:mode="mode"
:selected-credential="selectedCredential"
:show-auth-type-selector="requiredCredentials"
Expand Down Expand Up @@ -427,6 +428,15 @@ export default defineComponent({
this.parentTypes.includes('oAuth1Api'))
);
},
allOAuth2BasePropertiesOverridden() {
if (this.credentialType?.__overwrittenProperties) {
return (
this.credentialType.__overwrittenProperties.includes('clientId') &&
this.credentialType.__overwrittenProperties.includes('clientSecret')
);
}
return false;
},
isOAuthConnected(): boolean {
return this.isOAuthType && !!this.credentialData.oauthTokenData;
},
Expand All @@ -435,7 +445,7 @@ export default defineComponent({
return [];
}
return this.credentialType.properties.filter((propertyData: INodeProperties) => {
const properties = this.credentialType.properties.filter((propertyData: INodeProperties) => {
if (!this.displayCredentialParameter(propertyData)) {
return false;
}
Expand All @@ -444,6 +454,17 @@ export default defineComponent({
!this.credentialType!.__overwrittenProperties.includes(propertyData.name)
);
});
/**
* If after all credentials overrides are applied only "notice"
* properties are left, do not return them. This will avoid
* showing notices that refer to a property that was overridden.
*/
if (properties.every((p) => p.type === 'notice')) {
return [];
}
return properties;
},
requiredPropertiesFilled(): boolean {
for (const property of this.credentialProperties) {
Expand Down

0 comments on commit dff8f7a

Please sign in to comment.