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(topology): merge topology elements on update #1560

Merged
merged 2 commits into from
Feb 5, 2025
Merged
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
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
Loading