Skip to content

Commit

Permalink
feat: remove dagre and elkjs infiniflow#918 (infiniflow#1506)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

feat: remove dagre and elkjs infiniflow#918
### Type of change

- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Jul 15, 2024
1 parent ed5a799 commit 525ccc7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 154 deletions.
31 changes: 0 additions & 31 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
"antd": "^5.12.7",
"axios": "^1.6.3",
"classnames": "^2.5.1",
"dagre": "^0.8.5",
"dayjs": "^1.11.10",
"dompurify": "^3.1.6",
"elkjs": "^0.9.3",
"eventsource-parser": "^1.1.2",
"human-id": "^4.1.1",
"i18next": "^23.7.16",
Expand Down Expand Up @@ -63,7 +61,6 @@
"@redux-devtools/extension": "^3.3.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/dagre": "^0.7.52",
"@types/dompurify": "^3.0.5",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.14.202",
Expand Down
35 changes: 0 additions & 35 deletions web/src/pages/flow/elk-hooks.ts

This file was deleted.

42 changes: 0 additions & 42 deletions web/src/pages/flow/elk-utils.ts

This file was deleted.

43 changes: 0 additions & 43 deletions web/src/pages/flow/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DSLComponents } from '@/interfaces/database/flow';
import { removeUselessFieldsFromValues } from '@/utils/form';
import dagre from 'dagre';
import { humanId } from 'human-id';
import { curry, sample } from 'lodash';
import pipe from 'lodash/fp/pipe';
Expand Down Expand Up @@ -80,48 +79,6 @@ export const buildNodesAndEdgesFromDSLComponents = (data: DSLComponents) => {
return { nodes, edges };
};

const dagreGraph = new dagre.graphlib.Graph();
dagreGraph.setDefaultEdgeLabel(() => ({}));

const nodeWidth = 172;
const nodeHeight = 36;

export const getLayoutedElements = (
nodes: Node[],
edges: Edge[],
direction = 'TB',
) => {
const isHorizontal = direction === 'LR';
dagreGraph.setGraph({ rankdir: direction });

nodes.forEach((node) => {
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
});

edges.forEach((edge) => {
dagreGraph.setEdge(edge.source, edge.target);
});

dagre.layout(dagreGraph);

nodes.forEach((node) => {
const nodeWithPosition = dagreGraph.node(node.id);
node.targetPosition = isHorizontal ? Position.Left : Position.Top;
node.sourcePosition = isHorizontal ? Position.Right : Position.Bottom;

// We are shifting the dagre node position (anchor=center center) to the top left
// so it matches the React Flow node anchor point (top left).
node.position = {
x: nodeWithPosition.x - nodeWidth / 2,
y: nodeWithPosition.y - nodeHeight / 2,
};

return node;
});

return { nodes, edges };
};

const buildComponentDownstreamOrUpstream = (
edges: Edge[],
nodeId: string,
Expand Down

0 comments on commit 525ccc7

Please sign in to comment.