Only show assignee highlight on open changes The yellow background on changes assigned to the current user is intended to aid in prioritizing what changes need attention, but changes that are closed (merged or abandoned) do not need further attention. Do not show the highlight on these changes. Also correct an issue where the account was not set in change-lists used by the change-list-view, resulting in the highlight never appearing in search results. Bug: Issue 8476 Change-Id: I93e61f4c98e9a199f94689b611545de484799051
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html index 268b678..1a9099d 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html +++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
@@ -46,7 +46,7 @@ :host([needs-review]) { font-family: var(--font-family-bold); } - :host([assigned]) { + :host([highlight]) { background-color: #fcfad6; } .container {
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html index f2c7a48..ec0e5a2 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html +++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html
@@ -73,12 +73,13 @@ <gr-user-header user-id="[[_userId]]" show-dashboard-link - logged-in="[[loggedIn]]" + logged-in="[[_loggedIn]]" class$="[[_computeUserHeaderClass(_userId)]]"></gr-user-header> <gr-change-list + account="[[account]]" changes="{{_changes}}" selected-index="{{viewState.selectedChangeIndex}}" - show-star="[[loggedIn]]"></gr-change-list> + show-star="[[_loggedIn]]"></gr-change-list> <nav class$="[[_computeNavClass(_loading)]]"> Page [[_computePage(_offset, _changesPerPage)]] <a id="prevArrow"
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js index 890713a..f5de254 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js +++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js
@@ -49,9 +49,14 @@ /** * True when user is logged in. */ - loggedIn: { + _loggedIn: { type: Boolean, - value: false, + computed: '_computeLoggedIn(account)', + }, + + account: { + type: Object, + value: null, }, /** @@ -220,5 +225,9 @@ _computePage(offset, changesPerPage) { return offset / changesPerPage + 1; }, + + _computeLoggedIn(account) { + return !!(account && Object.keys(account).length > 0); + }, }); })();
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html index 5e8a957..ec8ab2d 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html +++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
@@ -80,7 +80,7 @@ <template is="dom-repeat" items="[[changeSection.results]]" as="change"> <gr-change-list-item selected$="[[_computeItemSelected(sectionIndex, index, selectedIndex)]]" - assigned$="[[_computeItemAssigned(account, change)]]" + highlight$="[[_computeItemHighlight(account, change)]]" needs-review$="[[_computeItemNeedsReview(account, change, showReviewedState)]]" change="[[change]]" visible-change-table-columns="[[visibleChangeTableColumns]]"
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js index f66d8c8..c098ef6 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js +++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
@@ -16,6 +16,8 @@ const NUMBER_FIXED_COLUMNS = 3; + const CLOSED_STATUS = ['MERGED', 'ABANDONED']; + Polymer({ is: 'gr-change-list', @@ -228,8 +230,12 @@ account._account_id != change.owner._account_id; }, - _computeItemAssigned(account, change) { - if (!change.assignee) { return false; } + _computeItemHighlight(account, change) { + // Do not show the assignee highlight if the change is not open. + if (!change.assignee || + CLOSED_STATUS.indexOf(change.status) !== -1) { + return false; + } return account._account_id === change.assignee._account_id; },
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html index 7b9fadf..8c37d25 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html +++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
@@ -450,7 +450,7 @@ 'Should navigate to /c/4/'); }); - test('assigned attribute set in each item', () => { + test('highlight attribute is updated correctly', () => { element.changes = [ { _number: 0, @@ -465,12 +465,20 @@ ]; element.account = {_account_id: 42}; flushAsynchronousOperations(); - const items = element._getListItems(); + let items = element._getListItems(); assert.equal(items.length, 2); - for (let i = 0; i < items.length; i++) { - assert.equal(items[i].hasAttribute('assigned'), - items[i]._account_id === element.account._account_id); - } + assert.isFalse(items[0].hasAttribute('highlight')); + assert.isFalse(items[1].hasAttribute('highlight')); + + // Assign all issues to the user, but only the first one is highlighted + // because the second one is abandoned. + element.set(['changes', 0, 'assignee'], {_account_id: 12}); + element.set(['changes', 1, 'assignee'], {_account_id: 12}); + element.account = {_account_id: 12}; + flushAsynchronousOperations(); + items = element._getListItems(); + assert.isTrue(items[0].hasAttribute('highlight')); + assert.isFalse(items[1].hasAttribute('highlight')); }); test('_computeItemAbsoluteIndex', () => {