From: James Moger Date: Wed, 31 Oct 2012 13:11:58 +0000 (-0400) Subject: Include gravatar images in registrant permissions panel, if configured X-Git-Tag: v1.2.0~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ef2290175dd9bd34f991a88d581dde6865182c42;p=gitblit.git Include gravatar images in registrant permissions panel, if configured --- diff --git a/src/com/gitblit/wicket/panels/GravatarImage.java b/src/com/gitblit/wicket/panels/GravatarImage.java index f26a9027..7f1874f2 100644 --- a/src/com/gitblit/wicket/panels/GravatarImage.java +++ b/src/com/gitblit/wicket/panels/GravatarImage.java @@ -44,8 +44,12 @@ public class GravatarImage extends Panel { public GravatarImage(String id, PersonIdent person) { this(id, person, 0); } - + public GravatarImage(String id, PersonIdent person, int width) { + this(id, person, width, true); + } + + public GravatarImage(String id, PersonIdent person, int width, boolean linked) { super(id); String email = person.getEmailAddress() == null ? person.getName().toLowerCase() : person.getEmailAddress().toLowerCase(); @@ -57,9 +61,13 @@ public class GravatarImage extends Panel { ExternalImage image = new ExternalImage("image", url); WicketUtils.setCssClass(image, "gravatar"); link.add(image); - WicketUtils.setHtmlTooltip(link, + if (linked) { + WicketUtils.setHtmlTooltip(link, MessageFormat.format("View Gravatar profile for {0}", person.getName())); - add(link); + } else { + WicketUtils.setHtmlTooltip(link, person.getName()); + } + add(link.setEnabled(linked)); setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true)); } } \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html b/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html index 31f0b6be..8f85816b 100644 --- a/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html +++ b/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html @@ -17,7 +17,15 @@
- + + + + + + + + + diff --git a/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java b/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java index 1d451a67..805db9dd 100644 --- a/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java +++ b/src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java @@ -28,17 +28,21 @@ import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.IChoiceRenderer; +import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.OddEvenItem; import org.apache.wicket.markup.repeater.RefreshingView; import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; +import org.eclipse.jgit.lib.PersonIdent; import com.gitblit.Constants.AccessPermission; import com.gitblit.Constants.PermissionType; import com.gitblit.Constants.RegistrantType; +import com.gitblit.GitBlit; import com.gitblit.models.RegistrantAccessPermission; +import com.gitblit.models.UserModel; import com.gitblit.utils.DeepCopier; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; @@ -96,11 +100,23 @@ public class RegistrantPermissionsPanel extends BasePanel { WicketUtils.setCssStyle(label, "font-weight: bold;"); item.add(label); } + } else if (RegistrantType.USER.equals(entry.registrantType)) { + // user + PersonIdent ident = new PersonIdent(entry.registrant, null); + UserModel user = GitBlit.self().getUserModel(entry.registrant); + if (user != null) { + ident = new PersonIdent(user.getDisplayName(), user.emailAddress); + } + + Fragment userFragment = new Fragment("registrant", "userRegistrant", RegistrantPermissionsPanel.this); + userFragment.add(new GravatarImage("userAvatar", ident, 16, false)); + userFragment.add(new Label("userName", entry.registrant)); + item.add(userFragment); } else { - // user or team - Label label = new Label("registrant", entry.registrant); - WicketUtils.setCssStyle(label, "font-weight: bold;"); - item.add(label); + // team + Fragment teamFragment = new Fragment("registrant", "teamRegistrant", RegistrantPermissionsPanel.this); + teamFragment.add(new Label("teamName", entry.registrant)); + item.add(teamFragment); } switch (entry.permissionType) { case OWNER: