diff options
author | James Moger <james.moger@gitblit.com> | 2012-10-31 09:11:58 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-10-31 09:11:58 -0400 |
commit | ef2290175dd9bd34f991a88d581dde6865182c42 (patch) | |
tree | 2fb2003294730e9b550f5d0026dca1e42fa25a95 | |
parent | e13ea7f2b53a9c4ec69005aced85c486dedb8d6b (diff) | |
download | gitblit-ef2290175dd9bd34f991a88d581dde6865182c42.tar.gz gitblit-ef2290175dd9bd34f991a88d581dde6865182c42.zip |
Include gravatar images in registrant permissions panel, if configured
3 files changed, 40 insertions, 8 deletions
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 @@ <form style="padding: 20px 40px;" class="well form-inline" wicket:id="addPermissionForm">
<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"/>
</form>
- </div>
+ </div>
+
+ <wicket:fragment wicket:id="userRegistrant">
+ <span wicket:id="userAvatar"></span> <span style="font-weight: bold;" wicket:id="userName"></span>
+ </wicket:fragment>
+
+ <wicket:fragment wicket:id="teamRegistrant">
+ <span style="font-weight: bold;" wicket:id="teamName"></span>
+ </wicket:fragment>
</wicket:panel>
</body>
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: |