]> source.dussan.org Git - gitblit.git/commitdiff
Include gravatar images in registrant permissions panel, if configured
authorJames Moger <james.moger@gitblit.com>
Wed, 31 Oct 2012 13:11:58 +0000 (09:11 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 31 Oct 2012 13:11:58 +0000 (09:11 -0400)
src/com/gitblit/wicket/panels/GravatarImage.java
src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.html
src/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java

index f26a90276205ae8029a7827ab78a02863eeb83cd..7f1874f270d2b22657ed6d5d9ebcaedf84ebb6fe 100644 (file)
@@ -44,8 +44,12 @@ public class GravatarImage extends Panel {
        public GravatarImage(String id, PersonIdent person) {\r
                this(id, person, 0);\r
        }\r
-\r
+       \r
        public GravatarImage(String id, PersonIdent person, int width) {\r
+               this(id, person, width, true);\r
+       }\r
+\r
+       public GravatarImage(String id, PersonIdent person, int width, boolean linked) {\r
                super(id);\r
 \r
                String email = person.getEmailAddress() == null ? person.getName().toLowerCase() : person.getEmailAddress().toLowerCase();\r
@@ -57,9 +61,13 @@ public class GravatarImage extends Panel {
                ExternalImage image = new ExternalImage("image", url);\r
                WicketUtils.setCssClass(image, "gravatar");\r
                link.add(image);\r
-               WicketUtils.setHtmlTooltip(link,\r
+               if (linked) {\r
+                       WicketUtils.setHtmlTooltip(link,\r
                                MessageFormat.format("View Gravatar profile for {0}", person.getName()));\r
-               add(link);\r
+               } else {\r
+                       WicketUtils.setHtmlTooltip(link, person.getName());\r
+               }\r
+               add(link.setEnabled(linked));\r
                setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));\r
        }\r
 }
\ No newline at end of file
index 31f0b6bee96b74fda109a010f55445e5aabe419d..8f85816b024d02af7f8fc1f9b08b1775cab3777e 100644 (file)
                <form style="padding: 20px 40px;" class="well form-inline" wicket:id="addPermissionForm">\r
                        <select class="input-large" wicket:id="registrant"></select> <select class="input-medium" wicket:id="permission"></select> <input class="btn btn-success" type="submit" value="Add" wicket:message="value:gb.add" wicket:id="addPermissionButton"/>\r
                </form>\r
-       </div>  \r
+       </div>\r
+       \r
+       <wicket:fragment wicket:id="userRegistrant">\r
+               <span wicket:id="userAvatar"></span> <span style="font-weight: bold;" wicket:id="userName"></span>\r
+       </wicket:fragment>\r
+\r
+       <wicket:fragment wicket:id="teamRegistrant">\r
+               <span style="font-weight: bold;" wicket:id="teamName"></span>\r
+       </wicket:fragment>\r
        \r
 </wicket:panel>\r
 </body>\r
index 1d451a672b58292a30014e37777b87c27b1361f5..805db9ddb4c768652cf12f9be942f926f67c4144 100644 (file)
@@ -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: