Use Diffy as avatar for the Gerrit server itself

Display Diffy as avatar for comments on changes that were created
by the Gerrit server, e.g. for the comment that is created if a change
needs to be rebased due to a path conflict.

Change-Id: I9bdd2e356fa1562ac1a20c4c9d17a557094d9018
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-04-25 08:48:54 +02:00
parent b60e909257
commit 920d7c7dd4
3 changed files with 15 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.client;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
@@ -56,7 +57,8 @@ public class AvatarImage extends Image {
* avatar image
*/
public AvatarImage(AccountInfo account, int size, boolean addPopup) {
super(url(account.email(), size));
super(isGerritServer(account) ? getGerritServerAvatarUrl() :
url(account.email(), size));
if (size > 0) {
// If the provider does not resize the image, force it in the browser.
@@ -80,6 +82,15 @@ public class AvatarImage extends Image {
}
}
private static boolean isGerritServer(AccountInfo account) {
return account._account_id() == 0
&& Util.C.messageNoAuthor().equals(account.name());
}
private static String getGerritServerAvatarUrl() {
return Gerrit.RESOURCES.gerritAvatar().getSafeUri().asString();
}
private static String url(String email, int size) {
if (email == null) {
return "";