From 48019b15fb3ee3f5c46f9f6669bd538e28000a25 Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 11 Sep 2014 11:20:39 -0400 Subject: Disable permission checkboxes if permission is inherited --- .../com/gitblit/wicket/pages/EditUserPage.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java index b9a84805..454aa619 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java @@ -239,9 +239,32 @@ public class EditUserPage extends RootSubPage { form.add(confirmPasswordField.setEnabled(editCredentials)); form.add(new TextField("displayName").setEnabled(editDisplayName)); form.add(new TextField("emailAddress").setEnabled(editEmailAddress)); - form.add(new CheckBox("canAdmin")); - form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true))); - form.add(new CheckBox("canCreate")); + + if (userModel.canAdmin() && !userModel.canAdmin) { + // user inherits Admin permission + // display a disabled-yet-checked checkbox + form.add(new CheckBox("canAdmin", Model.of(true)).setEnabled(false)); + } else { + form.add(new CheckBox("canAdmin")); + } + + if (userModel.canFork() && !userModel.canFork) { + // user inherits Fork permission + // display a disabled-yet-checked checkbox + form.add(new CheckBox("canFork", Model.of(true)).setEnabled(false)); + } else { + final boolean forkingAllowed = app().settings().getBoolean(Keys.web.allowForking, true); + form.add(new CheckBox("canFork").setEnabled(forkingAllowed)); + } + + if (userModel.canCreate() && !userModel.canCreate) { + // user inherits Create permission + // display a disabled-yet-checked checkbox + form.add(new CheckBox("canCreate", Model.of(true)).setEnabled(false)); + } else { + form.add(new CheckBox("canCreate")); + } + form.add(new CheckBox("excludeFromFederation")); form.add(new CheckBox("disabled")); -- cgit v1.2.3