]> source.dussan.org Git - gitblit.git/commitdiff
Use AccessPolicyPanel in EditRepositoryPage
authorJames Moger <james.moger@gitblit.com>
Sat, 31 May 2014 14:23:56 +0000 (10:23 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 3 Jun 2014 14:34:51 +0000 (10:34 -0400)
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html
src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.html
src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java
src/main/java/com/gitblit/wicket/panels/AccessPolicyPanel.java

index d2d1454e727dbd78450cfb0f9f2e1d632b671d05..13abcc066415e8151e4e32b50fba735066dc8735 100644 (file)
@@ -687,7 +687,7 @@ gb.plugins = plugins
 gb.extensions = extensions
 gb.pleaseSelectProject = Please select the project!
 gb.accessPolicy = Access Policy
-gb.accessPolicyDescription = Choose an access policy to control visibility, cloning, and pushing to this repository.
+gb.accessPolicyDescription = Choose an access policy to control repository visibility and git permissions.
 gb.anonymousPolicy = Anonymous View, Clone, & Push
 gb.anonymousPolicyDescription = Anyone can see, clone, and push to this repository.
 gb.authenticatedPushPolicy = Restrict Push (Authenticated)
@@ -704,5 +704,3 @@ gb.initWithReadme = Include a README
 gb.initWithReadmeDescription = This will generate a simple README document for your repository.
 gb.initWithGitignore = Include a .gitignore file
 gb.initWithGitignoreDescription = This will insert a config file that instructs your Git clients to ignore files or directories that match defined patterns.
-gb.initWithGitflow = Include a .gitflow file
-gb.initWithGitflowDescription = This will generate a config file which guides Git clients in setting up Gitflow branches.
\ No newline at end of file
index ccb60a5c55911eaf5a79d3270f73941770ff0b43..ab448038fde8a131543ea24f843d83f27895524f 100644 (file)
@@ -58,9 +58,7 @@
                                <tbody class="settings">\r
                                        <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="19" /> </td></tr>\r
                                        <tr><th colspan="2"><hr/></th></tr>\r
-                                       <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="20" /></td></tr>\r
-                                       <tr><th colspan="2"><hr/></th></tr>\r
-                                       <tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>\r
+                                       <tr><th></th><td style="padding:2px;"><span wicket:id="accessPolicyPanel"></span></td></tr>\r
                                        <tr><th colspan="2"><hr/></th></tr>\r
                                        <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="21" /> &nbsp;<span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>\r
                                        <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="22" /> &nbsp;<span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>\r
index 4759fd0d8c3e0ee71d0bafe6028a4d18bf1ebc91..e86bd1ee5892e26d8286896962728ff03e2da719 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Set;
 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
@@ -40,7 +39,6 @@ import org.apache.wicket.markup.html.form.ChoiceRenderer;
 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
@@ -69,6 +67,7 @@ import com.gitblit.utils.StringUtils;
 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
@@ -80,6 +79,8 @@ public class EditRepositoryPage extends RootSubPage {
 \r
        RepositoryNamePanel namePanel;\r
 \r
+       AccessPolicyPanel accessPolicyPanel;\r
+\r
        private boolean isAdmin;\r
 \r
        RepositoryModel repositoryModel;\r
@@ -396,9 +397,6 @@ public class EditRepositoryPage extends RootSubPage {
 \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
@@ -456,11 +454,6 @@ public class EditRepositoryPage extends RootSubPage {
                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
@@ -484,12 +477,10 @@ public class EditRepositoryPage extends RootSubPage {
                        // 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
@@ -497,15 +488,15 @@ public class EditRepositoryPage extends RootSubPage {
                        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
@@ -516,36 +507,14 @@ public class EditRepositoryPage extends RootSubPage {
                                        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
@@ -656,27 +625,6 @@ public class EditRepositoryPage extends RootSubPage {
                }\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
@@ -698,27 +646,6 @@ public class EditRepositoryPage extends RootSubPage {
                }\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
index 8e4e74acb6b13a76d97b4afb81586ba7fccaa491..df55381a43de5b9bc484689ca8112725f19df5d2 100644 (file)
@@ -14,7 +14,7 @@
                \r
                <hr/>\r
                \r
-               <div wicket:id="permissionPanel"></div>\r
+               <div wicket:id="accessPolicyPanel"></div>\r
                \r
                <hr/>\r
                \r
@@ -39,8 +39,8 @@
                                <input type="checkbox" wicket:id="addGitflow" />\r
                        </div>\r
                        <div style="display: inline-block;">\r
-                               <b><wicket:message key="gb.initWithGitflow"></wicket:message></b>\r
-                               <p><wicket:message key="gb.initWithGitflowDescription"></wicket:message></p>\r
+                               <b>Include a .gitflow file</b>\r
+                               <p>This will generate a config file which guides Git clients in setting up Gitflow branches.</p>\r
                        </div>\r
                </div>\r
                \r
index 0adb1ddd6698ca312acff7a72d13ef4d93ee9976..d5ae3440e39625d9d903f04ec3de55a76b28e9e3 100644 (file)
@@ -59,8 +59,8 @@ import com.gitblit.utils.FileUtils;
 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
@@ -69,7 +69,7 @@ public class NewRepositoryPage extends RootSubPage {
        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
@@ -108,7 +108,7 @@ public class NewRepositoryPage extends RootSubPage {
                                        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
@@ -174,8 +174,8 @@ public class NewRepositoryPage extends RootSubPage {
                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
index a115e251b7f1d0053b95828d39cf7ce2e2eef664..057b96f47fbd080bb4085531036a62e3d5d6f19d 100644 (file)
@@ -19,6 +19,7 @@ import java.io.Serializable;
 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
@@ -44,11 +45,18 @@ public class AccessPolicyPanel extends BasePanel {
 \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
@@ -128,10 +136,13 @@ public class AccessPolicyPanel extends BasePanel {
                        }\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
@@ -145,7 +156,7 @@ public class AccessPolicyPanel extends BasePanel {
                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