import org.apache.wicket.PageParameters;\r
import org.apache.wicket.ajax.AjaxRequestTarget;\r
import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;\r
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;\r
import org.apache.wicket.behavior.SimpleAttributeModifier;\r
import org.apache.wicket.extensions.markup.html.form.palette.Palette;\r
import org.apache.wicket.markup.html.WebMarkupContainer;\r
import org.apache.wicket.markup.html.form.DropDownChoice;\r
import org.apache.wicket.markup.html.form.Form;\r
import org.apache.wicket.markup.html.form.IChoiceRenderer;\r
-import org.apache.wicket.markup.html.form.RadioChoice;\r
import org.apache.wicket.markup.html.form.TextField;\r
import org.apache.wicket.markup.html.link.Link;\r
import org.apache.wicket.markup.html.list.ListItem;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.StringChoiceRenderer;\r
import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.panels.AccessPolicyPanel;\r
import com.gitblit.wicket.panels.BasePanel.JavascriptEventConfirmation;\r
import com.gitblit.wicket.panels.BulletListPanel;\r
import com.gitblit.wicket.panels.RegistrantPermissionsPanel;\r
\r
RepositoryNamePanel namePanel;\r
\r
+ AccessPolicyPanel accessPolicyPanel;\r
+\r
private boolean isAdmin;\r
\r
RepositoryModel repositoryModel;\r
\r
form.add(ownersPalette);\r
form.add(new CheckBox("allowForks").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true)));\r
- DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction",\r
- AccessRestrictionType.choices(app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)), new AccessRestrictionRenderer());\r
- form.add(accessRestriction);\r
form.add(new CheckBox("isFrozen"));\r
// TODO enable origin definition\r
form.add(new TextField<String>("origin").setEnabled(false/* isCreate */));\r
form.add(new TextField<String>("mailingLists", mailingLists));\r
form.add(indexedBranchesPalette);\r
\r
- List<AuthorizationControl> acList = Arrays.asList(AuthorizationControl.values());\r
- final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>(\r
- "authorizationControl", acList, new AuthorizationControlRenderer());\r
- form.add(authorizationControl);\r
-\r
final CheckBox verifyCommitter = new CheckBox("verifyCommitter");\r
verifyCommitter.setOutputMarkupId(true);\r
form.add(verifyCommitter);\r
// anonymous everything, disable all controls\r
usersPalette.setEnabled(false);\r
teamsPalette.setEnabled(false);\r
- authorizationControl.setEnabled(false);\r
verifyCommitter.setEnabled(false);\r
} else {\r
// authenticated something\r
// enable authorization controls\r
- authorizationControl.setEnabled(true);\r
verifyCommitter.setEnabled(true);\r
\r
boolean allowFineGrainedControls = repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
teamsPalette.setEnabled(allowFineGrainedControls);\r
}\r
\r
- accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") {\r
+ AjaxFormChoiceComponentUpdatingBehavior callback = new AjaxFormChoiceComponentUpdatingBehavior() {\r
\r
private static final long serialVersionUID = 1L;\r
\r
@Override\r
protected void onUpdate(AjaxRequestTarget target) {\r
- // enable/disable permissions panel based on access restriction\r
+ accessPolicyPanel.updateModel(repositoryModel);\r
+\r
boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);\r
- authorizationControl.setEnabled(allowAuthorizationControl);\r
verifyCommitter.setEnabled(allowAuthorizationControl);\r
\r
boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
repositoryModel.authorizationControl = AuthorizationControl.NAMED;\r
}\r
\r
- target.addComponent(authorizationControl);\r
target.addComponent(verifyCommitter);\r
target.addComponent(usersPalette);\r
target.addComponent(teamsPalette);\r
}\r
- });\r
-\r
- authorizationControl.add(new AjaxFormChoiceComponentUpdatingBehavior() {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- @Override\r
- protected void onUpdate(AjaxRequestTarget target) {\r
- // enable/disable permissions panel based on access restriction\r
- boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);\r
- authorizationControl.setEnabled(allowAuthorizationControl);\r
-\r
- boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);\r
- usersPalette.setEnabled(allowFineGrainedControls);\r
- teamsPalette.setEnabled(allowFineGrainedControls);\r
+ };\r
\r
- if (allowFineGrainedControls) {\r
- repositoryModel.authorizationControl = AuthorizationControl.NAMED;\r
- }\r
-\r
- target.addComponent(authorizationControl);\r
- target.addComponent(usersPalette);\r
- target.addComponent(teamsPalette);\r
- }\r
- });\r
+ accessPolicyPanel = new AccessPolicyPanel("accessPolicyPanel", repositoryModel, callback);\r
+ form.add(accessPolicyPanel);\r
\r
List<CommitMessageRenderer> renderers = Arrays.asList(CommitMessageRenderer.values());\r
DropDownChoice<CommitMessageRenderer> messageRendererChoice = new DropDownChoice<CommitMessageRenderer>("commitMessageRenderer", renderers);\r
}\r
}\r
\r
- private class AccessRestrictionRenderer implements IChoiceRenderer<AccessRestrictionType> {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- private final Map<AccessRestrictionType, String> map;\r
-\r
- public AccessRestrictionRenderer() {\r
- map = getAccessRestrictions();\r
- }\r
-\r
- @Override\r
- public String getDisplayValue(AccessRestrictionType type) {\r
- return map.get(type);\r
- }\r
-\r
- @Override\r
- public String getIdValue(AccessRestrictionType type, int index) {\r
- return Integer.toString(index);\r
- }\r
- }\r
-\r
private class FederationTypeRenderer implements IChoiceRenderer<FederationStrategy> {\r
\r
private static final long serialVersionUID = 1L;\r
}\r
}\r
\r
- private class AuthorizationControlRenderer implements IChoiceRenderer<AuthorizationControl> {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- private final Map<AuthorizationControl, String> map;\r
-\r
- public AuthorizationControlRenderer() {\r
- map = getAuthorizationControls();\r
- }\r
-\r
- @Override\r
- public String getDisplayValue(AuthorizationControl type) {\r
- return map.get(type);\r
- }\r
-\r
- @Override\r
- public String getIdValue(AuthorizationControl type, int index) {\r
- return Integer.toString(index);\r
- }\r
- }\r
-\r
private class GCPeriodRenderer implements IChoiceRenderer<Integer> {\r
\r
private static final long serialVersionUID = 1L;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.panels.RepositoryNamePanel;\r
import com.gitblit.wicket.panels.AccessPolicyPanel;\r
+import com.gitblit.wicket.panels.RepositoryNamePanel;\r
\r
public class NewRepositoryPage extends RootSubPage {\r
\r
private Model<String> gitignoreModel;\r
private IModel<Boolean> addGitflowModel;\r
private IModel<Boolean> addGitignoreModel;\r
- private AccessPolicyPanel permissionPanel;\r
+ private AccessPolicyPanel accessPolicyPanel;\r
private RepositoryNamePanel namePanel;\r
\r
public NewRepositoryPage() {\r
if (!namePanel.updateModel(repositoryModel)) {\r
return;\r
}\r
- permissionPanel.updateModel(repositoryModel);\r
+ accessPolicyPanel.updateModel(repositoryModel);\r
\r
repositoryModel.owners = new ArrayList<String>();\r
repositoryModel.owners.add(GitBlitWebSession.get().getUsername());\r
repositoryModel.authorizationControl = defaultControl;\r
repositoryModel.accessRestriction = defaultRestriction;\r
\r
- permissionPanel = new AccessPolicyPanel("permissionPanel", repositoryModel);\r
- form.add(permissionPanel);\r
+ accessPolicyPanel = new AccessPolicyPanel("accessPolicyPanel", repositoryModel);\r
+ form.add(accessPolicyPanel);\r
\r
//\r
// initial commit options\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.form.Radio;\r
import org.apache.wicket.markup.html.form.RadioGroup;\r
\r
private final RepositoryModel repository;\r
\r
+ private final AjaxFormChoiceComponentUpdatingBehavior callback;\r
+\r
private RadioGroup<AccessPolicy> policiesGroup;\r
\r
public AccessPolicyPanel(String wicketId, RepositoryModel repository) {\r
+ this(wicketId, repository, null);\r
+ }\r
+\r
+ public AccessPolicyPanel(String wicketId, RepositoryModel repository, AjaxFormChoiceComponentUpdatingBehavior callback) {\r
super(wicketId);\r
this.repository = repository;\r
+ this.callback = callback;\r
}\r
\r
@Override\r
}\r
};\r
policiesGroup.add(policiesList);\r
+ if (callback != null) {\r
+ policiesGroup.add(callback);\r
+ policiesGroup.setOutputMarkupId(true);\r
+ }\r
+ add(policiesGroup);\r
\r
setOutputMarkupId(true);\r
-\r
- add(policiesGroup);\r
}\r
\r
public void updateModel(RepositoryModel repository) {\r
return false;\r
}\r
\r
- private static class AccessPolicy implements Serializable {\r
+ public static class AccessPolicy implements Serializable {\r
\r
private static final long serialVersionUID = 1L;\r
\r