Add host to change list URL generation
Change-Id: I3628e307b6ea7ccd3fad38451af749f63bcc8b5e
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
index 6ea7cf3..332121f 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
@@ -171,10 +171,10 @@
</td>
<td class="cell project"
hidden$="[[isColumnHidden('Project', visibleChangeTableColumns)]]">
- <a class="fullProject" href$="[[_computeProjectURL(change.project)]]">
+ <a class="fullProject" href$="[[_computeProjectURL(change)]]">
[[change.project]]
</a>
- <a class="truncatedProject" href$="[[_computeProjectURL(change.project)]]">
+ <a class="truncatedProject" href$="[[_computeProjectURL(change)]]">
[[_computeTruncatedProject(change.project)]]
</a>
</td>
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
index 259580b..53cc990 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js
@@ -122,17 +122,19 @@
return '';
},
- _computeProjectURL(project) {
- return Gerrit.Nav.getUrlForProjectChanges(project, true);
+ _computeProjectURL(change) {
+ return Gerrit.Nav.getUrlForProjectChanges(change.project, true,
+ change.internalHost);
},
_computeProjectBranchURL(change) {
- return Gerrit.Nav.getUrlForBranch(change.branch, change.project);
+ return Gerrit.Nav.getUrlForBranch(change.branch, change.project, null,
+ change.internalHost);
},
_computeTopicURL(change) {
if (!change.topic) { return ''; }
- return Gerrit.Nav.getUrlForTopic(change.topic);
+ return Gerrit.Nav.getUrlForTopic(change.topic, change.internalHost);
},
_computeTruncatedProject(project) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
index 81e1034..4fa6ff5 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.html
@@ -37,8 +37,10 @@
<script>
suite('gr-change-list-item tests', () => {
let element;
+ let sandbox;
setup(() => {
+ sandbox = sinon.sandbox.create();
stub('gr-rest-api-interface', {
getConfig() { return Promise.resolve({}); },
getLoggedIn() { return Promise.resolve(false); },
@@ -46,6 +48,8 @@
element = fixture('basic');
});
+ teardown(() => { sandbox.restore(); });
+
test('computed fields', () => {
assert.equal(element._computeLabelClass({labels: {}}),
'cell label u-gray-background');
@@ -249,5 +253,25 @@
deletions: 999,
}), 'XL');
});
+
+ test('change params passed to gr-navigation', () => {
+ sandbox.stub(Gerrit.Nav);
+ const change = {
+ internalHost: 'test-host',
+ project: 'test-repo',
+ topic: 'test-topic',
+ branch: 'test-branch',
+ };
+ element.change = change;
+ flushAsynchronousOperations();
+
+ assert.deepEqual(Gerrit.Nav.getUrlForChange.lastCall.args, [change]);
+ assert.deepEqual(Gerrit.Nav.getUrlForProjectChanges.lastCall.args,
+ [change.project, true, change.internalHost]);
+ assert.deepEqual(Gerrit.Nav.getUrlForBranch.lastCall.args,
+ [change.branch, change.project, null, change.internalHost]);
+ assert.deepEqual(Gerrit.Nav.getUrlForTopic.lastCall.args,
+ [change.topic, change.internalHost]);
+ });
});
</script>
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
index e217b4b..dfe5410 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
@@ -177,13 +177,15 @@
* @param {!string} project The name of the project.
* @param {boolean=} opt_openOnly When true, only search open changes in
* the project.
+ * @param {string=} opt_host The host in which to search.
* @return {string}
*/
- getUrlForProjectChanges(project, opt_openOnly) {
+ getUrlForProjectChanges(project, opt_openOnly, opt_host) {
return this._getUrlFor({
view: Gerrit.Nav.View.SEARCH,
project,
statuses: opt_openOnly ? ['open'] : [],
+ host: opt_host,
});
},
@@ -191,26 +193,30 @@
* @param {string} branch The name of the branch.
* @param {string} project The name of the project.
* @param {string=} opt_status The status to search.
+ * @param {string=} opt_host The host in which to search.
* @return {string}
*/
- getUrlForBranch(branch, project, opt_status) {
+ getUrlForBranch(branch, project, opt_status, opt_host) {
return this._getUrlFor({
view: Gerrit.Nav.View.SEARCH,
branch,
project,
statuses: opt_status ? [opt_status] : undefined,
+ host: opt_host,
});
},
/**
* @param {string} topic The name of the topic.
+ * @param {string=} opt_host The host in which to search.
* @return {string}
*/
- getUrlForTopic(topic) {
+ getUrlForTopic(topic, opt_host) {
return this._getUrlFor({
view: Gerrit.Nav.View.SEARCH,
topic,
statuses: ['open', 'merged'],
+ host: opt_host,
});
},
@@ -267,6 +273,7 @@
patchNum: opt_patchNum,
basePatchNum: opt_basePatchNum,
edit: opt_isEdit,
+ host: change.internalHost || undefined,
});
},