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

Feature improvement request: include routes into component hierarchy graph #280

Open
MShekow opened this issue Nov 16, 2021 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@MShekow
Copy link

MShekow commented Nov 16, 2021

Hi Allan, your plug-in really helps to visualize dependencies in Angular projects. I particularly like the component hierarchy graph. I noticed, however, that if a component internally uses other components indirectly, via having a <router-outlet></router-outlet> in its HTML template (and routes defined in, say, the AppRoutingModule), then this dependency is missing from the component hierarchy graph.

Do you see a way to also include these indirect dependencies?

@CoderAllan CoderAllan added the enhancement New feature or request label Nov 17, 2021
@CoderAllan
Copy link
Owner

CoderAllan commented Nov 19, 2021

To be honest I'm not a hardcore Angular developer. I primarily do backend stuff in C# and I'm not that familiar with the routing in Angular so I need some more detail of how these relationships should be detected.
This is one of the example apps I have used to test the extension with: https://github.com/DanWahlin/Angular-JumpStart
For example in that app there is the app-routing-module.ts that define the Route for customers that uses the CustomersModule that uses the CustomerComponent as default and the app.component.html has a router-outlet defined. So is the relationship you would like to have visualized is from the app.component to the customer.component in the component hierarchy graph?
Something like this:
image

@MShekow
Copy link
Author

MShekow commented Nov 19, 2021

Yes, correct. For the Angular JumpStart app, I would like to see relations such as

AppComponent => CustomersComponent
AppComponent => OrdersComponent
AppComponent => AboutComponent
CustomersComponent => CustomerOrdersComponent
CustomersComponent => CustomerDetailsComponent
CustomersComponent => CustomerEditComponent

The general parsing logic would be like this:

  • For every component c whose HTML template contains a <router-outlet></router-outlet>:
    • Get the corresponding module m that references c
    • Check the imports or declarations of m's @NgModule for modules which have RouterModule.forRoot(someRoutes) defined
    • Parse someRoutes, and find other components c' that are referenced in someRoutes (see the component key, or loadChildren() key of each route)
    • For every c' you find, there is a relation c => c' in the component hierarchy graph

@CoderAllan
Copy link
Owner

@MShekow I have now published version 1.9.0 of the extension that is rendering the routing relations to components referenced directly in the routing modules, like shown below:
image
When routes are defined as references to module(like in the screenshot below) I need to implement some kind of parsing in order to discover the components that are referenced. I will be working on to solve that issue so all routing relation can be rendered.
image
I will leave this issue open until I get the final part of the rendering implemented.

@MShekow
Copy link
Author

MShekow commented Dec 11, 2021

Dear Allan, thanks for implementing some of the functionality :). With v1.9.0, I do see new orange-colored arrows in the component hierarchy graph.

One minor problem is that the origin of the arrow is not correct, at least for my own project. In my project, the component hierarchy graph claims that my AppComponent (the one referenced in index.html) routes to the other components that were discovered in the AppRoutingModule. In reality, however, AppComponent includes another component X, and the <router-outlet></router-outlet> is present in X's HTML template. Therefore, the origin of the orange arrows should be X, not AppComponent.

@CoderAllan
Copy link
Owner

CoderAllan commented Dec 11, 2021

Thanks for the feedback. Sounds like i have made an assumption that didn't hold...

I have created a fork of Angular-Jumpstart: https://github.com/CoderAllan/Angular-JumpStart
Can you clone that repository, create/change some of components to illustrate the issue, then create a pull request so I can see exactly how your component hierarchy looks like in this situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants