From 9af47c10c6a268877c1d232c8d71ee6df4f8a7ab Mon Sep 17 00:00:00 2001 From: Jeroen Baten <jeroen@jeroenbaten.nl> Date: Fri, 04 Jan 2013 05:18:37 -0500 Subject: [PATCH] Dutch translation before spellcheck --- src/com/gitblit/wicket/pages/EditRepositoryPage.java | 211 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 182 insertions(+), 29 deletions(-) diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 1a2e63c..a071b69 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -27,6 +27,9 @@ import java.util.Set; import org.apache.wicket.PageParameters; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.extensions.markup.html.form.palette.Palette; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -36,8 +39,7 @@ import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.IChoiceRenderer; -import org.apache.wicket.markup.html.form.Radio; -import org.apache.wicket.markup.html.form.RadioGroup; +import org.apache.wicket.markup.html.form.RadioChoice; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; @@ -51,6 +53,7 @@ import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.Constants.AuthorizationControl; import com.gitblit.Constants.FederationStrategy; +import com.gitblit.Constants.RegistrantType; import com.gitblit.GitBlit; import com.gitblit.GitBlitException; import com.gitblit.Keys; @@ -70,6 +73,8 @@ private final boolean isCreate; private boolean isAdmin; + + RepositoryModel repositoryModel; private IModel<String> mailingLists; @@ -97,6 +102,7 @@ setupPage(model); setStatelessHint(false); + setOutputMarkupId(true); } public EditRepositoryPage(PageParameters params) { @@ -107,9 +113,17 @@ RepositoryModel model = GitBlit.self().getRepositoryModel(name); setupPage(model); setStatelessHint(false); + setOutputMarkupId(true); + } + + @Override + protected boolean requiresPageMap() { + return true; } - protected void setupPage(final RepositoryModel repositoryModel) { + protected void setupPage(RepositoryModel model) { + this.repositoryModel = model; + // ensure this user can create or edit this repository checkPermissions(repositoryModel); @@ -132,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); @@ -145,10 +159,10 @@ final String oldName = repositoryModel.name; - RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users", - GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions()); - RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams", - GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions()); + final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users", + RegistrantType.USER, GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions()); + final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams", + RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions()); // indexed local branches palette List<String> allLocalBranches = new ArrayList<String>(); @@ -206,9 +220,9 @@ }; customFieldsListView.setReuseItems(true); - CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>( + CompoundPropertyModel<RepositoryModel> rModel = new CompoundPropertyModel<RepositoryModel>( repositoryModel); - Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", model) { + Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", rModel) { private static final long serialVersionUID = 1L; @@ -364,10 +378,11 @@ 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")); - form.add(new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays - .asList(AccessRestrictionType.values()), new AccessRestrictionRenderer())); + .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); form.add(new CheckBox("isFrozen")); // TODO enable origin definition form.add(new TextField<String>("origin").setEnabled(false/* isCreate */)); @@ -379,9 +394,10 @@ } form.add(new DropDownChoice<String>("HEAD", availableRefs).setEnabled(availableRefs.size() > 0)); - List<String> gcPeriods = Arrays.asList("1 day", "2 days", "3 days", "4 days", "5 days", "7 days", "10 days", "14 days"); - form.add(new DropDownChoice<String>("gcPeriod", gcPeriods)); - form.add(new TextField<String>("gcThreshold")); + boolean gcEnabled = GitBlit.getBoolean(Keys.git.enableGarbageCollection, false); + List<Integer> gcPeriods = Arrays.asList(1, 2, 3, 4, 5, 7, 10, 14 ); + form.add(new DropDownChoice<Integer>("gcPeriod", gcPeriods, new GCPeriodRenderer()).setEnabled(gcEnabled)); + form.add(new TextField<String>("gcThreshold").setEnabled(gcEnabled)); // federation strategies - remove ORIGIN choice if this repository has // no origin. @@ -398,19 +414,22 @@ 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)); form.add(indexedBranchesPalette); - RadioGroup<AuthorizationControl> group = new RadioGroup<AuthorizationControl>("authorizationControl"); - Radio<AuthorizationControl> allowAuthenticated = new Radio<AuthorizationControl>("allowAuthenticated", new Model<AuthorizationControl>(AuthorizationControl.AUTHENTICATED)); - Radio<AuthorizationControl> allowNamed = new Radio<AuthorizationControl>("allowNamed", new Model<AuthorizationControl>(AuthorizationControl.NAMED)); - group.add(allowAuthenticated); - group.add(allowNamed); - form.add(group); - - form.add(new CheckBox("verifyCommitter")); + List<AuthorizationControl> acList = Arrays.asList(AuthorizationControl.values()); + final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>( + "authorizationControl", acList, new AuthorizationControlRenderer()); + form.add(authorizationControl); + + final CheckBox verifyCommitter = new CheckBox("verifyCommitter"); + verifyCommitter.setOutputMarkupId(true); + form.add(verifyCommitter); form.add(usersPalette); form.add(teamsPalette); @@ -425,7 +444,73 @@ WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection"); customFieldsSection.add(customFieldsListView); form.add(customFieldsSection.setVisible(!GitBlit.getString(Keys.groovy.customFields, "").isEmpty())); + + // initial enable/disable of permission controls + if (repositoryModel.accessRestriction.equals(AccessRestrictionType.NONE)) { + // anonymous everything, disable all controls + 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); + } + + accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") { + + private static final long serialVersionUID = 1L; + protected void onUpdate(AjaxRequestTarget target) { + // 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); + teamsPalette.setEnabled(allowFineGrainedControls); + + if (allowFineGrainedControls) { + repositoryModel.authorizationControl = AuthorizationControl.NAMED; + } + + target.addComponent(authorizationControl); + target.addComponent(verifyCommitter); + target.addComponent(usersPalette); + target.addComponent(teamsPalette); + } + }); + + authorizationControl.add(new AjaxFormChoiceComponentUpdatingBehavior() { + + private static final long serialVersionUID = 1L; + + protected void onUpdate(AjaxRequestTarget target) { + // enable/disable permissions panel based on access restriction + boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE); + authorizationControl.setEnabled(allowAuthorizationControl); + + boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED); + usersPalette.setEnabled(allowFineGrainedControls); + teamsPalette.setEnabled(allowFineGrainedControls); + + if (allowFineGrainedControls) { + repositoryModel.authorizationControl = AuthorizationControl.NAMED; + } + + target.addComponent(authorizationControl); + target.addComponent(usersPalette); + target.addComponent(teamsPalette); + } + }); + form.add(new Button("save")); Button cancel = new Button("cancel") { private static final long serialVersionUID = 1L; @@ -528,4 +613,72 @@ return Integer.toString(index); } } + + private class AuthorizationControlRenderer implements IChoiceRenderer<AuthorizationControl> { + + private static final long serialVersionUID = 1L; + + private final Map<AuthorizationControl, String> map; + + public AuthorizationControlRenderer() { + map = getAuthorizationControls(); + } + + @Override + public String getDisplayValue(AuthorizationControl type) { + return map.get(type); + } + + @Override + public String getIdValue(AuthorizationControl type, int index) { + return Integer.toString(index); + } + } + + private class GCPeriodRenderer implements IChoiceRenderer<Integer> { + + private static final long serialVersionUID = 1L; + + public GCPeriodRenderer() { + } + + @Override + public String getDisplayValue(Integer value) { + if (value == 1) { + return getString("gb.duration.oneDay"); + } else { + return MessageFormat.format(getString("gb.duration.days"), value); + } + } + + @Override + public String getIdValue(Integer value, int index) { + return Integer.toString(index); + } + } + + 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); + } + } + } -- Gitblit v1.9.1