| | |
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Constants.AccessPermission;
|
| | | import com.gitblit.Constants.AuthorizationControl;
|
| | | import com.gitblit.models.RegistrantAccessPermission;
|
| | | import com.gitblit.models.TicketModel;
|
| | | import com.gitblit.models.TicketModel.Change;
|
| | |
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.MarkdownTextArea;
|
| | | import com.google.common.base.Optional;
|
| | |
|
| | | /**
|
| | | * Page for editing a ticket.
|
| | |
| | | form.add(new TextField<String>("title", titleModel));
|
| | | form.add(new TextField<String>("topic", topicModel));
|
| | |
|
| | | final IModel<String> markdownPreviewModel = new Model<String>();
|
| | | final IModel<String> markdownPreviewModel = Model.of(ticket.body == null ? "" : ticket.body);
|
| | | descriptionPreview = new Label("descriptionPreview", markdownPreviewModel);
|
| | | descriptionPreview.setEscapeModelStrings(false);
|
| | | descriptionPreview.setOutputMarkupId(true);
|
| | |
| | | // responsible
|
| | | Set<String> userlist = new TreeSet<String>(ticket.getParticipants());
|
| | |
|
| | | if (UserModel.ANONYMOUS.canPush(getRepositoryModel())) {
|
| | | // anonymous push
|
| | | if (UserModel.ANONYMOUS.canPush(getRepositoryModel())
|
| | | || AuthorizationControl.AUTHENTICATED == getRepositoryModel().authorizationControl) {
|
| | | // authorization is ANONYMOUS or AUTHENTICATED (i.e. all users can be set responsible)
|
| | | userlist.addAll(app().users().getAllUsernames());
|
| | | } else {
|
| | | // authenticated push
|
| | | // authorization is by NAMED users (users with PUSH permission can be set responsible)
|
| | | for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {
|
| | | if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {
|
| | | if (rp.permission.atLeast(AccessPermission.PUSH)) {
|
| | | userlist.add(rp.registrant);
|
| | | }
|
| | | }
|
| | |
| | | change.setField(Field.title, title);
|
| | | }
|
| | |
|
| | | String description = descriptionEditor.getText();
|
| | | String description = Optional.fromNullable(descriptionEditor.getText()).or("");
|
| | | if ((StringUtils.isEmpty(ticket.body) && !StringUtils.isEmpty(description))
|
| | | || (!StringUtils.isEmpty(ticket.body) && !ticket.body.equals(description))) {
|
| | | // description change
|
| | |
| | | change.setField(Field.type, type);
|
| | | }
|
| | |
|
| | | String topic = topicModel.getObject();
|
| | | String topic = Optional.fromNullable(topicModel.getObject()).or("");
|
| | | if ((StringUtils.isEmpty(ticket.topic) && !StringUtils.isEmpty(topic))
|
| | | || (!StringUtils.isEmpty(topic) && !topic.equals(ticket.topic))) {
|
| | | || (!StringUtils.isEmpty(ticket.topic) && !ticket.topic.equals(topic))) {
|
| | | // topic change
|
| | | change.setField(Field.topic, topic);
|
| | | }
|
| | |
| | | if (ticket != null) {
|
| | | TicketNotifier notifier = app().tickets().createNotifier();
|
| | | notifier.sendMailing(ticket);
|
| | | setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
|
| | | redirectTo(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
|
| | | } else {
|
| | | // TODO error
|
| | | }
|
| | | } else {
|
| | | // nothing to change?!
|
| | | setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
|
| | | redirectTo(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));
|
| | | }
|
| | | }
|
| | | });
|