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

refactor(editor): Upgrade to jsPlumb 5 #4989

Merged
merged 50 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3f99691
WIP: Nodeview
OlegIvaniv Nov 21, 2022
d95a210
Replace types
OlegIvaniv Nov 28, 2022
3ddac83
Finish N8nPlus endpoint type
OlegIvaniv Dec 5, 2022
76814d6
Working on connector
OlegIvaniv Dec 12, 2022
f430c73
WIP: Connector rendering, sort of
OlegIvaniv Dec 13, 2022
8388cd0
Merge commit 'bcde07e03288729ed185d1508cd73efebd82dec0' into n8n-5166…
OlegIvaniv Dec 14, 2022
1ddd0c1
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Dec 14, 2022
4c43189
Apply prettier
OlegIvaniv Dec 14, 2022
908277f
Fixed prettier issues
OlegIvaniv Dec 14, 2022
b255ce0
Debugging rendering
OlegIvaniv Dec 15, 2022
d13dc36
Fixed connectorrs position recalc
OlegIvaniv Dec 15, 2022
a66186a
Fix snapping and output labels, WIP dragging
OlegIvaniv Dec 15, 2022
b41eb51
Fix N8nPlus endpoint rendering issues
OlegIvaniv Dec 20, 2022
b3b6d1b
Merged master
OlegIvaniv Dec 20, 2022
453cc76
Cleanup
OlegIvaniv Dec 20, 2022
d3261b9
Fix undo/redo and canvas add button position, cleanup
OlegIvaniv Dec 20, 2022
dd4e57a
Cleanup
OlegIvaniv Dec 20, 2022
734a7ce
Revert accidental CLI changes
OlegIvaniv Dec 20, 2022
c8b0d03
Fix pnpm-lock
OlegIvaniv Dec 20, 2022
9d8875e
Address bugs that came up during review
OlegIvaniv Jan 10, 2023
1b0a603
Reset CLI package from master
OlegIvaniv Jan 10, 2023
2a05e48
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 10, 2023
492ca25
Various fixes
OlegIvaniv Jan 12, 2023
336831c
Fix run items label toggling
OlegIvaniv Jan 13, 2023
56a7437
Linter fixes
OlegIvaniv Jan 13, 2023
95429e2
Fix stalk size for larger run items label
OlegIvaniv Jan 16, 2023
118c422
Remove comment
OlegIvaniv Jan 16, 2023
774e88c
Correctly reset workspace after renaming the node
OlegIvaniv Jan 16, 2023
74c4216
Fix canvas e2e tests
OlegIvaniv Jan 16, 2023
e253e9b
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 16, 2023
381e070
Fix undo/redo tests
OlegIvaniv Jan 16, 2023
0769450
Fix stalk positioning and triggering of endpoint overlays
OlegIvaniv Jan 17, 2023
ff8b9cc
Repaint connections on pin removal
OlegIvaniv Jan 22, 2023
99ccdba
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 22, 2023
62506ce
Limit repaintings
OlegIvaniv Jan 24, 2023
c2706dd
Unbind jsPlumb events on deactivation
OlegIvaniv Jan 24, 2023
06453bf
Fix jsPlumb managment of Sticky and minor memort managment improvments
OlegIvaniv Jan 24, 2023
b20a6dc
Address rest of PR points
OlegIvaniv Jan 24, 2023
0936854
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 24, 2023
a6e06ff
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 25, 2023
9bae14d
Lint fix
OlegIvaniv Jan 25, 2023
c59b0f8
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 30, 2023
4ae924a
Copy patches folder to docker
OlegIvaniv Jan 30, 2023
e8c6a2c
Fix e2e tests
OlegIvaniv Jan 30, 2023
47a124b
set allowNonAppliedPatches to allow build
OlegIvaniv Jan 30, 2023
9319db2
fix(editor): Handling router errors when navigation is canceled by us…
MiloradFilipovic Jan 30, 2023
7461b3e
ci(core): Fix docker nightly/custom image build (no-changelog) (#5284)
OlegIvaniv Jan 30, 2023
d7d149f
Merge branch 'master' into n8n-5166-migrate-to-jsplumb-5
OlegIvaniv Jan 30, 2023
f5f5842
Fix connector hover state on success
OlegIvaniv Jan 30, 2023
f8f848f
Remove allowNonAppliedPatches from package.json
OlegIvaniv Jan 30, 2023
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
12 changes: 5 additions & 7 deletions cypress/e2e/10-undo-redo.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ describe('Undo/Redo', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(SET_NODE_NAME);
WorkflowPage.getters.nodeConnections().first().trigger('mouseover', { force: true });
cy.get('.connection-actions .add').invoke('show');
cy.get('.connection-actions .add').should('be.visible');
cy.get('.connection-actions .add').click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.nodeConnections().realHover();
cy.get('.connection-actions .add').filter(':visible').click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME, false);
WorkflowPage.actions.zoomToFit();
WorkflowPage.actions.hitUndo();
WorkflowPage.getters.canvasNodes().should('have.have.length', 3);
Expand Down Expand Up @@ -141,8 +139,8 @@ describe('Undo/Redo', () => {
it('should undo/redo deleting a connection by pressing delete button', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.nodeConnections().first().trigger('mouseover', { force: true });
cy.get('.connection-actions .delete').click();
WorkflowPage.getters.nodeConnections().realHover();
cy.get('.connection-actions .delete').filter(':visible').should('be.visible').click();
WorkflowPage.getters.nodeConnections().should('have.length', 0);
WorkflowPage.actions.hitUndo();
WorkflowPage.getters.nodeConnections().should('have.length', 1);
Expand Down
12 changes: 5 additions & 7 deletions cypress/e2e/12-canvas.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ describe('Canvas Actions', () => {
it('should add note between two connected nodes', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.nodeConnections().first().trigger('mouseover', { force: true });
cy.get('.connection-actions .add').as('AddNodeConnectionButton');
cy.get('@AddNodeConnectionButton').invoke('show');
cy.get('@AddNodeConnectionButton').should('be.visible').click();
WorkflowPage.actions.addNodeToCanvas(SET_NODE_NAME);
WorkflowPage.getters.nodeConnections().first().realHover();
cy.get('.connection-actions .add').filter(':visible').should('be.visible').click()
WorkflowPage.actions.addNodeToCanvas(SET_NODE_NAME, false);
WorkflowPage.getters.canvasNodes().should('have.length', 3);
WorkflowPage.getters.nodeConnections().should('have.length', 2);
// And last node should be pushed to the right
Expand Down Expand Up @@ -219,8 +217,8 @@ describe('Canvas Actions', () => {
it('should delete connections by pressing the delete button', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.nodeConnections().first().trigger('mouseover', { force: true });
cy.get('.connection-actions .delete').click();
WorkflowPage.getters.nodeConnections().first().realHover();
cy.get('.connection-actions .delete').filter(':visible').should('be.visible').click();
WorkflowPage.getters.nodeConnections().should('have.length', 0);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('Credentials', () => {
it('should correctly render required and optional credentials', () => {
workflowPage.actions.visit();
cy.waitForLoad();
workflowPage.actions.addNodeToCanvas(PIPEDRIVE_NODE_NAME, true);
workflowPage.actions.addNodeToCanvas(PIPEDRIVE_NODE_NAME, true, true);
cy.get('body').type('{downArrow}');
cy.get('body').type('{enter}');
// Select incoming authentication
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('NDV', () => {
});

it('should show correct validation state for resource locator params', () => {
workflowPage.actions.addNodeToCanvas('Typeform', true);
workflowPage.actions.addNodeToCanvas('Typeform', true, false);
ndv.getters.container().should('be.visible');
cy.get('.has-issues').should('have.length', 0);
cy.get('[class*=hasIssues]').should('have.length', 0);
Expand All @@ -66,7 +66,7 @@ describe('NDV', () => {

it('should show validation errors only after blur or re-opening of NDV', () => {
workflowPage.actions.addNodeToCanvas('Manual Trigger');
workflowPage.actions.addNodeToCanvas('Airtable', true);
workflowPage.actions.addNodeToCanvas('Airtable', true, true);
ndv.getters.container().should('be.visible');
cy.get('.has-issues').should('have.length', 0);
ndv.getters.parameterInput('table').find('input').eq(1).focus().blur();
Expand Down
7 changes: 5 additions & 2 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ export class WorkflowPage extends BasePage {
this.getters.nodeCreatorSearchBar().type('{enter}');
cy.get('body').type('{esc}');
},
addNodeToCanvas: (nodeDisplayName: string, preventNdvClose?: boolean) => {
this.getters.nodeCreatorPlusButton().click();
addNodeToCanvas: (nodeDisplayName: string, plusButtonClick = true, preventNdvClose?: boolean) => {
if (plusButtonClick) {
this.getters.nodeCreatorPlusButton().click();
}

this.getters.nodeCreatorSearchBar().type(nodeDisplayName);
this.getters.nodeCreatorSearchBar().type('{enter}');

Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import "cypress-real-events";
import { WorkflowsPage, SigninPage, SignupPage } from '../pages';
import { N8N_AUTH_COOKIE } from '../constants';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@types/node": "^16.11.22",
"cross-env": "^7.0.3",
"cypress": "^10.0.3",
"cypress-real-events": "^1.7.6",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-mock": "^29.3.1",
Expand Down Expand Up @@ -74,6 +75,7 @@
},
"patchedDependencies": {
"element-ui@2.15.12": "patches/element-ui@2.15.12.patch"
}
},
"allowNonAppliedPatches": true
}
}
6 changes: 5 additions & 1 deletion packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/vue-fontawesome": "^2.0.2",
"@jsplumb/browser-ui": "^5.13.2",
"@jsplumb/common": "^5.13.2",
"@jsplumb/connector-bezier": "^5.13.2",
"@jsplumb/core": "^5.13.2",
"@jsplumb/util": "^5.13.2",
"axios": "^0.21.1",
"codemirror-lang-html-n8n": "^1.0.0",
"codemirror-lang-n8n-expression": "^0.1.0",
Expand All @@ -50,7 +55,6 @@
"humanize-duration": "^3.27.2",
"jquery": "^3.4.1",
"jsonpath": "^1.1.1",
"jsplumb": "2.15.4",
"lodash-es": "^4.17.21",
"lodash.camelcase": "^4.3.0",
"lodash.debounce": "^4.0.8",
Expand Down
118 changes: 0 additions & 118 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { CREDENTIAL_EDIT_MODAL_KEY } from './constants';
/* eslint-disable @typescript-eslint/no-explicit-any */
import { IMenuItem } from 'n8n-design-system';
import {
jsPlumbInstance,
DragOptions,
DropOptions,
ElementGroupRef,
Endpoint,
EndpointOptions,
EndpointRectangle,
EndpointRectangleOptions,
EndpointSpec,
} from 'jsplumb';
import {
GenericValue,
IConnections,
Expand Down Expand Up @@ -47,98 +36,6 @@ import { BulkCommand, Undoable } from '@/models/history';

export * from 'n8n-design-system/types';

declare module 'jsplumb' {
interface PaintStyle {
stroke?: string;
fill?: string;
strokeWidth?: number;
outlineStroke?: string;
outlineWidth?: number;
}

// Extend jsPlumb Anchor interface
interface Anchor {
lastReturnValue: number[];
}

interface Connection {
__meta?: {
sourceNodeName: string;
sourceOutputIndex: number;
targetNodeName: string;
targetOutputIndex: number;
};
canvas?: HTMLElement;
connector?: {
setTargetEndpoint: (endpoint: Endpoint) => void;
resetTargetEndpoint: () => void;
bounds: {
minX: number;
maxX: number;
minY: number;
maxY: number;
};
};

// bind(event: string, (connection: Connection): void;): void;
bind(event: string, callback: Function): void;
removeOverlay(name: string): void;
removeOverlays(): void;
setParameter(name: string, value: any): void;
setPaintStyle(arg0: PaintStyle): void;
addOverlay(arg0: any[]): void;
setConnector(arg0: any[]): void;
getUuids(): [string, string];
}

interface Endpoint {
endpoint: any;
elementId: string;
__meta?: {
nodeName: string;
nodeId: string;
index: number;
totalEndpoints: number;
};
getUuid(): string;
getOverlay(name: string): any;
repaint(params?: object): void;
}

interface N8nPlusEndpoint extends Endpoint {
setSuccessOutput(message: string): void;
clearSuccessOutput(): void;
}

interface Overlay {
setVisible(visible: boolean): void;
setLocation(location: number): void;
canvas?: HTMLElement;
}

interface OnConnectionBindInfo {
originalSourceEndpoint: Endpoint;
originalTargetEndpoint: Endpoint;
getParameters(): { index: number };
}
}

// EndpointOptions from jsplumb seems incomplete and wrong so we define an own one
export type IEndpointOptions = Omit<EndpointOptions, 'endpoint' | 'dragProxy'> & {
endpointStyle: EndpointStyle;
endpointHoverStyle: EndpointStyle;
endpoint?: EndpointSpec | string;
dragAllowedWhenFull?: boolean;
dropOptions?: DropOptions & {
tolerance: string;
};
dragProxy?:
| string
| string[]
| EndpointSpec
| [EndpointRectangle, EndpointRectangleOptions & { strokeWidth: number }];
};

export type EndpointStyle = {
width?: number;
height?: number;
Expand All @@ -152,21 +49,6 @@ export type EndpointStyle = {
hoverMessage?: string;
};

export type IDragOptions = DragOptions & {
grid: [number, number];
filter: string;
};

export type IJsPlumbInstance = Omit<jsPlumbInstance, 'addEndpoint' | 'draggable'> & {
clearDragSelection: () => void;
addEndpoint(
el: ElementGroupRef,
params?: IEndpointOptions,
referenceParams?: IEndpointOptions,
): Endpoint | Endpoint[];
draggable(el: {}, options?: IDragOptions): IJsPlumbInstance;
};

export interface IUpdateInformation {
name: string;
key?: string;
Expand Down
Loading