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>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/AvatarImage.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/AvatarImage.java index 873ab4d..0cfd05f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/AvatarImage.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/AvatarImage.java
@@ -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 @@ * 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 @@ } } + 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 "";
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java index fc7ea53..d3f47c0 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java
@@ -51,4 +51,7 @@ @Source("addFileComment.png") public ImageResource addFileComment(); + + @Source("diffy.png") + public ImageResource gerritAvatar(); }
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diffy.png b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diffy.png new file mode 100644 index 0000000..4be4541 --- /dev/null +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diffy.png Binary files differ