Respect internalHost in dashboard project column
Change-Id: I2461f7e130614cbefac9d957cceb5fe2f6f850b9
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 332121f..7eb2b6c 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
@@ -172,10 +172,13 @@
<td class="cell project"
hidden$="[[isColumnHidden('Project', visibleChangeTableColumns)]]">
<a class="fullProject" href$="[[_computeProjectURL(change)]]">
- [[change.project]]
+ [[_computeProjectDisplay(change)]]
</a>
- <a class="truncatedProject" href$="[[_computeProjectURL(change)]]">
- [[_computeTruncatedProject(change.project)]]
+ <a
+ class="truncatedProject"
+ href$="[[_computeProjectURL(change)]]"
+ title$="[[_computeProjectDisplay(change)]]">
+ [[_computeProjectDisplay(change, 'true')]]
</a>
</td>
<td class="cell branch"
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 53cc990..b73a237 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
@@ -137,9 +137,21 @@
return Gerrit.Nav.getUrlForTopic(change.topic, change.internalHost);
},
- _computeTruncatedProject(project) {
- if (!project) { return ''; }
- return this.truncatePath(project, 2);
+ /**
+ * Computes the display string for the project column. If there is a host
+ * specified in the change detail, the string will be prefixed with it.
+ *
+ * @param {!Object} change
+ * @param {string=} truncate whether or not the project name should be
+ * truncated. If this value is truthy, the name will be truncated.
+ * @return {string}
+ */
+ _computeProjectDisplay(change, truncate) {
+ if (!change || !change.project) { return ''; }
+ let str = '';
+ if (change.internalHost) { str += change.internalHost + '/'; }
+ str += truncate ? this.truncatePath(change.project, 2) : change.project;
+ return str;
},
_computeAccountStatusString(account) {
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 4fa6ff5..f4c66c7 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
@@ -273,5 +273,19 @@
assert.deepEqual(Gerrit.Nav.getUrlForTopic.lastCall.args,
[change.topic, change.internalHost]);
});
+
+ test('_computeProjectDisplay', () => {
+ const change = {
+ project: 'a/test/repo',
+ internalHost: 'host',
+ };
+ assert.equal(element._computeProjectDisplay(change), 'host/a/test/repo');
+ assert.equal(element._computeProjectDisplay(change, true),
+ 'host/…/test/repo');
+ delete change.internalHost;
+ assert.equal(element._computeProjectDisplay(change), 'a/test/repo');
+ assert.equal(element._computeProjectDisplay(change, true),
+ '…/test/repo');
+ });
});
</script>