-
-
Notifications
You must be signed in to change notification settings - Fork 241
feat: enable nesting named page router outlets #1556
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
Conversation
c840df2
to
af4a15d
Compare
d3250ec
to
7d68733
Compare
test branch_testsappng#djenkov/nested-outlets sdk_ng |
@@ -342,10 +361,27 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire | |||
} | |||
|
|||
private markActivatedRoute(activatedRoute: ActivatedRoute) { |
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.
Add comments on what this method does
@@ -149,16 +150,17 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire | |||
private parentContexts: ChildrenOutletContexts, | |||
private location: ViewContainerRef, | |||
@Attribute("name") name: string, | |||
@Attribute("isNSEmptyOutlet") isNSEmptyOutlet: boolean, |
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.
The property can be named isEmptyOutlet
-> it is already inside a PageRouterOutlet
class that is NS-specific.
Also you can inject and define it in the same time
@Attribute("isNSEmptyOutlet") isNSEmptyOutlet: boolean, | |
@Attribute("isNSEmptyOutlet") private isEmptyOutlet: boolean, |
@@ -81,7 +82,10 @@ export class ModalDialogService { | |||
const componentContainer = moduleRef || viewContainerRef; | |||
const resolver = componentContainer.injector.get(ComponentFactoryResolver); | |||
|
|||
const frame = parentView.page && parentView.page.frame; | |||
let frame = parentView; |
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.
Can we add a comment about the scenario where parentView is a Frame? (it seems previously there wasn't such scenario?)
@@ -81,7 +82,10 @@ export class ModalDialogService { | |||
const componentContainer = moduleRef || viewContainerRef; | |||
const resolver = componentContainer.injector.get(ComponentFactoryResolver); | |||
|
|||
const frame = parentView.page && parentView.page.frame; | |||
let frame = parentView; |
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.
Can we add a comment about the scenario where parentView is a Frame? (it seems previously there wasn't such scenario?)
if (url !== tree.toString()) { | ||
const urlSerializer = new DefaultUrlSerializer(); | ||
const stateUrlTree: UrlTree = urlSerializer.parse(url); | ||
const rootOutlets = stateUrlTree.root.children; | ||
|
||
Object.keys(rootOutlets).forEach(outletName => { | ||
const topState = this.peekState(outletName); | ||
const outlet = this.findOutletByKey(outletName); | ||
const topState = outlet.peekState(); |
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.
topState
is not guarded for null
} else { | ||
const queue = []; | ||
queue.push(urlTreeRoot); | ||
let currentTree = queue.shift(); |
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.
const queue = [];
let currentTree = urlTreeRoot;
// tslint:disable-next-line:component-selector | ||
selector: "ns-empty-outlet", | ||
moduleId: module.id, | ||
template: "<page-router-outlet isNSEmptyOutlet='true'></page-router-outlet>" |
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 isNSEmptyOutlet
is renamed this should be renamed as well.
@@ -81,7 +82,10 @@ export class ModalDialogService { | |||
const componentContainer = moduleRef || viewContainerRef; | |||
const resolver = componentContainer.injector.get(ComponentFactoryResolver); | |||
|
|||
const frame = parentView.page && parentView.page.frame; | |||
let frame = parentView; |
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.
Can we add a comment about the scenario where parentView is a Frame? (it seems previously there wasn't such scenario?)
@@ -52,19 +79,21 @@ export class NSLocationStrategy extends LocationStrategy { | |||
return "/"; | |||
} | |||
|
|||
const state = this.peekState(this.currentOutlet); | |||
const state = this.currentOutlet && this.currentOutlet.peekState(); |
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 it possible for this.currentOutlet to be null when this.currentUrlTree is not null?
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.
We set currentUrlTree
inside pushStateInternal
where all incoming urls are transformed into outlets . There will be always at least 1 Outlet set as currentOutlet
. The otherwise should be possible only if pushState()
is called from Angular with empty url param.
this.currentUrlTree = urlSerializer.parse(url); | ||
const urlTreeRoot = this.currentUrlTree.root; | ||
|
||
if (!Object.keys(urlTreeRoot.children).length) { |
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.
To reduce indentation of the main case instead of:
if (!Object.keys(urlTreeRoot.children).length) {
} else {
// else clause statements go here...
}
Use:
if (!Object.keys(urlTreeRoot.children).length) {
// ...
return;
}
// else clause statements go here...
} else { | ||
tree.root.children[this.currentOutlet] = state.segmentGroup; | ||
} else if (changedOutlet) { | ||
// tslint:disable-next-line:max-line-length |
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.
Probably comment is unnecessary at this point.
componentView.closeModal(); | ||
this.location.back(); | ||
this.location._finishCloseModalNavigation(); |
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.
Maybe rename to _closeModalNavigation?
return null; | ||
} | ||
|
||
containsLastState(stateUrl: string): boolean { |
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.
Maybe containsTopState?
isPageNavigationBack: boolean; | ||
outletKeys: Array<string>; | ||
pathByOutlets: string; | ||
statesByOutlet: Array<LocationState> = []; |
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.
Rename to states?
segmentGroup = segmentGroup.children[currentPath]; | ||
} else { | ||
segmentGroup = null; | ||
break; |
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.
Explain this with a comment
test nested-router-tab-view#djenkov/nested-outlets |
modalNavigationDepth: number; | ||
parent: Outlet; | ||
isPageNavigationBack: boolean; | ||
outletKeys: Array<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.
[Reminder] As discussed it would be useful to add a comment why Outlet can have multiple (two) keys.
} | ||
} | ||
|
||
queue.push(currentTree.children[outletName]); |
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.
[Reminder] queue.push(currentSegmentGroup)
for clarity.
|
||
while (segmentGroup) { | ||
const url = segmentGroup.toString(); | ||
fullPath = fullPath ? (url ? url + "/" : url) + fullPath : url; |
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.
This one-liner is concise but that also makes it unnecessarily complex to understand.
private updateSegmentGroup(rootNode, oldSegmentGroup: UrlSegmentGroup, newSegmentGroup: UrlSegmentGroup) { | ||
const queue = []; | ||
queue.push(rootNode); | ||
let currentTree = queue.shift(); |
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.
const queue = [];
let currentTree = rootNode;
test branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
feat(location-strategy): refactor location strategy to support nested p-r-o feat(reuse-strategy): refactor reuse strategy to support nested p-r-o chore(frame-service): cleanup FrameService from unused methods feat(router-extensions): extend back() to handle specific outlets by relative route feat(location-strategy): rework location strategy to support simultaneously outlets back navigation chore(e2e-tests): extend nested tabs test app with 'split view' chore: mark states with the current parent route path chore: add parent outlet to Outlet chore(router-extensions): prevent back navigation of outlet that already navigating back chore(reuse-strategy): extend cache key with parent route state string (unique) fix(router-extensions): fix back navigation when only relative route provided. Should find and back in the current outlet chore(e2e-tests): extend nested-router-tab-view app with tests chore(location-strategy): rework location strategy to store outlets by their parent path and current outlet name chore(reuse-strategy): child components should not be reteached when parent is detached chore(e2e-tests): extend e2e tests chore(reuse-strategy): modify shouldDetach to mark parent outlet chore(location-strategy): Modify getRouteFullPath method chore(p-r-o): mark all activated routes child routes that have coresponding outlet chore(router-extensions): find top activated route node for outlet when going back chore(location-strategy): modify getRouteFullPath to generates proper url path chore(p-r-o): find the top activated route for outlet inside activateWith method chore(e2e-tests): extend nested tab view app with lazy loaded home module feat(router-extensions): extend canGoBack() to handle specific outlets by relative route e2e tests added feat(modal-views): remove the back navigation when destroying modal views with p-r-o Introduce modalNavigationDepth to mark all p-r-o , along with their states, shown as modals. chore(e2e-modal-navigation): modify goBack to back in the current ActivatedRoute feat(modal-views): create outlet for any p-r-o displayed as modal view (even if it's 'primary') feat: introduce NSEmptyOutletComponent to support nested named lazy loaded modules feat(page-router-outlet): support named lazy loaded outlet Allow Outlet to be associated with more than one p-r-o (NSEmptyOutlet)
b9329d2
to
37f9aa4
Compare
test nativescript_ng_cosmos branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
1 similar comment
test nativescript_ng_cosmos branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
452cb8f
to
7259fc1
Compare
test nativescript_ng_cosmos branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
test nativescript_ng_cosmos branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets nativescript_ng_cosmos_api28 nativescript_ng_cosmos_ios12 |
test nativescript_ng_cosmos branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets nativescript_ng_cosmos_api28 nativescript_ng_cosmos_ios12 |
test branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
test branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
1 similar comment
test branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
test branch_nested-router-tab-view#djenkov/nested-outlets testsappng#djenkov/nested-outlets |
TO DO: Add description
Resolve: #1351