Refactor root navigation to generated URL
Change-Id: If969604814d3f2e859932f8a3bc26d14d22eac73
This commit is contained in:
@@ -961,9 +961,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_determinePageBack() {
|
_determinePageBack() {
|
||||||
// Default backPage to '/' if user came to change view page
|
// Default backPage to root if user came to change view page
|
||||||
// via an email link, etc.
|
// via an email link, etc.
|
||||||
Gerrit.Nav.navigateToRelativeUrl(this.backPage || '/');
|
Gerrit.Nav.navigateToRelativeUrl(this.backPage ||
|
||||||
|
Gerrit.Nav.getUrlForRoot());
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleLabelRemoved(splices, path) {
|
_handleLabelRemoved(splices, path) {
|
||||||
|
|||||||
@@ -89,12 +89,13 @@ limitations under the License.
|
|||||||
assert(starStub.called);
|
assert(starStub.called);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('U should navigate to / if no backPage set', () => {
|
test('U should navigate to root if no backPage set', () => {
|
||||||
const relativeNavStub = sandbox.stub(Gerrit.Nav,
|
const relativeNavStub = sandbox.stub(Gerrit.Nav,
|
||||||
'navigateToRelativeUrl');
|
'navigateToRelativeUrl');
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
|
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
|
||||||
assert.isTrue(relativeNavStub.called);
|
assert.isTrue(relativeNavStub.called);
|
||||||
assert.isTrue(relativeNavStub.lastCall.calledWithExactly('/'));
|
assert.isTrue(relativeNavStub.lastCall.calledWithExactly(
|
||||||
|
Gerrit.Nav.getUrlForRoot()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('U should navigate to backPage if set', () => {
|
test('U should navigate to backPage if set', () => {
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ limitations under the License.
|
|||||||
// - `repoName`, required, String: the name of the repo
|
// - `repoName`, required, String: the name of the repo
|
||||||
// - `detail`, optional, String: the name of the repo detail view.
|
// - `detail`, optional, String: the name of the repo detail view.
|
||||||
// Takes any value from Gerrit.Nav.RepoDetailView.
|
// Takes any value from Gerrit.Nav.RepoDetailView.
|
||||||
|
//
|
||||||
|
// - Gerrit.Nav.View.ROOT:
|
||||||
|
// - no possible parameters.
|
||||||
|
|
||||||
|
|
||||||
window.Gerrit = window.Gerrit || {};
|
window.Gerrit = window.Gerrit || {};
|
||||||
@@ -96,6 +99,7 @@ limitations under the License.
|
|||||||
GROUP: 'group',
|
GROUP: 'group',
|
||||||
PLUGIN_SCREEN: 'plugin-screen',
|
PLUGIN_SCREEN: 'plugin-screen',
|
||||||
REPO: 'repo',
|
REPO: 'repo',
|
||||||
|
ROOT: 'root',
|
||||||
SEARCH: 'search',
|
SEARCH: 'search',
|
||||||
SETTINGS: 'settings',
|
SETTINGS: 'settings',
|
||||||
},
|
},
|
||||||
@@ -411,6 +415,15 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getUrlForRoot() {
|
||||||
|
return this._getUrlFor({
|
||||||
|
view: Gerrit.Nav.View.ROOT,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} repo The name of the repo.
|
* @param {string} repo The name of the repo.
|
||||||
* @param {!Array} sections The sections to display in the dashboard
|
* @param {!Array} sections The sections to display in the dashboard
|
||||||
|
|||||||
@@ -248,6 +248,8 @@
|
|||||||
url = this._generateGroupUrl(params);
|
url = this._generateGroupUrl(params);
|
||||||
} else if (params.view === Views.REPO) {
|
} else if (params.view === Views.REPO) {
|
||||||
url = this._generateRepoUrl(params);
|
url = this._generateRepoUrl(params);
|
||||||
|
} else if (params.view === Views.ROOT) {
|
||||||
|
url = '/';
|
||||||
} else if (params.view === Views.SETTINGS) {
|
} else if (params.view === Views.SETTINGS) {
|
||||||
url = this._generateSettingsUrl(params);
|
url = this._generateSettingsUrl(params);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user