Merge changes I325d2062,I6efb64c4,Ic911d307
* changes: Don't display user header above project dashboards Support any dashboard ref, not just "custom" Link to project dashboards instead of custom
This commit is contained in:
@@ -53,7 +53,7 @@ limitations under the License.
|
|||||||
</tr>
|
</tr>
|
||||||
<template is="dom-repeat" items="[[item.dashboards]]">
|
<template is="dom-repeat" items="[[item.dashboards]]">
|
||||||
<tr class="table">
|
<tr class="table">
|
||||||
<td class="name"><a href$="[[_getUrl(item.project, item.sections)]]">[[item.path]]</a></td>
|
<td class="name"><a href$="[[_getUrl(item.project, item.id)]]">[[item.path]]</a></td>
|
||||||
<td class="title">[[item.title]]</td>
|
<td class="title">[[item.title]]</td>
|
||||||
<td class="desc">[[item.description]]</td>
|
<td class="desc">[[item.description]]</td>
|
||||||
<td class="inherited">[[_computeInheritedFrom(item.project, item.defining_project)]]</td>
|
<td class="inherited">[[_computeInheritedFrom(item.project, item.defining_project)]]</td>
|
||||||
|
@@ -43,24 +43,24 @@
|
|||||||
this.$.restAPI.getRepoDashboards(this.repo, errFn).then(res => {
|
this.$.restAPI.getRepoDashboards(this.repo, errFn).then(res => {
|
||||||
if (!res) { return Promise.resolve(); }
|
if (!res) { return Promise.resolve(); }
|
||||||
|
|
||||||
// Flatten 2 dimenional array, and sort by id.
|
// Group by ref and sort by id.
|
||||||
const dashboards = res.concat.apply([], res).sort((a, b) =>
|
const dashboards = res.concat.apply([], res).sort((a, b) =>
|
||||||
a.id > b.id);
|
a.id < b.id ? -1 : 1);
|
||||||
const customList = dashboards.filter(a => a.ref === 'custom');
|
const dashboardsByRef = {};
|
||||||
const defaultList = dashboards.filter(a => a.ref === 'default');
|
dashboards.forEach(d => {
|
||||||
|
if (!dashboardsByRef[d.ref]) {
|
||||||
|
dashboardsByRef[d.ref] = [];
|
||||||
|
}
|
||||||
|
dashboardsByRef[d.ref].push(d);
|
||||||
|
});
|
||||||
|
|
||||||
const dashboardBuilder = [];
|
const dashboardBuilder = [];
|
||||||
if (customList.length) {
|
Object.keys(dashboardsByRef).sort().forEach(ref => {
|
||||||
dashboardBuilder.push({
|
dashboardBuilder.push({
|
||||||
section: 'Custom',
|
section: ref,
|
||||||
dashboards: customList,
|
dashboards: dashboardsByRef[ref],
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
if (defaultList.length) {
|
|
||||||
dashboardBuilder.push({
|
|
||||||
section: 'Default',
|
|
||||||
dashboards: defaultList,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this._dashboards = dashboardBuilder;
|
this._dashboards = dashboardBuilder;
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
@@ -68,10 +68,10 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_getUrl(project, sections) {
|
_getUrl(project, id) {
|
||||||
if (!project || !sections) { return ''; }
|
if (!project || !id) { return ''; }
|
||||||
|
|
||||||
return Gerrit.Nav.getUrlForCustomDashboard(project, sections);
|
return Gerrit.Nav.getUrlForRepoDashboard(project, id);
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeLoadingClass(loading) {
|
_computeLoadingClass(loading) {
|
||||||
|
@@ -46,54 +46,61 @@ limitations under the License.
|
|||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
suite('with default only', () => {
|
suite('dashboard table', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoDashboards').returns(
|
sandbox.stub(element.$.restAPI, 'getRepoDashboards').returns(
|
||||||
Promise.resolve([
|
Promise.resolve([
|
||||||
[
|
{
|
||||||
{
|
id: 'default:contributor',
|
||||||
id: 'default:contributor',
|
project: 'gerrit',
|
||||||
project: 'gerrit',
|
defining_project: 'gerrit',
|
||||||
defining_project: 'gerrit',
|
ref: 'default',
|
||||||
ref: 'default',
|
path: 'contributor',
|
||||||
path: 'contributor',
|
description: 'Own contributions.',
|
||||||
description: 'Own contributions.',
|
foreach: 'owner:self',
|
||||||
foreach: 'owner:self',
|
url: '/dashboard/?params',
|
||||||
url: '/dashboard/?params',
|
title: 'Contributor Dashboard',
|
||||||
title: 'Contributor Dashboard',
|
sections: [
|
||||||
sections: [
|
{
|
||||||
{
|
name: 'Mine To Rebase',
|
||||||
name: 'Mine To Rebase',
|
query: 'is:open -is:mergeable',
|
||||||
query: 'is:open -is:mergeable',
|
},
|
||||||
},
|
{
|
||||||
{
|
name: 'My Recently Merged',
|
||||||
name: 'My Recently Merged',
|
query: 'is:merged limit:10',
|
||||||
query: 'is:merged limit:10',
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
],
|
id: 'custom:custom2',
|
||||||
[
|
project: 'gerrit',
|
||||||
{
|
defining_project: 'Public-Projects',
|
||||||
id: 'default:open',
|
ref: 'custom',
|
||||||
project: 'gerrit',
|
path: 'open',
|
||||||
defining_project: 'Public-Projects',
|
description: 'Recent open changes.',
|
||||||
ref: 'default',
|
url: '/dashboard/?params',
|
||||||
path: 'open',
|
title: 'Open Changes',
|
||||||
description: 'Recent open changes.',
|
sections: [
|
||||||
url: '/dashboard/?params',
|
{
|
||||||
title: 'Open Changes',
|
name: 'Open Changes',
|
||||||
sections: [
|
query: 'status:open project:${project} -age:7w',
|
||||||
{
|
},
|
||||||
name: 'Open Changes',
|
],
|
||||||
query: 'status:open project:${project} -age:7w',
|
},
|
||||||
},
|
{
|
||||||
],
|
id: 'default:abc',
|
||||||
},
|
project: 'gerrit',
|
||||||
],
|
ref: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'custom:custom1',
|
||||||
|
project: 'gerrit',
|
||||||
|
ref: 'custom',
|
||||||
|
},
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
test('loading', done => {
|
|
||||||
|
test('loading, sections, and ordering', done => {
|
||||||
assert.isTrue(element._loading);
|
assert.isTrue(element._loading);
|
||||||
assert.notEqual(getComputedStyle(element.$.loadingContainer).display,
|
assert.notEqual(getComputedStyle(element.$.loadingContainer).display,
|
||||||
'none');
|
'none');
|
||||||
@@ -101,143 +108,20 @@ limitations under the License.
|
|||||||
'none');
|
'none');
|
||||||
element.repo = 'test';
|
element.repo = 'test';
|
||||||
flush(() => {
|
flush(() => {
|
||||||
assert.equal(element._dashboards.length, 1);
|
|
||||||
assert.equal(element._dashboards[0].section, 'Default');
|
|
||||||
assert.equal(element._dashboards[0].dashboards.length, 2);
|
|
||||||
assert.equal(getComputedStyle(element.$.loadingContainer).display,
|
assert.equal(getComputedStyle(element.$.loadingContainer).display,
|
||||||
'none');
|
'none');
|
||||||
assert.notEqual(getComputedStyle(element.$.dashboards).display,
|
assert.notEqual(getComputedStyle(element.$.dashboards).display,
|
||||||
'none');
|
'none');
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('dispatched command-tap on button tap', done => {
|
|
||||||
element.repo = 'test';
|
|
||||||
flush(() => {
|
|
||||||
assert.equal(element._dashboards.length, 1);
|
|
||||||
assert.equal(element._dashboards[0].section, 'Default');
|
|
||||||
assert.equal(element._dashboards[0].dashboards.length, 2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite('with custom only', () => {
|
|
||||||
setup(() => {
|
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoDashboards').returns(
|
|
||||||
Promise.resolve([
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'custom:custom1',
|
|
||||||
project: 'gerrit',
|
|
||||||
defining_project: 'gerrit',
|
|
||||||
ref: 'custom',
|
|
||||||
path: 'contributor',
|
|
||||||
description: 'Own contributions.',
|
|
||||||
foreach: 'owner:self',
|
|
||||||
url: '/dashboard/?params',
|
|
||||||
title: 'Contributor Dashboard',
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
name: 'Mine To Rebase',
|
|
||||||
query: 'is:open -is:mergeable',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'My Recently Merged',
|
|
||||||
query: 'is:merged limit:10',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'custom:custom2',
|
|
||||||
project: 'gerrit',
|
|
||||||
defining_project: 'Public-Projects',
|
|
||||||
ref: 'custom',
|
|
||||||
path: 'open',
|
|
||||||
description: 'Recent open changes.',
|
|
||||||
url: '/dashboard/?params',
|
|
||||||
title: 'Open Changes',
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
name: 'Open Changes',
|
|
||||||
query: 'status:open project:${project} -age:7w',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('dispatched command-tap on button tap', done => {
|
|
||||||
element.repo = 'test';
|
|
||||||
flush(() => {
|
|
||||||
assert.equal(element._dashboards.length, 1);
|
|
||||||
assert.equal(element._dashboards[0].section, 'Custom');
|
|
||||||
assert.equal(element._dashboards[0].dashboards.length, 2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite('with custom and default', () => {
|
|
||||||
setup(() => {
|
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoDashboards').returns(
|
|
||||||
Promise.resolve([
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'default:contributor',
|
|
||||||
project: 'gerrit',
|
|
||||||
defining_project: 'gerrit',
|
|
||||||
ref: 'default',
|
|
||||||
path: 'contributor',
|
|
||||||
description: 'Own contributions.',
|
|
||||||
foreach: 'owner:self',
|
|
||||||
url: '/dashboard/?params',
|
|
||||||
title: 'Contributor Dashboard',
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
name: 'Mine To Rebase',
|
|
||||||
query: 'is:open -is:mergeable',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'My Recently Merged',
|
|
||||||
query: 'is:merged limit:10',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'custom:custom2',
|
|
||||||
project: 'gerrit',
|
|
||||||
defining_project: 'Public-Projects',
|
|
||||||
ref: 'custom',
|
|
||||||
path: 'open',
|
|
||||||
description: 'Recent open changes.',
|
|
||||||
url: '/dashboard/?params',
|
|
||||||
title: 'Open Changes',
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
name: 'Open Changes',
|
|
||||||
query: 'status:open project:${project} -age:7w',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('dispatched command-tap on button tap', done => {
|
|
||||||
element.repo = 'test';
|
|
||||||
flush(() => {
|
|
||||||
assert.equal(element._dashboards.length, 2);
|
assert.equal(element._dashboards.length, 2);
|
||||||
assert.equal(element._dashboards[0].section, 'Custom');
|
assert.equal(element._dashboards[0].section, 'custom');
|
||||||
assert.equal(element._dashboards[1].section, 'Default');
|
assert.equal(element._dashboards[1].section, 'default');
|
||||||
assert.equal(element._dashboards[0].dashboards.length, 1);
|
|
||||||
assert.equal(element._dashboards[1].dashboards.length, 1);
|
const dashboards = element._dashboards[0].dashboards;
|
||||||
|
assert.equal(dashboards.length, 2);
|
||||||
|
assert.equal(dashboards[0].id, 'custom:custom1');
|
||||||
|
assert.equal(dashboards[1].id, 'custom:custom2');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -245,7 +129,7 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('test url', () => {
|
suite('test url', () => {
|
||||||
test('_getUrl', () => {
|
test('_getUrl', () => {
|
||||||
sandbox.stub(Gerrit.Nav, 'getUrlForCustomDashboard',
|
sandbox.stub(Gerrit.Nav, 'getUrlForRepoDashboard',
|
||||||
() => '/r/dashboard/test');
|
() => '/r/dashboard/test');
|
||||||
|
|
||||||
assert.equal(element._getUrl('/dashboard/test', {}), '/r/dashboard/test');
|
assert.equal(element._getUrl('/dashboard/test', {}), '/r/dashboard/test');
|
||||||
|
@@ -87,7 +87,7 @@ limitations under the License.
|
|||||||
<div hidden$="[[_loading]]" hidden>
|
<div hidden$="[[_loading]]" hidden>
|
||||||
<gr-user-header
|
<gr-user-header
|
||||||
user-id="[[params.user]]"
|
user-id="[[params.user]]"
|
||||||
class$="[[_computeUserHeaderClass(params.user)]]"></gr-user-header>
|
class$="[[_computeUserHeaderClass(params)]]"></gr-user-header>
|
||||||
<gr-change-list
|
<gr-change-list
|
||||||
show-star
|
show-star
|
||||||
show-reviewed-state
|
show-reviewed-state
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
/** @type {{ selectedChangeIndex: number }} */
|
/** @type {{ selectedChangeIndex: number }} */
|
||||||
viewState: Object,
|
viewState: Object,
|
||||||
|
|
||||||
/** @type {{ user: string }} */
|
/** @type {{ project: string, user: string }} */
|
||||||
params: {
|
params: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
@@ -217,8 +217,12 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeUserHeaderClass(userParam) {
|
_computeUserHeaderClass(params) {
|
||||||
return userParam === 'self' ? 'hide' : '';
|
if (!params || !!params.project || !params.user
|
||||||
|
|| params.user === 'self') {
|
||||||
|
return 'hide';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleToggleStar(e) {
|
_handleToggleStar(e) {
|
||||||
|
@@ -314,10 +314,13 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_computeUserHeaderClass', () => {
|
test('_computeUserHeaderClass', () => {
|
||||||
assert.equal(element._computeUserHeaderClass(undefined), '');
|
assert.equal(element._computeUserHeaderClass(undefined), 'hide');
|
||||||
assert.equal(element._computeUserHeaderClass(''), '');
|
assert.equal(element._computeUserHeaderClass({}), 'hide');
|
||||||
assert.equal(element._computeUserHeaderClass('self'), 'hide');
|
assert.equal(element._computeUserHeaderClass({user: 'self'}), 'hide');
|
||||||
assert.equal(element._computeUserHeaderClass('user'), '');
|
assert.equal(element._computeUserHeaderClass({user: 'user'}), '');
|
||||||
|
assert.equal(
|
||||||
|
element._computeUserHeaderClass({project: 'p', user: 'user'}),
|
||||||
|
'hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('404 page', done => {
|
test('404 page', done => {
|
||||||
|
@@ -522,14 +522,15 @@ limitations under the License.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} repo The name of the repo.
|
* @param {string} repo The name of the repo.
|
||||||
* @param {!Array} sections The sections to display in the dashboard
|
* @param {string} dashboard The ID of the dashboard, in the form of
|
||||||
|
* '<ref>:<path>'.
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
getUrlForCustomDashboard(repo, sections) {
|
getUrlForRepoDashboard(repo, dashboard) {
|
||||||
return this._getUrlFor({
|
return this._getUrlFor({
|
||||||
repo,
|
|
||||||
view: Gerrit.Nav.View.DASHBOARD,
|
view: Gerrit.Nav.View.DASHBOARD,
|
||||||
sections,
|
repo,
|
||||||
|
dashboard,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -427,7 +427,8 @@
|
|||||||
return `/dashboard/${user}?${queryParams.join('&')}`;
|
return `/dashboard/${user}?${queryParams.join('&')}`;
|
||||||
} else if (repoName) {
|
} else if (repoName) {
|
||||||
// Project dashboard.
|
// Project dashboard.
|
||||||
return `/p/${repoName}/+/dashboard/${params.dashboard}`;
|
const encodedRepo = this.encodeURL(repoName, true);
|
||||||
|
return `/p/${encodedRepo}/+/dashboard/${params.dashboard}`;
|
||||||
} else {
|
} else {
|
||||||
// User dashboard.
|
// User dashboard.
|
||||||
return `/dashboard/${params.user || 'self'}`;
|
return `/dashboard/${params.user || 'self'}`;
|
||||||
|
Reference in New Issue
Block a user