Merge "Fix link generation in gr-repo-dashboards"
This commit is contained in:
commit
8b27c4e0b5
@ -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>
|
||||
|
@ -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) {
|
||||
|
@ -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), '');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user