Merge "Fix link generation in gr-repo-dashboards"

This commit is contained in:
viktard 2018-04-25 18:11:39 +00:00 committed by Gerrit Code Review
commit 8b27c4e0b5
4 changed files with 20 additions and 7 deletions

View File

@ -53,7 +53,7 @@ limitations under the License.
</tr>
<template is="dom-repeat" items="[[item.dashboards]]">
<tr class="table">
<td class="name"><a href$="[[_getUrl(item.url)]]">[[item.path]]</a></td>
<td class="name"><a href$="[[_getUrl(item.project, item.sections)]]">[[item.path]]</a></td>
<td class="title">[[item.title]]</td>
<td class="desc">[[item.description]]</td>
<td class="inherited">[[_computeInheritedFrom(item.project, item.defining_project)]]</td>

View File

@ -68,10 +68,10 @@
});
},
_getUrl(url) {
if (!url) { return ''; }
_getUrl(project, sections) {
if (!project || !sections) { return ''; }
return Gerrit.Nav.navigateToRelativeUrl(url);
return Gerrit.Nav.getUrlForCustomDashboard(project, sections);
},
_computeLoadingClass(loading) {

View File

@ -245,12 +245,12 @@ limitations under the License.
suite('test url', () => {
test('_getUrl', () => {
sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl',
sandbox.stub(Gerrit.Nav, 'getUrlForCustomDashboard',
() => '/r/dashboard/test');
assert.equal(element._getUrl('/dashboard/test'), '/r/dashboard/test');
assert.equal(element._getUrl('/dashboard/test', {}), '/r/dashboard/test');
assert.equal(element._getUrl(undefined), '');
assert.equal(element._getUrl(undefined, undefined), '');
});
});

View File

@ -404,6 +404,19 @@ limitations under the License.
});
},
/**
* @param {string} repo The name of the repo.
* @param {!Array} sections The sections to display in the dashboard
* @return {string}
*/
getUrlForCustomDashboard(repo, sections) {
return this._getUrlFor({
repo,
view: Gerrit.Nav.View.DASHBOARD,
sections,
});
},
/**
* Navigate to an arbitrary relative URL.
* @param {string} relativeUrl