mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
fix(editor): Prevent saving already saved workflows (#9670)
This commit is contained in:
parent
99b54bb029
commit
b652405a06
|
@ -36,6 +36,20 @@ describe('Workflow Actions', () => {
|
||||||
WorkflowPage.getters.isWorkflowSaved();
|
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', () => {
|
it('should not be able to activate unsaved workflow', () => {
|
||||||
WorkflowPage.getters.activatorSwitch().find('input').first().should('be.disabled');
|
WorkflowPage.getters.activatorSwitch().find('input').first().should('be.disabled');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1572,8 +1572,9 @@ export default defineComponent({
|
||||||
if (e.key === 's' && ctrlModifier && !readOnly) {
|
if (e.key === 's' && ctrlModifier && !readOnly) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const workflowIsSaved = !this.uiStore.stateIsDirty;
|
||||||
|
|
||||||
if (this.isReadOnlyRoute || this.readOnlyEnv) {
|
if (this.isReadOnlyRoute || this.readOnlyEnv || workflowIsSaved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue