refactor(devtools): adds router graph implementation and demo#58213
refactor(devtools): adds router graph implementation and demo#58213sumitarora wants to merge 2 commits into
Conversation
f70b0c4 to
b2bd946
Compare
dgp1130
left a comment
There was a problem hiding this comment.
Thanks for putting this together @sumitarora!
I mostly left a bunch of minor readability improvements. I'll have to defer to @AleksanderBodurri on the DI and d3 stuff, as I'm not super familiar with those pieces and can only leave superficial suggestions.
The biggest missing piece to me is testing. I'd love to test some tests covering the newly added code to the extent we can. That would go a long way to maintaining functionality long term.
There was a problem hiding this comment.
Suggestion: Avoid any where possible. I get that there's a bunch of pre-existing any types here and it doesn't look like we have an @angular/router dependency here (should we have one?). But anything we can do to avoid proliferating more any types is probably worth the effort, even if we ignore the existing ones.
There was a problem hiding this comment.
Bug: What if the viewChild elements change? Should we recreate the RouterTreeVisualizer?
Ideally I think routerTreeVisualizer would be a computed(() => new RouterTreeVisualizer(...)), but I think the need to call .cleanup() makes that tricky. Maybe it should just be an effect dependent on viewChild signals?
This is a bit of an academic concern since those viewChild elements are unlikely to change, so up to you if this is really important to fix or not.
There was a problem hiding this comment.
Consider: Since we only snap to root on the first render, could we use something like afterNextRender(() => this.routerTreeVisualizer.snapToRoot(...); in the constructor and then leave it out of renderGraph?
I'm thinking that getting rid of the parameter might make it a little easier to turn this into an effect which is automatically scheduled rather than manually managed.
|
Pls, add option to set router tree vertical, not only horizontal |
4d63a1d to
3618607
Compare
523aaed to
00e541d
Compare
dgp1130
left a comment
There was a problem hiding this comment.
Thanks for these changes! It's looking a lot better already.
Is there anything we can do to write tests for some of the new additions? Maybe testing the new functionality in client-event-subscribers or router-tree.component / router-tree-visualizer?
I get that d3 probably isn't super conducive to unit testing, but even just making sure the right content was loaded and rendered at all goes a long way, even if we can't easily assert the exact layout of the graph.
There was a problem hiding this comment.
Suggestion: I think find would be more appropriate than filter here. Also should we check that we actually found a Router instance? Not everyone will have @angular/router installed.
There was a problem hiding this comment.
Consider: I think this can be marked protected?
There was a problem hiding this comment.
Consider: I think this can be protected too?
There was a problem hiding this comment.
Suggestion: Prefer boolean here as well (or just infer from false).
There was a problem hiding this comment.
Question: What about rendering multiple routes?
df1b144 to
d2d3324
Compare
dgp1130
left a comment
There was a problem hiding this comment.
Added a handful of minor suggestions, but nothing too major.
There was a problem hiding this comment.
Consider: We can simplify this with a spread operator: serializedProviderRecords.push(...nonMultiRecords);
There was a problem hiding this comment.
Nit: Unnecessary trailing space.
There was a problem hiding this comment.
But I don't think ^ works after a .. What does "start of line" mean after a different character for a non-multiline regex?
IIUC:
.*would match anything.^.would match "starts a line with one character"..^would match "one character followed by the start of a line" which feels like it would be never? Playing around with this myself, I can't get it to match any string.
There was a problem hiding this comment.
Consider: The default case does new RegExp(DEFAULT_FILTER /* already a RegExp */). This seems to work, but maybe we should move the new RegExp into the non-default part of this condition to avoid duplicating the regex?
d2d3324 to
150d43f
Compare
c545ade to
a29a356
Compare
There was a problem hiding this comment.
nit: This seems very similar to getInjectorProvidersCallback. Can we consolidate the logic (we can use this helper function in the getInjectorProvidersCallback logic).
|
Adding cleanup label as it needs rebase |
Follow-up PR for angular#58086 & angular#58199. Adds below features to Angular DevTools to display router graph: - Add a new router example in the Angular DevTools demo application. - Implement the router graph in the Angular DevTools to view the routes that are loaded in the application.
a29a356 to
f399068
Compare
|
@pkozlowski-opensource rebased and fixed conflicts. |
- removed unused styles - refactored tests and adding types
f399068 to
9887e94
Compare
|
This PR was merged into the repository by commit 42b1662. The changes were merged into the following branches: main |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…r#58213) Follow-up PR for angular#58086 & angular#58199. Adds below features to Angular DevTools to display router graph: - Add a new router example in the Angular DevTools demo application. - Implement the router graph in the Angular DevTools to view the routes that are loaded in the application. PR Close angular#58213
…angular#58213) - removed unused styles - refactored tests and adding types PR Close angular#58213
Follow-up PR for #58086 & #58199.
Adds below features to Angular DevTools to display router graph: