Merge "Include in ServerInfo whether an avatar provider is registered"
This commit is contained in:
		| @@ -1284,6 +1284,18 @@ The maximal memory size. The value is returned with a unit abbreviation | ||||
| The number of open files. | ||||
| |============================ | ||||
|  | ||||
| [[plugin-config-info]] | ||||
| === PluginConfigInfo | ||||
| The `PluginConfigInfo` entity contains information about Gerrit | ||||
| extensions by plugins. | ||||
|  | ||||
| [options="header",cols="1,^1,5"] | ||||
| |=========================== | ||||
| |Field Name    ||Description | ||||
| |`has_avatars` |not set if `false`| | ||||
| Whether an avatar provider is registered. | ||||
| |=========================== | ||||
|  | ||||
| [[receive-info]] | ||||
| === ReceiveInfo | ||||
| The `ReceiveInfo` entity contains information about the configuration | ||||
| @@ -1326,7 +1338,9 @@ link:config-gerrit.html#gerrit[gerrit] section as link:#gerrit-info[ | ||||
| GerritInfo] entity. | ||||
| |`gitweb `                 |optional| | ||||
| Information about the link:config-gerrit.html#gitweb[gitweb] | ||||
| configuration as link:#git-web-info[GitwebInfo] entity. | ||||
| |`plugin `                 || | ||||
| Information about Gerrit extensions by plugins as | ||||
| link:#plugin-config-info[PluginConfigInfo] entity. | ||||
| |`receive`                 |optional| | ||||
| Information about the receive-pack configuration as a | ||||
| link:#receive-info[ReceiveInfo] entity. | ||||
|   | ||||
| @@ -91,6 +91,10 @@ public class AvatarImage extends Image implements LoadHandler { | ||||
|   } | ||||
|  | ||||
|   private void loadAvatar(AccountInfo account, int size, boolean addPopup) { | ||||
|     if (!Gerrit.info().plugin().hasAvatars()) { | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|      // TODO Kill /accounts/*/avatar URL. | ||||
|     String u = account.email(); | ||||
|     if (Gerrit.isSignedIn() | ||||
|   | ||||
| @@ -44,14 +44,16 @@ public class MyProfileScreen extends SettingsScreen { | ||||
|     HorizontalPanel h = new HorizontalPanel(); | ||||
|     add(h); | ||||
|  | ||||
|     VerticalPanel v = new VerticalPanel(); | ||||
|     v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel()); | ||||
|     h.add(v); | ||||
|     avatar = new AvatarImage(); | ||||
|     v.add(avatar); | ||||
|     changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank"); | ||||
|     changeAvatar.setVisible(false); | ||||
|     v.add(changeAvatar); | ||||
|     if (Gerrit.info().plugin().hasAvatars()) { | ||||
|       VerticalPanel v = new VerticalPanel(); | ||||
|       v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel()); | ||||
|       h.add(v); | ||||
|       avatar = new AvatarImage(); | ||||
|       v.add(avatar); | ||||
|       changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank"); | ||||
|       changeAvatar.setVisible(false); | ||||
|       v.add(changeAvatar); | ||||
|     } | ||||
|  | ||||
|     if (LocaleInfo.getCurrentLocale().isRTL()) { | ||||
|       labelIdx = 1; | ||||
| @@ -95,19 +97,21 @@ public class MyProfileScreen extends SettingsScreen { | ||||
|   } | ||||
|  | ||||
|   void display(final Account account) { | ||||
|     avatar.setAccount(FormatUtil.asInfo(account), 93, false); | ||||
|     new RestApi("/accounts/").id("self").view("avatar.change.url") | ||||
|         .get(new AsyncCallback<NativeString>() { | ||||
|           @Override | ||||
|           public void onSuccess(NativeString changeUrl) { | ||||
|             changeAvatar.setHref(changeUrl.asString()); | ||||
|             changeAvatar.setVisible(true); | ||||
|           } | ||||
|     if (Gerrit.info().plugin().hasAvatars()) { | ||||
|       avatar.setAccount(FormatUtil.asInfo(account), 93, false); | ||||
|       new RestApi("/accounts/").id("self").view("avatar.change.url") | ||||
|           .get(new AsyncCallback<NativeString>() { | ||||
|             @Override | ||||
|             public void onSuccess(NativeString changeUrl) { | ||||
|               changeAvatar.setHref(changeUrl.asString()); | ||||
|               changeAvatar.setVisible(true); | ||||
|             } | ||||
|  | ||||
|           @Override | ||||
|           public void onFailure(Throwable caught) { | ||||
|           } | ||||
|         }); | ||||
|             @Override | ||||
|             public void onFailure(Throwable caught) { | ||||
|             } | ||||
|           }); | ||||
|     } | ||||
|  | ||||
|     int row = 0; | ||||
|     if (Gerrit.info().auth().siteHasUsernames()) { | ||||
|   | ||||
| @@ -23,6 +23,7 @@ public class ServerInfo extends JavaScriptObject { | ||||
|   public final native DownloadInfo download() /*-{ return this.download; }-*/; | ||||
|   public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/; | ||||
|   public final native GitwebInfo gitweb() /*-{ return this.gitweb; }-*/; | ||||
|   public final native PluginConfigInfo plugin() /*-{ return this.plugin; }-*/; | ||||
|   public final native SshdInfo sshd() /*-{ return this.sshd; }-*/; | ||||
|   public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/; | ||||
|   public final native UserConfigInfo user() /*-{ return this.user; }-*/; | ||||
| @@ -59,6 +60,13 @@ public class ServerInfo extends JavaScriptObject { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public static class PluginConfigInfo extends JavaScriptObject { | ||||
|     public final native boolean hasAvatars() /*-{ return this.has_avatars || false; }-*/; | ||||
|  | ||||
|     protected PluginConfigInfo() { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public static class SshdInfo extends JavaScriptObject { | ||||
|     protected SshdInfo() { | ||||
|     } | ||||
|   | ||||
| @@ -24,11 +24,13 @@ import com.google.gerrit.common.data.GitwebType; | ||||
| import com.google.gerrit.extensions.config.CloneCommand; | ||||
| import com.google.gerrit.extensions.config.DownloadCommand; | ||||
| import com.google.gerrit.extensions.config.DownloadScheme; | ||||
| import com.google.gerrit.extensions.registration.DynamicItem; | ||||
| import com.google.gerrit.extensions.registration.DynamicMap; | ||||
| import com.google.gerrit.extensions.restapi.RestReadView; | ||||
| import com.google.gerrit.reviewdb.client.Account; | ||||
| import com.google.gerrit.reviewdb.client.AuthType; | ||||
| import com.google.gerrit.server.account.Realm; | ||||
| import com.google.gerrit.server.avatar.AvatarProvider; | ||||
| import com.google.gerrit.server.change.ArchiveFormat; | ||||
| import com.google.gerrit.server.change.GetArchive; | ||||
| import com.google.gerrit.server.change.Submit; | ||||
| @@ -56,6 +58,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|   private final AllUsersName allUsersName; | ||||
|   private final String anonymousCowardName; | ||||
|   private final GitwebConfig gitwebConfig; | ||||
|   private final DynamicItem<AvatarProvider> avatar; | ||||
|  | ||||
|   @Inject | ||||
|   public GetServerInfo( | ||||
| @@ -69,7 +72,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|       AllProjectsName allProjectsName, | ||||
|       AllUsersName allUsersName, | ||||
|       @AnonymousCowardName String anonymousCowardName, | ||||
|       GitwebConfig gitwebConfig) { | ||||
|       GitwebConfig gitwebConfig, | ||||
|       DynamicItem<AvatarProvider> avatar) { | ||||
|     this.config = config; | ||||
|     this.authConfig = authConfig; | ||||
|     this.realm = realm; | ||||
| @@ -81,6 +85,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|     this.allUsersName = allUsersName; | ||||
|     this.anonymousCowardName = anonymousCowardName; | ||||
|     this.gitwebConfig = gitwebConfig; | ||||
|     this.avatar = avatar; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -94,6 +99,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|             archiveFormats); | ||||
|     info.gerrit = getGerritInfo(config, allProjectsName, allUsersName); | ||||
|     info.gitweb = getGitwebInfo(gitwebConfig); | ||||
|     info.plugin = getPluginInfo(); | ||||
|     info.sshd = getSshdInfo(config); | ||||
|     info.suggest = getSuggestInfo(config); | ||||
|     info.user = getUserInfo(anonymousCowardName); | ||||
| @@ -255,6 +261,12 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|     return info; | ||||
|   } | ||||
|  | ||||
|   private PluginConfigInfo getPluginInfo() { | ||||
|     PluginConfigInfo info = new PluginConfigInfo(); | ||||
|     info.hasAvatars = toBoolean(avatar.get() != null); | ||||
|     return info; | ||||
|   } | ||||
|  | ||||
|   private SshdInfo getSshdInfo(Config cfg) { | ||||
|     String[] addr = cfg.getStringList("sshd", null, "listenAddress"); | ||||
|     if (addr.length == 1 && isOff(addr[0])) { | ||||
| @@ -298,6 +310,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|     public DownloadInfo download; | ||||
|     public GerritInfo gerrit; | ||||
|     public GitwebInfo gitweb; | ||||
|     public PluginConfigInfo plugin; | ||||
|     public SshdInfo sshd; | ||||
|     public SuggestInfo suggest; | ||||
|     public UserConfigInfo user; | ||||
| @@ -357,6 +370,10 @@ public class GetServerInfo implements RestReadView<ConfigResource> { | ||||
|     public GitwebType type; | ||||
|   } | ||||
|  | ||||
|   public static class PluginConfigInfo { | ||||
|     public Boolean hasAvatars; | ||||
|   } | ||||
|  | ||||
|   public static class SshdInfo { | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shawn Pearce
					Shawn Pearce