New review UI: Fix display of large avatar image in user popup panel

Hovering with the mouse over an avatar image opens a user popup panel
that shows additional information for this user. Beside the name and
the email address it is supposed to show a larger version of the
avatar image. This is important since the avatar images in the new
review UI (new change screen + new side-by-side diff screen) are very
tiny and the persons are difficult to recognize (note that currently
there are no user popups for the avatar images that are displayed for
reviewers and approvals, but only for change messages and inline
comments).

The avatar image in its default size is included in AccountInfo, but
if a different size was requested it didn't load the image from the
server. The problem was likely introduced by commit
edb9d2275c.

On the old review UI this works properly, so it's a regression with
the new review UI.

Change-Id: Iafa23377aa115ad4dfbe6c0fcd939bcf75b857f7
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2014-05-19 16:23:14 +02:00
parent 15c4bfa7e8
commit f712cdb27c

View File

@@ -80,27 +80,33 @@ public class AvatarImage extends Image implements LoadHandler {
setHeight(info.height() > 0 ? info.height() + "px" : "");
setUrl(info.url());
popup(account, addPopup);
} else if (account.email() != null) {
loadAvatar(account, size, addPopup);
}
} else if (account.email() != null) {
// TODO Kill /accounts/*/avatar URL.
String u = account.email();
if (Gerrit.isSignedIn()
&& u.equals(Gerrit.getUserAccount().getPreferredEmail())) {
u = "self";
}
RestApi api = new RestApi("/accounts/").id(u).view("avatar");
if (size > 0) {
api.addParameter("s", size);
setSize("", size + "px");
}
setVisible(false);
setUrl(api.url());
popup(account, addPopup);
loadAvatar(account, size, addPopup);
} else {
setVisible(false);
}
}
private void loadAvatar(AccountInfo account, int size, boolean addPopup) {
// TODO Kill /accounts/*/avatar URL.
String u = account.email();
if (Gerrit.isSignedIn()
&& u.equals(Gerrit.getUserAccount().getPreferredEmail())) {
u = "self";
}
RestApi api = new RestApi("/accounts/").id(u).view("avatar");
if (size > 0) {
api.addParameter("s", size);
setSize("", size + "px");
}
setVisible(false);
setUrl(api.url());
popup(account, addPopup);
}
private void popup(AccountInfo account, boolean addPopup) {
if (addPopup) {
PopupHandler popupHandler = new PopupHandler(account, this);