Skip to content

Commit

Permalink
fix(editor): Prevent saving already saved workflows (#9670)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloradFilipovic authored Jun 10, 2024
1 parent 99b54bb commit b652405
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ describe('Workflow Actions', () => {
WorkflowPage.getters.isWorkflowSaved();
});

it('should not save already saved workflow', () => {
cy.intercept('PATCH', '/rest/workflows/*').as('saveWorkflow');
WorkflowPage.actions.saveWorkflowOnButtonClick();
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.actions.saveWorkflowOnButtonClick();
cy.wait('@saveWorkflow');
WorkflowPage.getters.isWorkflowSaved();
// Try to save a few times
WorkflowPage.actions.saveWorkflowUsingKeyboardShortcut();
WorkflowPage.actions.saveWorkflowUsingKeyboardShortcut();
// Should be saved only once
cy.get('@saveWorkflow.all').should('have.length', 1);
});

it('should not be able to activate unsaved workflow', () => {
WorkflowPage.getters.activatorSwitch().find('input').first().should('be.disabled');
});
Expand Down
3 changes: 2 additions & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,9 @@ export default defineComponent({
if (e.key === 's' && ctrlModifier && !readOnly) {
e.stopPropagation();
e.preventDefault();
const workflowIsSaved = !this.uiStore.stateIsDirty;
if (this.isReadOnlyRoute || this.readOnlyEnv) {
if (this.isReadOnlyRoute || this.readOnlyEnv || workflowIsSaved) {
return;
}
Expand Down

0 comments on commit b652405

Please sign in to comment.