Skip to content

Commit 1329136

Browse files
Merge pull request #1633 from NativeScript/release-7.0.2
Release 7.0.2
2 parents 851ba1d + 816856f commit 1329136

40 files changed

+159
-38
lines changed

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name="7.0.2"></a>
2+
## [7.0.2](https://github.com/NativeScript/nativescript-angular/compare/7.0.1...7.0.2) (2018-11-26)
3+
4+
5+
### Bug Fixes
6+
7+
* **page-router-outlet:** actionBarVisibility not applied ([#1621](https://github.com/NativeScript/nativescript-angular/issues/1621)) ([a6ff509](https://github.com/NativeScript/nativescript-angular/commit/a6ff509))
8+
* **router-extensions:** unable to go back with relativeTo param ([#1632](https://github.com/NativeScript/nativescript-angular/issues/1632)) ([63900dc](https://github.com/NativeScript/nativescript-angular/commit/63900dc))
9+
10+
11+
112
<a name="7.0.1"></a>
213
## [7.0.1](https://github.com/NativeScript/nativescript-angular/compare/7.0.0...7.0.1) (2018-11-20)
314

Diff for: e2e/modal-navigation-ng/e2e/screens/screen.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Screen {
4444
}
4545

4646
loadedHome = async () => {
47-
const lblHome = await this._driver.findElementByAutomationText(home);
47+
const lblHome = await this._driver.waitForElement(home);
4848
assert.isTrue(await lblHome.isDisplayed());
4949
console.log(home + " loaded!");
5050
}
@@ -149,7 +149,7 @@ export class Screen {
149149
}
150150

151151
loadedModalFrame = async () => {
152-
const lblModal = await this._driver.findElementByAutomationText(modal, 1000);
152+
const lblModal = await this._driver.waitForElement(modal, 5000);
153153
assert.isTrue(await lblModal.isDisplayed(), `${modal} is not displayed!`);
154154
console.log(modal + " loaded!");
155155
}
@@ -226,7 +226,7 @@ export class Screen {
226226
}
227227

228228
loadedSecondPage = async () => {
229-
const lblModalSecond = await this._driver.findElementByAutomationText(modalSecond);
229+
const lblModalSecond = await this._driver.waitForElement(modalSecond, 5000);
230230
assert.isTrue(await lblModalSecond.isDisplayed());
231231
console.log(modalSecond + " loaded!");
232232
}
@@ -259,7 +259,7 @@ export class Screen {
259259
}
260260

261261
loadedNestedModalFrame = async () => {
262-
const lblModalNested = await this._driver.findElementByAutomationText(modalNested);
262+
const lblModalNested = await this._driver.waitForElement(modalNested, 5000);
263263
assert.isTrue(await lblModalNested.isDisplayed());
264264
console.log(modalNested + " loaded!");
265265
}

Diff for: e2e/renderer/app/app-routing.module.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2-
import { NativeScriptRouterModule } from "nativescript-angular/router";
2+
import { NativeScriptRouterModule, NSEmptyOutletComponent } from "nativescript-angular/router";
33

44
import { ActionBarDynamicItemsComponent } from "./action-bar/action-bar-dynamic-items.component";
55
import { ActionBarExtensionComponent } from "./action-bar/action-bar-extension.component";
@@ -54,6 +54,16 @@ export const routes = [
5454
component: NestedPageComponent
5555
}]
5656
},
57+
{
58+
path: "action-bar-visibility-never-lazy",
59+
component: ActionBarVisibilityNeverComponent,
60+
children: [{
61+
path: "nested",
62+
outlet: "nested",
63+
component: NSEmptyOutletComponent,
64+
loadChildren:"~/page-router-outlet/nested-lazy-page.module#NestedLazyPageModule"
65+
}]
66+
},
5767
{
5868
path: "action-bar-dynamic",
5969
component: ActionBarDynamicItemsComponent,
@@ -111,7 +121,6 @@ export const navigatableComponents = [
111121
ActionBarVisibilityAlwaysComponent,
112122
ActionBarVisibilityNeverComponent,
113123
ActionBarVisibilityAutoComponent,
114-
NestedPageComponent,
115124

116125
TabItemBindingComponent,
117126

Diff for: e2e/renderer/app/app.module.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { ItemsService } from "./items.service";
1111

1212
import { rendererTraceCategory, viewUtilCategory, bootstrapCategory } from "nativescript-angular/trace";
1313
import { addCategories, enable, categories } from "tns-core-modules/trace";
14+
import { SharedModule } from "./shared.module";
15+
1416
addCategories(bootstrapCategory);
1517
addCategories(rendererTraceCategory);
1618
addCategories(viewUtilCategory);
@@ -22,7 +24,7 @@ export class MyErrorHandler implements ErrorHandler {
2224
console.log("### ErrorHandler Error: " + error.toString());
2325
console.log("### ErrorHandler Stack: " + error.stack);
2426
}
25-
}
27+
}
2628

2729

2830
@NgModule({
@@ -38,6 +40,7 @@ export class MyErrorHandler implements ErrorHandler {
3840
imports: [
3941
NativeScriptModule,
4042
AppRoutingModule,
43+
SharedModule
4144
],
4245
schemas: [NO_ERRORS_SCHEMA],
4346
})

Diff for: e2e/renderer/app/list.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Component } from "@angular/core";
99
<Button text="ActionBarVisibility Always" [nsRouterLink]="['/action-bar-visibility-always']"></Button>
1010
<Button text="ActionBarVisibility Never" [nsRouterLink]="['/action-bar-visibility-never']"></Button>
1111
<Button text="ActionBarVisibility Auto" [nsRouterLink]="['/action-bar-visibility-auto']"></Button>
12+
<Button text="ActionBarVisibility Never Lazy" [nsRouterLink]="['/action-bar-visibility-never-lazy']"></Button>
1213
<Button text="TabItem Binding" [nsRouterLink]="['/tab-item-binding']"></Button>
1314
<Button text="NgFor" [nsRouterLink]="['/ngfor']"></Button>
1415
<Button text="NgForOf" [nsRouterLink]="['/ngforof']"></Button>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2+
import { NativeScriptRouterModule } from "nativescript-angular/router";
3+
import { NativeScriptCommonModule } from "nativescript-angular/common";
4+
import { SharedModule } from "~/shared.module";
5+
import { NestedPageComponent } from "./nested-page.component";
6+
7+
@NgModule({
8+
imports: [
9+
SharedModule,
10+
NativeScriptCommonModule,
11+
NativeScriptRouterModule,
12+
NativeScriptRouterModule.forChild([
13+
{ path: "", component: NestedPageComponent }
14+
])
15+
],
16+
providers: [
17+
],
18+
schemas: [NO_ERRORS_SCHEMA]
19+
})
20+
export class NestedLazyPageModule { }

Diff for: e2e/renderer/app/shared.module.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2+
import { NativeScriptRouterModule } from "nativescript-angular/router";
3+
import { NativeScriptCommonModule } from "nativescript-angular/common";
4+
import { NestedPageComponent } from "./page-router-outlet/nested-page.component";
5+
6+
@NgModule({
7+
imports: [
8+
NativeScriptCommonModule,
9+
NativeScriptRouterModule
10+
],
11+
declarations:[NestedPageComponent],
12+
schemas: [NO_ERRORS_SCHEMA]
13+
})
14+
export class SharedModule { }

Diff for: e2e/renderer/e2e/action-bar.e2e-spec.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "nativescript-dev-appium";
77

88
import { isOnTheLeft } from "./helpers/location";
9+
import { assert } from "chai";
910

1011
describe("Action Bar scenario", () => {
1112
let driver: AppiumDriver;
@@ -132,16 +133,10 @@ describe("Action Bar scenario", () => {
132133
conditional = await driver.findElementByAutomationText("conditional");
133134
});
134135

135-
it("should detach conditional action item when its condition is false", done => {
136-
(async () => {
137-
await toggle();
138-
139-
try {
140-
await driver.findElementByAutomationText("conditional");
141-
} catch (e) {
142-
done();
143-
}
144-
})();
136+
it("should detach conditional action item when its condition is false", async () => {
137+
await toggle();
138+
const conditionalBtn = await driver.waitForElement("conditional", 1000);
139+
assert.isUndefined(conditionalBtn, "Conditional button should not be visible!");
145140
});
146141

147142
it("should reattach conditional action item at correct place", async () => {

Diff for: e2e/renderer/e2e/page-router-outlet.e2e-spec.ts

+46
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,52 @@ describe("page-router-outlet-scenario", () => {
9393
});
9494
});
9595

96+
describe("actionBarVisibility 'never' doesn't show action bars in lazy module page", async () => {
97+
let imagePostFix = "";
98+
before(async () => {
99+
driver = await createDriver();
100+
await driver.driver.resetApp();
101+
if (driver.isIOS && driver.nsCapabilities.device.name.toLowerCase().includes("x")) {
102+
imagePostFix = "-lazy";
103+
}
104+
});
105+
106+
afterEach(async function () {
107+
if (this.currentTest.state === "failed") {
108+
await driver.logTestArtifacts(this.currentTest.title);
109+
}
110+
});
111+
112+
it("should navigate to page", async () => {
113+
const navigationButton =
114+
await driver.findElementByAutomationText("ActionBarVisibility Never Lazy");
115+
await navigationButton.click();
116+
117+
await driver.findElementByAutomationText("ShowActionBar");
118+
});
119+
120+
it("should hide action bar by default", async () => {
121+
const screenMatches = await driver.compareScreen(`actionBarVisibility-never-default${imagePostFix}`, 5);
122+
assert(screenMatches);
123+
});
124+
125+
it("should not show action bar when shown by page", async () => {
126+
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
127+
showActionBarButton.click();
128+
129+
const screenMatches = await driver.compareScreen(`actionBarVisibility-never-shown${imagePostFix}`, 5);
130+
assert(screenMatches);
131+
});
132+
133+
it("should not do anything when hidden action bar by page", async () => {
134+
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
135+
hideActionBarButton.click();
136+
137+
const screenMatches = await driver.compareScreen(`actionBarVisibility-never-hidden${imagePostFix}`, 5);
138+
assert(screenMatches);
139+
});
140+
});
141+
96142
describe("actionBarVisibility 'auto' shows action bars based on page", async () => {
97143
before(async () => {
98144
driver = await createDriver();
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

Diff for: e2e/renderer/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
},
2525
"devDependencies": {
2626
"@angular/compiler-cli": "~7.0.0",
27-
"@types/chai": "^4.0.2",
28-
"@types/mocha": "^2.2.41",
29-
"@types/node": "^7.0.5",
27+
"@ngtools/webpack": "~7.0.0",
28+
"@types/chai": "~4.1.3",
29+
"@types/mocha": "~5.2.1",
30+
"@types/node": "10.11.4",
3031
"babel-traverse": "6.25.0",
3132
"babel-types": "6.25.0",
3233
"babylon": "6.17.4",
3334
"chai": "~4.1.1",
3435
"chai-as-promised": "~7.1.1",
3536
"colors": "^1.1.2",
3637
"lazy": "1.0.11",
37-
"mocha": "~3.5.0",
38-
"mocha-junit-reporter": "^1.13.0",
39-
"mocha-multi": "^0.11.0",
38+
"mocha": "~5.1.0",
39+
"mocha-junit-reporter": "~1.17.0",
40+
"mocha-multi": "~1.0.0",
4041
"nativescript-dev-appium": "next",
4142
"nativescript-dev-typescript": "~0.7.1",
4243
"nativescript-dev-webpack": "next",
4344
"tslib": "^1.7.1",
44-
"typescript": "~3.1.1",
45-
"@ngtools/webpack": "~7.0.0"
45+
"typescript": "~3.1.1"
4646
},
4747
"scripts": {
4848
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",

Diff for: nativescript-angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-angular",
3-
"version": "7.0.1",
3+
"version": "7.0.2",
44
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
55
"homepage": "https://www.nativescript.org/",
66
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
+9-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
import { Component } from "@angular/core";
1+
import { Component, ViewChild } from "@angular/core";
22
import { Page } from "tns-core-modules/ui/page";
3+
import { PageRouterOutlet } from "./page-router-outlet";
34
@Component({
45
// tslint:disable-next-line:component-selector
56
selector: "ns-empty-outlet",
67
moduleId: module.id,
78
template: "<page-router-outlet isEmptyOutlet='true'></page-router-outlet>"
89
})
910
export class NSEmptyOutletComponent {
11+
@ViewChild(PageRouterOutlet) pageRouterOutlet: PageRouterOutlet;
1012
constructor(private page: Page) {
1113
if (this.page) {
1214
this.page.actionBarHidden = true;
15+
16+
this.page.on("loaded", () => {
17+
if (this.pageRouterOutlet && this.page.frame) {
18+
this.pageRouterOutlet.setActionBarVisibility(this.page.frame.actionBarVisibility);
19+
}
20+
});
1321
}
1422
}
1523
}

Diff for: nativescript-angular/router/ns-location-strategy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class Outlet {
2525
path: string;
2626
pathByOutlets: string;
2727
states: Array<LocationState> = [];
28+
isNSEmptyOutlet: boolean;
2829

2930
// Used in reuse-strategy by its children to determine if they should be detached too.
3031
shouldDetach: boolean = true;

Diff for: nativescript-angular/router/page-router-outlet.ts

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
280280
return;
281281
}
282282

283+
this.outlet.isNSEmptyOutlet = this.isEmptyOutlet;
283284
this.locationStrategy.updateOutletFrame(this.outlet, this.frame);
284285

285286
if (this.outlet && this.outlet.isPageNavigationBack) {

Diff for: nativescript-angular/router/router-extensions.ts

+23-11
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,24 @@ export class RouterExtensions {
9393
const outletsToBack: Array<Outlet> = [];
9494
const rootRoute: ActivatedRoute = this.router.routerState.root;
9595
let outlets = options.outlets;
96-
let relativeRoute = options.relativeTo;
96+
let relativeRoute = options.relativeTo || rootRoute;
9797

98-
if (!outlets && relativeRoute) {
99-
outlets = [relativeRoute.outlet];
100-
relativeRoute = relativeRoute.parent || rootRoute;
101-
} else if (!relativeRoute) {
102-
relativeRoute = rootRoute;
98+
const relativeRouteOutlet = this.findOutletByRoute(relativeRoute);
99+
const isNSEmptyOutlet = relativeRouteOutlet && relativeRouteOutlet.isNSEmptyOutlet;
100+
101+
// Lazy named outlet has added 'primary' inner NSEmptyOutlet child.
102+
// Take parent route when `relativeTo` option points to the outer named outlet.
103+
if (isNSEmptyOutlet && relativeRoute.outlet !== "primary") {
104+
relativeRoute = relativeRoute.parent || relativeRoute;
103105
}
104106

105-
for (let index = 0; index < relativeRoute.children.length; index++) {
106-
const currentRoute = relativeRoute.children[index];
107+
const routesToMatch = outlets ? relativeRoute.children : [relativeRoute];
108+
outlets = outlets || [relativeRoute.outlet];
107109

110+
for (let index = 0; index < routesToMatch.length; index++) {
111+
const currentRoute = routesToMatch[index];
108112
if (outlets.some(currentOutlet => currentOutlet === currentRoute.outlet)) {
109-
const currentRouteSnapshop = findTopActivatedRouteNodeForOutlet(currentRoute.snapshot);
110-
const outletKey = this.locationStrategy.getRouteFullPath(currentRouteSnapshop);
111-
let outlet = this.locationStrategy.findOutletByKey(outletKey);
113+
const outlet = this.findOutletByRoute(currentRoute);
112114

113115
if (outlet) {
114116
outletsToBack.push(outlet);
@@ -118,4 +120,14 @@ export class RouterExtensions {
118120

119121
return { outletsToBack: outletsToBack, outlets: outlets };
120122
}
123+
124+
private findOutletByRoute(currentRoute: ActivatedRoute): Outlet {
125+
let outlet;
126+
127+
const currentRouteSnapshop = findTopActivatedRouteNodeForOutlet(currentRoute.snapshot);
128+
const outletKey = this.locationStrategy.getRouteFullPath(currentRouteSnapshop);
129+
outlet = this.locationStrategy.findOutletByKey(outletKey);
130+
131+
return outlet;
132+
}
121133
}

0 commit comments

Comments
 (0)