James Moger
2013-01-05 9e186eedf1a09ca7ac4fbdea32b00e7e5331f7eb
src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -146,11 +146,11 @@
         }
      } else {
         super.setupPage(getString("gb.edit"), repositoryModel.name);
         if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {
            repositoryUsers.addAll(GitBlit.self().getUserAccessPermissions(repositoryModel));
            repositoryTeams.addAll(GitBlit.self().getTeamAccessPermissions(repositoryModel));
            Collections.sort(repositoryUsers);
         }
         repositoryUsers.addAll(GitBlit.self().getUserAccessPermissions(repositoryModel));
         repositoryTeams.addAll(GitBlit.self().getTeamAccessPermissions(repositoryModel));
         Collections.sort(repositoryUsers);
         Collections.sort(repositoryTeams);
         federationSets.addAll(repositoryModel.federationSets);
         if (!ArrayUtils.isEmpty(repositoryModel.indexedBranches)) {
            indexedBranches.addAll(repositoryModel.indexedBranches);
@@ -378,8 +378,8 @@
      form.add(new TextField<String>("name").setEnabled(allowEditName));
      form.add(new TextField<String>("description"));
      form.add(new DropDownChoice<String>("owner", GitBlit.self().getAllUsernames())
            .setEnabled(GitBlitWebSession.get().canAdmin()));
      form.add(new CheckBox("allowForks"));
            .setEnabled(GitBlitWebSession.get().canAdmin() && !repositoryModel.isPersonalRepository()));
      form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
      DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays
            .asList(AccessRestrictionType.values()), new AccessRestrictionRenderer());
      form.add(accessRestriction);
@@ -414,6 +414,9 @@
      form.add(new CheckBox("showReadme"));
      form.add(new CheckBox("skipSizeCalculation"));
      form.add(new CheckBox("skipSummaryMetrics"));
      List<Integer> maxActivityCommits  = Arrays.asList(-1, 0, 25, 50, 75, 100, 150, 200, 250, 500 );
      form.add(new DropDownChoice<Integer>("maxActivityCommits", maxActivityCommits, new MaxActivityCommitsRenderer()));
      mailingLists = new Model<String>(ArrayUtils.isEmpty(repositoryModel.mailingLists) ? ""
            : StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
      form.add(new TextField<String>("mailingLists", mailingLists));
@@ -423,8 +426,10 @@
      final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>(
            "authorizationControl", acList, new AuthorizationControlRenderer());
      form.add(authorizationControl);
      form.add(new CheckBox("verifyCommitter"));
      final CheckBox verifyCommitter = new CheckBox("verifyCommitter");
      verifyCommitter.setOutputMarkupId(true);
      form.add(verifyCommitter);
      form.add(usersPalette);
      form.add(teamsPalette);
@@ -446,14 +451,16 @@
         usersPalette.setEnabled(false);
         teamsPalette.setEnabled(false);
         authorizationControl.setEnabled(false);
         verifyCommitter.setEnabled(false);
      } else {
         // authenticated something
         // enable authorization controls
         authorizationControl.setEnabled(true);
         verifyCommitter.setEnabled(true);
         
         boolean allowFineGrainedControls = repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);
         usersPalette.setEnabled(allowFineGrainedControls);
         teamsPalette.setEnabled(allowFineGrainedControls);
         teamsPalette.setEnabled(allowFineGrainedControls);
      }
      
      accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@@ -464,6 +471,7 @@
            // enable/disable permissions panel based on access restriction
            boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);
            authorizationControl.setEnabled(allowAuthorizationControl);
            verifyCommitter.setEnabled(allowAuthorizationControl);
            
            boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);
            usersPalette.setEnabled(allowFineGrainedControls);
@@ -474,6 +482,7 @@
            }
            
            target.addComponent(authorizationControl);
            target.addComponent(verifyCommitter);
            target.addComponent(usersPalette);
            target.addComponent(teamsPalette);
         }
@@ -648,4 +657,28 @@
      }
   }
   
   private class MaxActivityCommitsRenderer implements IChoiceRenderer<Integer> {
      private static final long serialVersionUID = 1L;
      public MaxActivityCommitsRenderer() {
      }
      @Override
      public String getDisplayValue(Integer value) {
         if (value == -1) {
            return getString("gb.excludeFromActivity");
         } else if (value == 0) {
            return getString("gb.noMaximum");
         } else {
            return value + " " + getString("gb.commits");
         }
      }
      @Override
      public String getIdValue(Integer value, int index) {
         return Integer.toString(index);
      }
   }
}