]> source.dussan.org Git - gitblit.git/commitdiff
Disable permission checkboxes if permission is inherited 77/177/1
authorJames Moger <james.moger@gitblit.com>
Thu, 11 Sep 2014 15:20:39 +0000 (11:20 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 11 Sep 2014 15:20:39 +0000 (11:20 -0400)
src/main/java/com/gitblit/wicket/pages/EditUserPage.java

index b9a848052ba2657f25a4424bb63f5aa1d7350468..454aa619164225fd8bb36c1415e25d1e8b8c6ff6 100644 (file)
@@ -239,9 +239,32 @@ public class EditUserPage extends RootSubPage {
                form.add(confirmPasswordField.setEnabled(editCredentials));\r
                form.add(new TextField<String>("displayName").setEnabled(editDisplayName));\r
                form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));\r
-               form.add(new CheckBox("canAdmin"));\r
-               form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));\r
-               form.add(new CheckBox("canCreate"));\r
+\r
+               if (userModel.canAdmin() && !userModel.canAdmin) {\r
+                       // user inherits Admin permission\r
+                       // display a disabled-yet-checked checkbox\r
+                       form.add(new CheckBox("canAdmin", Model.of(true)).setEnabled(false));\r
+               } else {\r
+                       form.add(new CheckBox("canAdmin"));\r
+               }\r
+\r
+               if (userModel.canFork() && !userModel.canFork) {\r
+                       // user inherits Fork permission\r
+                       // display a disabled-yet-checked checkbox\r
+                       form.add(new CheckBox("canFork", Model.of(true)).setEnabled(false));\r
+               } else {\r
+                       final boolean forkingAllowed = app().settings().getBoolean(Keys.web.allowForking, true);\r
+                       form.add(new CheckBox("canFork").setEnabled(forkingAllowed));\r
+               }\r
+\r
+               if (userModel.canCreate() && !userModel.canCreate) {\r
+                       // user inherits Create permission\r
+                       // display a disabled-yet-checked checkbox\r
+                       form.add(new CheckBox("canCreate", Model.of(true)).setEnabled(false));\r
+               } else {\r
+                       form.add(new CheckBox("canCreate"));\r
+               }\r
+\r
                form.add(new CheckBox("excludeFromFederation"));\r
                form.add(new CheckBox("disabled"));\r
 \r