Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Rebind endpoint events when component activated #7129

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import {
MANUAL_TRIGGER_NODE_NAME,
META_KEY,
SCHEDULE_TRIGGER_NODE_NAME,
SET_NODE_NAME,
} from '../constants';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
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 IMPORT_WORKFLOW_URL =
Expand All @@ -16,6 +18,7 @@ const DUPLICATE_WORKFLOW_TAG = 'Duplicate';

const WorkflowPage = new WorkflowPageClass();
const WorkflowPages = new WorkflowsPageClass();
const executionsTab = new WorkflowExecutionsTab();

describe('Workflow Actions', () => {
beforeEach(() => {
Expand Down Expand Up @@ -250,4 +253,25 @@ describe('Workflow Actions', () => {
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');
});
});
22 changes: 13 additions & 9 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2531,15 +2531,18 @@ export default defineComponent({
this.instance.unbind(EVENT_CONNECTION_ABORT, this.onConnectionDragAbortDetached);
this.instance.unbind(EVENT_CONNECTION_DETACHED, this.onConnectionDragAbortDetached);
this.instance.unbind(EVENT_PLUS_ENDPOINT_CLICK, this.onPlusEndpointClick);

// Get all the endpoints and unbind the events
const elements = this.instance.getManagedElements();
for (const element of Object.values(elements)) {
const endpoints = element.endpoints;
for (const endpoint of endpoints || []) {
const endpointInstance = endpoint?.endpoint;
if (endpointInstance && endpointInstance.type === N8nPlusEndpointType) {
(endpointInstance as N8nPlusEndpoint).unbindEvents();
},
unbindEndpointEventListeners(bind = true) {
if (this.instance) {
// Get all the endpoints and unbind the events
const elements = this.instance.getManagedElements();
for (const element of Object.values(elements)) {
const endpoints = element.endpoints;
for (const endpoint of endpoints || []) {
const endpointInstance = endpoint?.endpoint;
if (endpointInstance && endpointInstance.type === N8nPlusEndpointType) {
(endpointInstance as N8nPlusEndpoint).unbindEvents();
}
}
}
}
Expand Down Expand Up @@ -3575,6 +3578,7 @@ export default defineComponent({
this.nodeCreatorStore.setShowScrim(false);

// Reset nodes
this.unbindEndpointEventListeners();
this.deleteEveryEndpoint();

// Make sure that if there is a waiting test-webhook that it gets removed
Expand Down
Loading