Skip to content

Commit 3c9a1d2

Browse files
fix(editor): Prevent saving workflow while another save is in progress (#9048)
1 parent 744327c commit 3c9a1d2

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

cypress/e2e/7-workflow-actions.cy.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ describe('Workflow Actions', () => {
108108
cy.wait('@saveWorkflow');
109109
cy.wrap(null).then(() => expect(interceptCalledCount).to.eq(1));
110110
});
111+
112+
it('should not save workflow twice when save is in progress', () => {
113+
// This happens when users click save button from workflow name input
114+
// In this case blur on the input saves the workflow and then click on the button saves it again
115+
WorkflowPage.actions.visit();
116+
WorkflowPage.getters.workflowNameInput().invoke('val').then((oldName) => {
117+
WorkflowPage.getters.workflowNameInputContainer().click();
118+
WorkflowPage.getters.workflowNameInput().type('{selectall}');
119+
WorkflowPage.getters.workflowNameInput().type('Test');
120+
WorkflowPage.getters.saveButton().click();
121+
WorkflowPage.getters.workflowNameInput().should('have.value', 'Test');
122+
cy.visit(WorkflowPages.url);
123+
// There should be no workflow with the old name (duplicate save)
124+
WorkflowPages.getters.workflowCards().contains(String(oldName)).should('not.exist');
125+
});
126+
});
127+
111128
it('should copy nodes', () => {
112129
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
113130
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);

packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ export default defineComponent({
388388
},
389389
methods: {
390390
async onSaveButtonClick() {
391+
// If the workflow is saving, do not allow another save
392+
if (this.isWorkflowSaving) {
393+
return;
394+
}
391395
let currentId = undefined;
392396
if (this.currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
393397
currentId = this.currentWorkflowId;
@@ -497,11 +501,12 @@ export default defineComponent({
497501
cb(true);
498502
return;
499503
}
500-
504+
this.uiStore.addActiveAction('workflowSaving');
501505
const saved = await this.workflowHelpers.saveCurrentWorkflow({ name });
502506
if (saved) {
503507
this.isNameEditEnabled = false;
504508
}
509+
this.uiStore.removeActiveAction('workflowSaving');
505510
cb(saved);
506511
},
507512
async handleFileImport(): Promise<void> {

0 commit comments

Comments
 (0)