-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! There is one thing I think might be worth it to do here too. We should create an initial model for the visualization controller.
The fromModel method must be called on the controller to create the nodes
https://www.patternfly.org/topology/getting-started
I am unsure it is truely necessary but in case it is required elsewhere that a model must be available at all time. The OCP console also does so: https://github.com/openshift/console/blob/126e3fab46c9cc85542783e5e50e272b4d6bd1f0/frontend/packages/topology/src/components/graph-view/Topology.tsx#L200
diff --git a/src/app/Topology/GraphView/TopologyGraphView.tsx b/src/app/Topology/GraphView/TopologyGraphView.tsx
index 466b1a8..e43b714 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<TopologyGraphViewProps> = ({ transformC
}
}, 200),
);
+
+ _newVisualization.fromModel(BASE_MODEL);
+
return _newVisualization;
}, [setSelectedIds, setSelectedEntity]);
@@ -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,
05aa000
to
409b5b5
Compare
* fix(topology): merge topology elements on update * initial model --------- Co-authored-by: Thuan Vo <[email protected]> (cherry picked from commit ffa214f)
* fix(topology): merge topology elements on update * initial model --------- Co-authored-by: Thuan Vo <[email protected]> (cherry picked from commit ffa214f) Co-authored-by: aptmac <[email protected]>
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
To recreate commits with GPG signature
git fetch upstream && git rebase --force --gpg-sign upstream/main
Fixes: #122
Description of the change:
This change switches the boolean in
visualization.fromModel()
in TopologyGraphView from false to true, in-order to "merge" the topology elements on update instead of removing and rebuilding them.Motivation for the change:
What seems to be the issue is that when the boolean is false the visualization clears out all the old elements before re-creating them. This results in the error because it ends up setting the controller to undefined, but during the process of destroying the colalayout there is a check for that controller.
With merge set to true the old elements are cleaned up after the new elements are created, and we don't run into this issue where the controller doesn't exist.
Before:
![errors](https://private-user-images.githubusercontent.com/10425301/410127503-079c309a-4cdf-4ae3-880f-f193d9b92fc3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTk4NDQsIm5iZiI6MTczOTQ5OTU0NCwicGF0aCI6Ii8xMDQyNTMwMS80MTAxMjc1MDMtMDc5YzMwOWEtNGNkZi00YWUzLTg4MGYtZjE5M2Q5YjkyZmMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAyMTkwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzOTIyNzRiNGIzMTNkMWVjOGUwZjk0ZTdmNjExMmM5NzVhYzgyZDNiNmMxNjdhMzIyYTVmZDhlMzY5NmNhNzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.judSEY0b705dufUslw949q8DSpTGBDXOMeir6RhRgH0)
After:
![no errors](https://private-user-images.githubusercontent.com/10425301/410127363-8b3200cd-0454-40a6-8747-30a938d2260d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTk4NDQsIm5iZiI6MTczOTQ5OTU0NCwicGF0aCI6Ii8xMDQyNTMwMS80MTAxMjczNjMtOGIzMjAwY2QtMDQ1NC00MGE2LTg3NDctMzBhOTM4ZDIyNjBkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAyMTkwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUzZDIxYTA2YWYzY2VmMGIyOThiZDAyYTVmZGY1NjVhODAzOTBhZTQyZGQ1NzIxNDUwMDcwYTlmYzdhMmU1MTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.vUGMi-KgtCkleA9NMZWyg5OJX7_pqwdCLhjB1UIusOI)