From ffa214f7e30b2dc9a30e98b93f84813ef6b6b8cc Mon Sep 17 00:00:00 2001 From: aptmac Date: Wed, 5 Feb 2025 13:55:05 -0500 Subject: [PATCH] fix(topology): merge topology elements on update (#1560) * fix(topology): merge topology elements on update * initial model --------- Co-authored-by: Thuan Vo --- .../Topology/GraphView/TopologyGraphView.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/Topology/GraphView/TopologyGraphView.tsx b/src/app/Topology/GraphView/TopologyGraphView.tsx index 466b1a821..138660d50 100644 --- a/src/app/Topology/GraphView/TopologyGraphView.tsx +++ b/src/app/Topology/GraphView/TopologyGraphView.tsx @@ -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; @@ -146,6 +155,9 @@ export const TopologyGraphView: React.FC = ({ transformC } }, 200), ); + + _newVisualization.fromModel(BASE_MODEL); + return _newVisualization; }, [setSelectedIds, setSelectedEntity]); @@ -171,10 +183,7 @@ export const TopologyGraphView: React.FC = ({ 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, @@ -189,7 +198,7 @@ export const TopologyGraphView: React.FC = ({ 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