Skip to content

Commit

Permalink
fix(topology): merge topology elements on update (#1560)
Browse files Browse the repository at this point in the history
* fix(topology): merge topology elements on update

* initial model

---------

Co-authored-by: Thuan Vo <[email protected]>
  • Loading branch information
aptmac and tthvo authored Feb 5, 2025
1 parent d242c1b commit ffa214f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/app/Topology/GraphView/TopologyGraphView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export const MAX_NODE_LIMIT = 100;
export const DEFAULT_SIZEBAR_SIZE = 500;
export const MIN_SIZEBAR_SIZE = 400;

export const BASE_MODEL: Model = {
graph: {
id: TOPOLOGY_GRAPH_ID,
type: 'graph',
layout: 'Cola',
layers: [BOTTOM_LAYER, GROUPS_LAYER, DEFAULT_LAYER, TOP_LAYER],
},
};

export type SavedGraphPosition = {
id?: string;
type?: string;
Expand Down Expand Up @@ -146,6 +155,9 @@ export const TopologyGraphView: React.FC<TopologyGraphViewProps> = ({ transformC
}
}, 200),
);

_newVisualization.fromModel(BASE_MODEL);

return _newVisualization;
}, [setSelectedIds, setSelectedEntity]);

Expand All @@ -171,10 +183,7 @@ export const TopologyGraphView: React.FC<TopologyGraphViewProps> = ({ transformC
}),
edges: _transformData.edges,
graph: {
id: TOPOLOGY_GRAPH_ID,
type: 'graph',
layout: 'Cola',
layers: [BOTTOM_LAYER, GROUPS_LAYER, DEFAULT_LAYER, TOP_LAYER],
...BASE_MODEL.graph!,
data: { ...discoveryTree },
x: graphData.x,
y: graphData.y,
Expand All @@ -189,7 +198,7 @@ export const TopologyGraphView: React.FC<TopologyGraphViewProps> = ({ transformC
}

// Initialize the controller with model to create nodes
visualization.fromModel(model, false);
visualization.fromModel(model, true);
}, [_transformData, visualization, discoveryTree]);

// Note: Do not reorder. Must be called after registering model
Expand Down

0 comments on commit ffa214f

Please sign in to comment.