Respect internalHost in dashboard project column
Change-Id: I2461f7e130614cbefac9d957cceb5fe2f6f850b9
This commit is contained in:
@@ -172,10 +172,13 @@ limitations under the License.
|
||||
<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"
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -273,5 +273,19 @@ limitations under the License.
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user