| | |
| | |
|
| | | import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.form.CheckBox;
|
| | | import org.apache.wicket.markup.html.form.Radio;
|
| | | import org.apache.wicket.markup.html.form.RadioGroup;
|
| | | import org.apache.wicket.markup.html.list.ListItem;
|
| | | import org.apache.wicket.markup.html.list.ListView;
|
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.model.IModel;
|
| | | import org.apache.wicket.model.Model;
|
| | | import org.apache.wicket.model.PropertyModel;
|
| | |
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.AuthorizationControl;
|
| | |
| | | private final AjaxFormChoiceComponentUpdatingBehavior callback;
|
| | |
|
| | | private RadioGroup<AccessPolicy> policiesGroup;
|
| | |
|
| | | private IModel<Boolean> allowForks;
|
| | |
|
| | | public AccessPolicyPanel(String wicketId, RepositoryModel repository) {
|
| | | this(wicketId, repository, null);
|
| | |
| | | }
|
| | | add(policiesGroup);
|
| | |
|
| | | allowForks = Model.of(true);
|
| | | add(newCheckbox("allowForks",
|
| | | if (app().settings().getBoolean(Keys.web.allowForking, true)) {
|
| | | Fragment fragment = new Fragment("allowForks", "allowForksFragment", this);
|
| | | fragment.add(new BooleanOption("allowForks",
|
| | | getString("gb.allowForks"),
|
| | | getString("gb.allowForksDescription"),
|
| | | allowForks).setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));
|
| | | new PropertyModel<Boolean>(repository, "allowForks")));
|
| | | add(fragment);
|
| | | } else {
|
| | | add(new Label("allowForks").setVisible(false));
|
| | | }
|
| | |
|
| | | setOutputMarkupId(true);
|
| | | }
|
| | |
|
| | | private Fragment newCheckbox(String wicketId, String title, String description, IModel<Boolean> model) {
|
| | | Fragment fragment = new Fragment(wicketId, "checkboxOption", this);
|
| | | fragment.add(new Label("name", title));
|
| | | fragment.add(new Label("description", description));
|
| | | fragment.add(new CheckBox("checkbox", model));
|
| | | return fragment;
|
| | | }
|
| | |
|
| | | public void updateModel(RepositoryModel repository) {
|
| | | AccessPolicy policy = policiesGroup.getModelObject();
|
| | | repository.authorizationControl = policy.control;
|
| | | repository.accessRestriction = policy.type;
|
| | | repository.allowForks = allowForks.getObject();
|
| | | }
|
| | |
|
| | | @Override
|