mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
fix(editor): Unbind workflow endpoint events in case of workspace reset (#7129)
This commit is contained in:
parent
22edc03cab
commit
c9b79485cf
|
@ -3,10 +3,12 @@ import {
|
||||||
MANUAL_TRIGGER_NODE_NAME,
|
MANUAL_TRIGGER_NODE_NAME,
|
||||||
META_KEY,
|
META_KEY,
|
||||||
SCHEDULE_TRIGGER_NODE_NAME,
|
SCHEDULE_TRIGGER_NODE_NAME,
|
||||||
|
SET_NODE_NAME,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
||||||
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
|
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
|
||||||
import { getVisibleDropdown, getVisibleSelect } from '../utils';
|
import { getVisibleSelect } from '../utils';
|
||||||
|
import { WorkflowExecutionsTab } from "../pages";
|
||||||
|
|
||||||
const NEW_WORKFLOW_NAME = 'Something else';
|
const NEW_WORKFLOW_NAME = 'Something else';
|
||||||
const IMPORT_WORKFLOW_URL =
|
const IMPORT_WORKFLOW_URL =
|
||||||
|
@ -16,6 +18,7 @@ const DUPLICATE_WORKFLOW_TAG = 'Duplicate';
|
||||||
|
|
||||||
const WorkflowPage = new WorkflowPageClass();
|
const WorkflowPage = new WorkflowPageClass();
|
||||||
const WorkflowPages = new WorkflowsPageClass();
|
const WorkflowPages = new WorkflowsPageClass();
|
||||||
|
const executionsTab = new WorkflowExecutionsTab();
|
||||||
|
|
||||||
describe('Workflow Actions', () => {
|
describe('Workflow Actions', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -250,4 +253,25 @@ describe('Workflow Actions', () => {
|
||||||
duplicateWorkflow();
|
duplicateWorkflow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should keep endpoint click working when switching between execution and editor tab', () => {
|
||||||
|
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
|
||||||
|
cy.intercept('GET', '/rest/executions-current?filter=*').as('getCurrentExecutions');
|
||||||
|
|
||||||
|
WorkflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
||||||
|
WorkflowPage.actions.addNodeToCanvas(SET_NODE_NAME);
|
||||||
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
||||||
|
|
||||||
|
WorkflowPage.getters.canvasNodePlusEndpointByName(SET_NODE_NAME).click();
|
||||||
|
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
||||||
|
cy.get('body').type('{esc}');
|
||||||
|
|
||||||
|
executionsTab.actions.switchToExecutionsTab();
|
||||||
|
cy.wait(['@getExecutions', '@getCurrentExecutions']);
|
||||||
|
cy.wait(500);
|
||||||
|
executionsTab.actions.switchToEditorTab();
|
||||||
|
|
||||||
|
WorkflowPage.getters.canvasNodePlusEndpointByName(SET_NODE_NAME).click();
|
||||||
|
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2531,7 +2531,9 @@ export default defineComponent({
|
||||||
this.instance.unbind(EVENT_CONNECTION_ABORT, this.onConnectionDragAbortDetached);
|
this.instance.unbind(EVENT_CONNECTION_ABORT, this.onConnectionDragAbortDetached);
|
||||||
this.instance.unbind(EVENT_CONNECTION_DETACHED, this.onConnectionDragAbortDetached);
|
this.instance.unbind(EVENT_CONNECTION_DETACHED, this.onConnectionDragAbortDetached);
|
||||||
this.instance.unbind(EVENT_PLUS_ENDPOINT_CLICK, this.onPlusEndpointClick);
|
this.instance.unbind(EVENT_PLUS_ENDPOINT_CLICK, this.onPlusEndpointClick);
|
||||||
|
},
|
||||||
|
unbindEndpointEventListeners(bind = true) {
|
||||||
|
if (this.instance) {
|
||||||
// Get all the endpoints and unbind the events
|
// Get all the endpoints and unbind the events
|
||||||
const elements = this.instance.getManagedElements();
|
const elements = this.instance.getManagedElements();
|
||||||
for (const element of Object.values(elements)) {
|
for (const element of Object.values(elements)) {
|
||||||
|
@ -2543,6 +2545,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onBeforeUnload(e) {
|
onBeforeUnload(e) {
|
||||||
if (this.isDemo || window.preventNodeViewBeforeUnload) {
|
if (this.isDemo || window.preventNodeViewBeforeUnload) {
|
||||||
|
@ -3575,6 +3578,7 @@ export default defineComponent({
|
||||||
this.nodeCreatorStore.setShowScrim(false);
|
this.nodeCreatorStore.setShowScrim(false);
|
||||||
|
|
||||||
// Reset nodes
|
// Reset nodes
|
||||||
|
this.unbindEndpointEventListeners();
|
||||||
this.deleteEveryEndpoint();
|
this.deleteEveryEndpoint();
|
||||||
|
|
||||||
// Make sure that if there is a waiting test-webhook that it gets removed
|
// Make sure that if there is a waiting test-webhook that it gets removed
|
||||||
|
|
Loading…
Reference in a new issue