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.
|
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]]
|
[[receive-info]]
|
||||||
=== ReceiveInfo
|
=== ReceiveInfo
|
||||||
The `ReceiveInfo` entity contains information about the configuration
|
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.
|
GerritInfo] entity.
|
||||||
|`gitweb ` |optional|
|
|`gitweb ` |optional|
|
||||||
Information about the link:config-gerrit.html#gitweb[gitweb]
|
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|
|
|`receive` |optional|
|
||||||
Information about the receive-pack configuration as a
|
Information about the receive-pack configuration as a
|
||||||
link:#receive-info[ReceiveInfo] entity.
|
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) {
|
private void loadAvatar(AccountInfo account, int size, boolean addPopup) {
|
||||||
|
if (!Gerrit.info().plugin().hasAvatars()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Kill /accounts/*/avatar URL.
|
// TODO Kill /accounts/*/avatar URL.
|
||||||
String u = account.email();
|
String u = account.email();
|
||||||
if (Gerrit.isSignedIn()
|
if (Gerrit.isSignedIn()
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class MyProfileScreen extends SettingsScreen {
|
|||||||
HorizontalPanel h = new HorizontalPanel();
|
HorizontalPanel h = new HorizontalPanel();
|
||||||
add(h);
|
add(h);
|
||||||
|
|
||||||
|
if (Gerrit.info().plugin().hasAvatars()) {
|
||||||
VerticalPanel v = new VerticalPanel();
|
VerticalPanel v = new VerticalPanel();
|
||||||
v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel());
|
v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel());
|
||||||
h.add(v);
|
h.add(v);
|
||||||
@@ -52,6 +53,7 @@ public class MyProfileScreen extends SettingsScreen {
|
|||||||
changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank");
|
changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank");
|
||||||
changeAvatar.setVisible(false);
|
changeAvatar.setVisible(false);
|
||||||
v.add(changeAvatar);
|
v.add(changeAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
if (LocaleInfo.getCurrentLocale().isRTL()) {
|
if (LocaleInfo.getCurrentLocale().isRTL()) {
|
||||||
labelIdx = 1;
|
labelIdx = 1;
|
||||||
@@ -95,6 +97,7 @@ public class MyProfileScreen extends SettingsScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void display(final Account account) {
|
void display(final Account account) {
|
||||||
|
if (Gerrit.info().plugin().hasAvatars()) {
|
||||||
avatar.setAccount(FormatUtil.asInfo(account), 93, false);
|
avatar.setAccount(FormatUtil.asInfo(account), 93, false);
|
||||||
new RestApi("/accounts/").id("self").view("avatar.change.url")
|
new RestApi("/accounts/").id("self").view("avatar.change.url")
|
||||||
.get(new AsyncCallback<NativeString>() {
|
.get(new AsyncCallback<NativeString>() {
|
||||||
@@ -108,6 +111,7 @@ public class MyProfileScreen extends SettingsScreen {
|
|||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
if (Gerrit.info().auth().siteHasUsernames()) {
|
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 DownloadInfo download() /*-{ return this.download; }-*/;
|
||||||
public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/;
|
public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/;
|
||||||
public final native GitwebInfo gitweb() /*-{ return this.gitweb; }-*/;
|
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 SshdInfo sshd() /*-{ return this.sshd; }-*/;
|
||||||
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
|
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
|
||||||
public final native UserConfigInfo user() /*-{ return this.user; }-*/;
|
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 {
|
public static class SshdInfo extends JavaScriptObject {
|
||||||
protected SshdInfo() {
|
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.CloneCommand;
|
||||||
import com.google.gerrit.extensions.config.DownloadCommand;
|
import com.google.gerrit.extensions.config.DownloadCommand;
|
||||||
import com.google.gerrit.extensions.config.DownloadScheme;
|
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.registration.DynamicMap;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AuthType;
|
import com.google.gerrit.reviewdb.client.AuthType;
|
||||||
import com.google.gerrit.server.account.Realm;
|
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.ArchiveFormat;
|
||||||
import com.google.gerrit.server.change.GetArchive;
|
import com.google.gerrit.server.change.GetArchive;
|
||||||
import com.google.gerrit.server.change.Submit;
|
import com.google.gerrit.server.change.Submit;
|
||||||
@@ -56,6 +58,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
private final AllUsersName allUsersName;
|
private final AllUsersName allUsersName;
|
||||||
private final String anonymousCowardName;
|
private final String anonymousCowardName;
|
||||||
private final GitwebConfig gitwebConfig;
|
private final GitwebConfig gitwebConfig;
|
||||||
|
private final DynamicItem<AvatarProvider> avatar;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GetServerInfo(
|
public GetServerInfo(
|
||||||
@@ -69,7 +72,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
AllProjectsName allProjectsName,
|
AllProjectsName allProjectsName,
|
||||||
AllUsersName allUsersName,
|
AllUsersName allUsersName,
|
||||||
@AnonymousCowardName String anonymousCowardName,
|
@AnonymousCowardName String anonymousCowardName,
|
||||||
GitwebConfig gitwebConfig) {
|
GitwebConfig gitwebConfig,
|
||||||
|
DynamicItem<AvatarProvider> avatar) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
@@ -81,6 +85,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
this.allUsersName = allUsersName;
|
this.allUsersName = allUsersName;
|
||||||
this.anonymousCowardName = anonymousCowardName;
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
this.gitwebConfig = gitwebConfig;
|
this.gitwebConfig = gitwebConfig;
|
||||||
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,6 +99,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
archiveFormats);
|
archiveFormats);
|
||||||
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
||||||
info.gitweb = getGitwebInfo(gitwebConfig);
|
info.gitweb = getGitwebInfo(gitwebConfig);
|
||||||
|
info.plugin = getPluginInfo();
|
||||||
info.sshd = getSshdInfo(config);
|
info.sshd = getSshdInfo(config);
|
||||||
info.suggest = getSuggestInfo(config);
|
info.suggest = getSuggestInfo(config);
|
||||||
info.user = getUserInfo(anonymousCowardName);
|
info.user = getUserInfo(anonymousCowardName);
|
||||||
@@ -255,6 +261,12 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PluginConfigInfo getPluginInfo() {
|
||||||
|
PluginConfigInfo info = new PluginConfigInfo();
|
||||||
|
info.hasAvatars = toBoolean(avatar.get() != null);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
private SshdInfo getSshdInfo(Config cfg) {
|
private SshdInfo getSshdInfo(Config cfg) {
|
||||||
String[] addr = cfg.getStringList("sshd", null, "listenAddress");
|
String[] addr = cfg.getStringList("sshd", null, "listenAddress");
|
||||||
if (addr.length == 1 && isOff(addr[0])) {
|
if (addr.length == 1 && isOff(addr[0])) {
|
||||||
@@ -298,6 +310,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
public DownloadInfo download;
|
public DownloadInfo download;
|
||||||
public GerritInfo gerrit;
|
public GerritInfo gerrit;
|
||||||
public GitwebInfo gitweb;
|
public GitwebInfo gitweb;
|
||||||
|
public PluginConfigInfo plugin;
|
||||||
public SshdInfo sshd;
|
public SshdInfo sshd;
|
||||||
public SuggestInfo suggest;
|
public SuggestInfo suggest;
|
||||||
public UserConfigInfo user;
|
public UserConfigInfo user;
|
||||||
@@ -357,6 +370,10 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
public GitwebType type;
|
public GitwebType type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PluginConfigInfo {
|
||||||
|
public Boolean hasAvatars;
|
||||||
|
}
|
||||||
|
|
||||||
public static class SshdInfo {
|
public static class SshdInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user