Merge "Fix dashboard not showing up for not-logged in user"
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
index ce3a811..0cf9357 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
@@ -219,7 +219,9 @@
)
);
- const checkForNewUser = !project && user === 'self';
+ // Checking `this.account` to make sure that the user is logged in.
+ // Otherwise sending a query for 'owner:self' will result in an error.
+ const checkForNewUser = !project && !!this.account && user === 'self';
return dashboardPromise
.then(res => {
if (res && res.title) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
index 44f203d..f788e74 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
@@ -21,6 +21,7 @@
import {GerritNav, GerritView} from '../../core/gr-navigation/gr-navigation.js';
import {changeIsOpen} from '../../../utils/change-util.js';
import {ChangeStatus} from '../../../constants/constants.js';
+import {createAccountWithId} from '../../../test/test-data-generators.js';
const basicFixture = fixtureFromElement('gr-dashboard-view');
@@ -201,9 +202,23 @@
user: 'self',
};
return paramsChangedPromise.then(() => {
- assert.isTrue(
- getChangesStub.calledWith(undefined,
- ['1', '2', 'owner:self limit:1']));
+ assert.isTrue(getChangesStub.calledWith(undefined, ['1', '2']));
+ });
+ });
+
+ test('viewing dashboard when logged in includes owner:self query', () => {
+ element.account = createAccountWithId(1);
+ element.params = {
+ view: GerritNav.View.DASHBOARD,
+ sections: [
+ {query: '1'},
+ {query: '2', selfOnly: true},
+ ],
+ user: 'self',
+ };
+ return paramsChangedPromise.then(() => {
+ assert.isTrue(getChangesStub.calledWith(undefined,
+ ['1', '2', 'owner:self limit:1']));
});
});