Merge "Limit shown changes in user dashboard and show their count"

This commit is contained in:
Milutin Kristofic
2019-10-15 11:01:37 +00:00
committed by Gerrit Code Review
3 changed files with 43 additions and 2 deletions

View File

@@ -210,7 +210,7 @@
this._showNewUserHelp = lastResultSet.length == 0;
}
this._results = changes.map((results, i) => ({
name: res.sections[i].name,
name: this._computeSectionName(res.sections[i].name, results),
query: res.sections[i].query,
results,
isOutgoing: res.sections[i].isOutgoing,
@@ -220,6 +220,17 @@
});
},
_computeSectionName(name, changes) {
if (!changes || !changes.length || changes.length == 0) {
return name;
}
const more = changes[changes.length - 1]._more_changes;
const numChanges = changes.length;
const andMore = more ? ' and more' : '';
const changeLabel = `change${numChanges > 1 ? 's' : ''}`;
return `${name} (${numChanges} ${changeLabel}${andMore})`;
},
_computeUserHeaderClass(params) {
if (!params || !!params.project || !params.user
|| params.user === 'self') {

View File

@@ -149,6 +149,31 @@ limitations under the License.
assert.equal(element._computeTitle('not self'), 'Dashboard for not self');
});
suite('_computeSectionName', () => {
test('empty changes dont change name', () => {
const name = 'Work in progress';
assert.equal(name, element._computeSectionName(name, []));
});
test('1 change', () => {
const name = 'Work in progress';
assert.equal(name + ' (1 change)',
element._computeSectionName(name, ['1']));
});
test('2 changes', () => {
const name = 'Work in progress';
assert.equal(name + ' (2 changes)',
element._computeSectionName(name, ['1', '2']));
});
test('1 change and more', () => {
const name = 'Work in progress';
assert.equal(name + ' (1 change and more)',
element._computeSectionName(name, [{_more_changes: true}]));
});
});
suite('_isViewActive', () => {
test('nothing happens when user param is falsy', () => {
element.params = {};
@@ -280,7 +305,7 @@ limitations under the License.
return element._fetchDashboardChanges({sections}, false).then(() => {
assert.equal(element._results.length, 1);
assert.equal(element._results[0].name, 'test2');
assert.equal(element._results[0].name, 'test2 (1 change)');
});
});

View File

@@ -115,6 +115,7 @@ limitations under the License.
query: 'assignee:${user} (-is:wip OR owner:self OR assignee:self) ' +
'is:open -is:ignored',
hideIfEmpty: true,
suffixForDashboard: 'limit:25',
},
{
// WIP open changes owned by viewing user. This section is omitted when
@@ -123,6 +124,7 @@ limitations under the License.
query: 'is:open owner:${user} is:wip',
selfOnly: true,
hideIfEmpty: true,
suffixForDashboard: 'limit:25',
},
{
// Non-WIP open changes owned by viewed user. Filter out changes ignored
@@ -130,6 +132,7 @@ limitations under the License.
name: 'Outgoing reviews',
query: 'is:open owner:${user} -is:wip -is:ignored',
isOutgoing: true,
suffixForDashboard: 'limit:25',
},
{
// Non-WIP open changes not owned by the viewed user, that the viewed user
@@ -138,12 +141,14 @@ limitations under the License.
name: 'Incoming reviews',
query: 'is:open -owner:${user} -is:wip -is:ignored ' +
'(reviewer:${user} OR assignee:${user})',
suffixForDashboard: 'limit:25',
},
{
// Open changes the viewed user is CCed on. Changes ignored by the viewing
// user are filtered out.
name: 'CCed on',
query: 'is:open -is:ignored cc:${user}',
suffixForDashboard: 'limit:10',
},
{
name: 'Recently closed',