| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | private final boolean isCreate;
|
| | |
|
| | | private boolean isAdmin;
|
| | | |
| | | RepositoryModel repositoryModel;
|
| | |
|
| | | private IModel<String> mailingLists;
|
| | |
|
| | |
| | |
|
| | | setupPage(model);
|
| | | setStatelessHint(false);
|
| | | setOutputMarkupId(true);
|
| | | }
|
| | |
|
| | | public EditRepositoryPage(PageParameters params) {
|
| | |
| | | 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);
|
| | |
|
| | |
| | | }
|
| | | } 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);
|
| | |
| | |
|
| | | 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>();
|
| | |
| | | };
|
| | | 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;
|
| | |
|
| | |
| | | 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 */));
|
| | |
| | | }
|
| | | 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.
|
| | |
| | | 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);
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | |
| | | }
|