Skip to content

Commit

Permalink
fix: Disable continue button unless at least 1 cred has been filled (…
Browse files Browse the repository at this point in the history
…no-changelog) (#7959)

Disable the continue button in template credential setup unless at least
one credential has been (pre-)filled
  • Loading branch information
tomi authored Dec 7, 2023
1 parent c48850d commit a3ca7c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
6 changes: 5 additions & 1 deletion cypress/e2e/34-template-credentials-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ describe('Template credentials setup', () => {
it('can create credentials and workflow from the template', () => {
templateCredentialsSetupPage.actions.visit(testTemplate.id);

templateCredentialsSetupPage.getters.continueButton().should('be.enabled');
// Continue button should be disabled if no credentials are created
templateCredentialsSetupPage.getters.continueButton().should('be.disabled');

templateCredentialsSetupPage.getters.createAppCredentialsButton('Shopify').click();
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
credentialsModal.actions.save(false);
credentialsModal.actions.close();

// Continue button should be enabled if at least one has been created
templateCredentialsSetupPage.getters.continueButton().should('be.enabled');

templateCredentialsSetupPage.getters.createAppCredentialsButton('X (Formerly Twitter)').click();
credentialsModal.getters.editCredentialModal().find('input:first()').type('test');
credentialsModal.actions.save(false);
Expand Down
3 changes: 2 additions & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2283,5 +2283,6 @@
"templateSetup.instructions": "You need {0} account to setup this template",
"templateSetup.skip": "Skip",
"templateSetup.continue.button": "Continue",
"templateSetup.credential.description": "The credential you select will be used in the {0} node of the workflow template. | The credential you select will be used in the {0} nodes of the workflow template."
"templateSetup.credential.description": "The credential you select will be used in the {0} node of the workflow template. | The credential you select will be used in the {0} nodes of the workflow template.",
"templateSetup.continue.button.fillRemaining": "Fill remaining credentials to continue"
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,21 @@ onMounted(async () => {
i18n.baseText('templateSetup.skip')
}}</n8n-link>

<n8n-button
<n8n-tooltip
v-if="isReady"
size="large"
:label="i18n.baseText('templateSetup.continue.button')"
:disabled="setupTemplateStore.isSaving"
@click="setupTemplateStore.createWorkflow({ router })"
data-test-id="continue-button"
/>
:content="i18n.baseText('templateSetup.continue.button.fillRemaining')"
:disabled="setupTemplateStore.numFilledCredentials > 0"
>
<n8n-button
size="large"
:label="i18n.baseText('templateSetup.continue.button')"
:disabled="
setupTemplateStore.isSaving || setupTemplateStore.numFilledCredentials === 0
"
@click="setupTemplateStore.createWorkflow({ router })"
data-test-id="continue-button"
/>
</n8n-tooltip>
<div v-else>
<n8n-loading variant="button" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ export const useSetupTemplateStore = defineStore('setupTemplate', () => {
return overrides;
});

const numFilledCredentials = computed(() => {
return Object.keys(selectedCredentialIdByKey.value).length;
});

//#endregion Getters

//#region Actions
Expand Down Expand Up @@ -376,6 +380,7 @@ export const useSetupTemplateStore = defineStore('setupTemplate', () => {
credentialUsages,
selectedCredentialIdByKey,
credentialOverrides,
numFilledCredentials,
createWorkflow,
skipSetup,
init,
Expand Down

0 comments on commit a3ca7c7

Please # to comment.