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() { _computeTitle(user) {
this.fire('title-change', {title: 'My Reviews'}); if (user === 'self') {
return 'My Reviews';
}
return 'Dashboard for ' + user;
}, },
/** /**
@@ -97,6 +100,12 @@
*/ */
_userChanged(user) { _userChanged(user) {
if (!user) { return; } 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; this._loading = true;
const sections = this._sectionMetadata.filter( const sections = this._sectionMetadata.filter(
section => (user === 'self' || !section.selfOnly)); section => (user === 'self' || !section.selfOnly));

View File

@@ -91,5 +91,10 @@ limitations under the License.
{query, suffixForDashboard}, 'user'), {query, suffixForDashboard}, 'user'),
'query for user suffix for 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> </script>

View File

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

View File

@@ -108,6 +108,8 @@
} else { } else {
url = `/c/${params.changeNum}${range}`; 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) { } else if (params.view === Gerrit.Nav.View.DIFF) {
let range = this._getPatchRangeExpression(params); let range = this._getPatchRangeExpression(params);
if (range.length) { range = '/' + range; } if (range.length) { range = '/' + range; }

View File

@@ -31,7 +31,8 @@
_computeOwnerLink(account) { _computeOwnerLink(account) {
if (!account) { return; } 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) { _computeShowEmail(account) {