-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(linking-tool): add support for links tree #39
base: master
Are you sure you want to change the base?
Conversation
4a437d6
to
51c3123
Compare
934c1e2
to
f7d50d8
Compare
Work in progress |
7d18f6e
to
a74b733
Compare
private findNodeWithPath(linkPath: Link[]): LinksTree { | ||
let linksTree = { ...this.linksTree }; | ||
linkPath.forEach(link => { | ||
linksTree = linksTree[link.type] as LinksTree; |
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.
I would check if property is really LinksTree to avoid unhandled errors if wrong path is provided.
embedded?: { id: string }; | ||
queryParams?: Params; | ||
skipLocationChange?: boolean; | ||
[key: string]: any; |
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.
Is there any reason why is interpolatable parameters map not nested under dedicated property?
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.
I am not sure, it's an old code from another project. I think we can remove this for now, if some property will be missing, the change has to be done in this library.
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.
I'm not sure we can simply remove this. I believe it is used to interpolate url params (like "somePath/:id/update") e.g. search for utils.interpolate(url, params)
. What I mean is to move this params under some prop, e.g.
skipLocationChange?: boolean; params?: { [key: string]: any; }
and then pass only obj.params
instead of obj
to the interpolation function. Is it more clear now?
export function convertParamsToQueryParamsString(params: Params): string { | ||
let result = '?'; | ||
Object.keys(params).forEach((key: string) => { | ||
result += `${key}=${params[key]}&`; |
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.
If particular param value is an array of strings (common case), with this implementation it will be rendered like: "?param1=val1,val2¶m2=...". This kind of multi-value query param is not correctly parsed by Angular then into Params object again (you will get {param1: "val1,val2", ...}). It's better to convert it to the following form instead: "?param1=val1¶m1=val2¶m2=...". This kind of url could be correctly parsed by the Angular then (you will get {param1: ["val1", "val2"], ... }) and is also widely supported by many web frameworks.
.concat('-routing.module.ts'); | ||
} | ||
|
||
private static resolveLoadChildrenForIvy(loadChildrenAssignment: PropertyAssignment): string { |
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.
I think this is not the best name. You could not use Ivy and use dynamic imports for routing at the same time and still this function will be used. I would name this function like "resolveLoadChildrenFromDynamicImport" (and the other function "resolveLoadChildrenFromStringImport") or something similiar.
The other thing is if you should use "resolveLoadChildren" or "resolveChildModule(Path? Name?)" instead, in my opinion it is more descriptive.
loadChildrenAssignment.getInitializer() as ArrowFunction | ||
) | ||
.split(/([A-Z]?[^A-Z]*)/g) | ||
.filter(word => !!word && word !== 'Module' && word !== 'Feature'); |
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.
I'm not sure why do you filter out 'Module' and 'Feature' words here. Many modules have 'Feature' word in their name, so it could break filename of routing module. I can imagine some apps could also have "Module" word somewhere in their module names (not only in the suffix). These are not preserved words netiher in JS, nor in Angular, so I don't think we can simply filter them like that.
- create some enum with link types, like the following: | ||
``` | ||
export enum LinkType { | ||
Admin = 'admin', |
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.
I'm not sure it will work with current implementation. It seems like enum item name and its value must match exactly 1:1, because I think you use item name instead of value when saving items to map/tree.
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.
Good point, I will fix it.
a74b733
to
3fb5237
Compare
Add README.md
3fb5237
to
1ae8340
Compare
Add README.md
…Type, with import path.
No description provided.