Merge "Include in ServerInfo whether an avatar provider is registered"

This commit is contained in:
Shawn Pearce
2015-07-22 15:54:03 +00:00
committed by Gerrit Code Review
5 changed files with 69 additions and 22 deletions

View File

@@ -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()

View File

@@ -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()) {

View File

@@ -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() {
}