Handle unauthenticated users in when computing change list highlight
In I93e61f4c98, the `_computeItemHighlight` method was changed in a way
that didn't account for unauthenticated users. Update the method to
handle this scenario and add a test.
The dashboard view is updated to set null accounts more consistently
with the change list view.
Change-Id: Id33808505ffb6c3f722a963d8e27dd8dba112dec
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 c098ef6..3489db0 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
@@ -44,7 +44,7 @@
*/
account: {
type: Object,
- value() { return {}; },
+ value: null,
},
/**
* An array of ChangeInfo objects to render.
@@ -227,12 +227,13 @@
_computeItemNeedsReview(account, change, showReviewedState) {
return showReviewedState && !change.reviewed &&
this.changeIsOpen(change.status) &&
- account._account_id != change.owner._account_id;
+ (!account || account._account_id != change.owner._account_id);
},
_computeItemHighlight(account, change) {
// Do not show the assignee highlight if the change is not open.
if (!change.assignee ||
+ !account ||
CLOSED_STATUS.indexOf(change.status) !== -1) {
return false;
}
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 8c37d25..aed48e3 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
@@ -481,6 +481,11 @@
assert.isFalse(items[1].hasAttribute('highlight'));
});
+ test('_computeItemHighlight gives false for null account', () => {
+ assert.isFalse(
+ element._computeItemHighlight(null, {assignee: {_account_id: 42}}));
+ });
+
test('_computeItemAbsoluteIndex', () => {
sandbox.stub(element, '_computeLabelNames');
element.sections = [
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
index 7c04c1f..cce291b 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
@@ -72,7 +72,7 @@
properties: {
account: {
type: Object,
- value() { return {}; },
+ value: null,
},
/** @type {{ selectedChangeIndex: number }} */
viewState: Object,