Link accounts to their dashboards

Account links now go to /dashboard/NAME, where NAME is the account's
email address (or username or account ID as fallbacks).

Change-Id: Ib51c40eb8764e22570e002def6c4a72adfbcffa2
This commit is contained in:
Logan Hanks 2017-08-11 14:41:57 -07:00
parent 9ccf9d023b
commit e6458a2d27
5 changed files with 22 additions and 5 deletions

View File

@ -88,8 +88,11 @@
);
},
attached() {
this.fire('title-change', {title: 'My Reviews'});
_computeTitle(user) {
if (user === 'self') {
return 'My Reviews';
}
return 'Dashboard for ' + user;
},
/**
@ -97,6 +100,12 @@
*/
_userChanged(user) {
if (!user) { return; }
// NOTE: This method may be called before attachment. Fire title-change
// in an async so that attachment to the DOM can take place first.
this.async(
() => this.fire('title-change', {title: this._computeTitle(user)}));
this._loading = true;
const sections = this._sectionMetadata.filter(
section => (user === 'self' || !section.selfOnly));

View File

@ -91,5 +91,10 @@ limitations under the License.
{query, suffixForDashboard}, 'user'),
'query for user suffix for user');
});
test('_computeTitle', () => {
assert.equal(element._computeTitle('self'), 'My Reviews');
assert.equal(element._computeTitle('not self'), 'Dashboard for not self');
});
});
</script>

View File

@ -258,8 +258,8 @@ limitations under the License.
*/
getUrlForOwner(owner) {
return this._getUrlFor({
view: Gerrit.Nav.View.SEARCH,
owner,
view: Gerrit.Nav.View.DASHBOARD,
user: owner,
});
},

View File

@ -108,6 +108,8 @@
} else {
url = `/c/${params.changeNum}${range}`;
}
} else if (params.view === Gerrit.Nav.View.DASHBOARD) {
url = `/dashboard/${params.user || 'self'}`;
} else if (params.view === Gerrit.Nav.View.DIFF) {
let range = this._getPatchRangeExpression(params);
if (range.length) { range = '/' + range; }

View File

@ -31,7 +31,8 @@
_computeOwnerLink(account) {
if (!account) { return; }
return Gerrit.Nav.getUrlForOwner(account.email || account._account_id);
return Gerrit.Nav.getUrlForOwner(
account.email || account.username || account._account_id);
},
_computeShowEmail(account) {