James Moger
2014-09-11 48019b15fb3ee3f5c46f9f6669bd538e28000a25
Disable permission checkboxes if permission is inherited
1 files modified
29 ■■■■ changed files
src/main/java/com/gitblit/wicket/pages/EditUserPage.java 29 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/EditUserPage.java
@@ -239,9 +239,32 @@
        form.add(confirmPasswordField.setEnabled(editCredentials));
        form.add(new TextField<String>("displayName").setEnabled(editDisplayName));
        form.add(new TextField<String>("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"));