fix(editor): Prevent saving already saved workflows (#9670)

This commit is contained in:
Milorad FIlipović 2024-06-10 16:00:21 +02:00 committed by GitHub
parent 99b54bb029
commit b652405a06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -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');
});

View file

@ -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;
}