Merge "Rely on params change to set _lastSearchPage"

This commit is contained in:
Kasper Nilsson
2018-04-14 17:30:51 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 7 deletions

View File

@@ -98,6 +98,7 @@
observers: [
'_viewChanged(params.view)',
'_paramsChanged(params.*)',
],
behaviors: [
@@ -227,15 +228,12 @@
pathname += '@' + hash;
}
this.set('_path', pathname);
this._handleSearchPageChange();
},
_handleSearchPageChange() {
if (!this.params) {
return;
}
_paramsChanged(paramsRecord) {
const params = paramsRecord.base;
const viewsToCheck = [Gerrit.Nav.View.SEARCH, Gerrit.Nav.View.DASHBOARD];
if (viewsToCheck.includes(this.params.view)) {
if (viewsToCheck.includes(params.view)) {
this.set('_lastSearchPage', location.pathname);
}
},

View File

@@ -55,6 +55,8 @@ limitations under the License.
});
},
getPreferences() { return Promise.resolve({my: []}); },
getDiffPreferences() { return Promise.resolve({}); },
getEditPreferences() { return Promise.resolve({}); },
getVersion() { return Promise.resolve(42); },
probePath() { return Promise.resolve(42); },
});
@@ -87,7 +89,6 @@ limitations under the License.
hash: '#2',
host: location.host,
};
sandbox.stub(element, '_handleSearchPageChange');
element._handleLocationChange({detail: curLocation});
flush(() => {
@@ -107,6 +108,13 @@ limitations under the License.
});
});
test('_paramsChanged sets search page', () => {
element._paramsChanged({base: {view: Gerrit.Nav.View.CHANGE}});
assert.notOk(element._lastSearchPage);
element._paramsChanged({base: {view: Gerrit.Nav.View.SEARCH}});
assert.ok(element._lastSearchPage);
});
suite('_jumpKeyPressed', () => {
let navStub;