public synchronized boolean renameMilestone(RepositoryModel repository, String oldName, String newName, String createdBy) {
return renameMilestone(repository, oldName, newName, createdBy, true);
}
-
+
/**
* Renames a milestone.
*
}
Repository db = null;
try {
+ TicketMilestone tm = getMilestone(repository, milestone);
db = repositoryManager.getRepository(repository.name);
StoredConfig config = db.getConfig();
config.unsetSection(MILESTONE, milestone);
milestonesCache.remove(repository.name);
+ for (QueryResult qr : tm.tickets) {
+ if (qr.isOpen()) {
+ // reset the milestone only for open tickets
+ Change change = new Change(createdBy);
+ change.setField(Field.milestone, "");
+ TicketModel ticket = updateTicket(repository, qr.number, change);
+ }
+ }
return true;
} catch (IOException e) {
log.error("failed to delete milestone " + milestone + " in " + repository, e);
import org.apache.wicket.markup.html.form.TextField;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
-import org.parboiled.common.StringUtils;\r
\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.TicketModel;\r
import com.gitblit.models.TicketModel.Status;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.tickets.TicketMilestone;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
\r
public class EditMilestonePage extends RepositoryPage {\r
\r
private final String oldName;\r
- \r
+\r
private IModel<String> nameModel;\r
\r
private IModel<Date> dueModel;\r
- \r
+\r
private IModel<Status> statusModel;\r
- \r
+\r
private IModel<Boolean> notificationModel;\r
\r
public EditMilestonePage(PageParameters params) {\r
// ticket service is read-only\r
throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
}\r
- \r
+\r
UserModel currentUser = GitBlitWebSession.get().getUser();\r
if (currentUser == null) {\r
currentUser = UserModel.ANONYMOUS;\r
// administration prohibited\r
throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
}\r
- \r
+\r
oldName = WicketUtils.getObject(params);\r
if (StringUtils.isEmpty(oldName)) {\r
// milestone not specified\r
throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
}\r
- \r
+\r
TicketMilestone tm = app().tickets().getMilestone(getRepositoryModel(), oldName);\r
if (tm == null) {\r
// milestone does not exist\r
\r
@Override\r
protected void onSubmit() {\r
- \r
+\r
String name = nameModel.getObject();\r
if (StringUtils.isEmpty(name)) {\r
return;\r
}\r
- \r
+\r
Date due = dueModel.getObject();\r
Status status = statusModel.getObject();\r
boolean rename = !name.equals(oldName);\r
boolean notify = notificationModel.getObject();\r
- \r
+\r
UserModel currentUser = GitBlitWebSession.get().getUser();\r
String createdBy = currentUser.username;\r
- \r
+\r
TicketMilestone tm = app().tickets().getMilestone(getRepositoryModel(), oldName);\r
tm.setName(name);\r
tm.setDue(due);\r
tm.status = status;\r
- \r
+\r
boolean success = true;\r
if (rename) {\r
success = app().tickets().renameMilestone(getRepositoryModel(), oldName, name, createdBy, notify);\r
}\r
- \r
+\r
if (success && app().tickets().updateMilestone(getRepositoryModel(), tm, createdBy)) {\r
setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(getRepositoryModel().name));\r
} else {\r
dueModel = Model.of(tm.due);\r
statusModel = Model.of(tm.status);\r
notificationModel = Model.of(true);\r
- \r
+\r
form.add(new TextField<String>("name", nameModel));\r
form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
\r
cancel.setDefaultFormProcessing(false);\r
form.add(cancel);\r
\r
+ Button delete = new Button("delete") {\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onSubmit() {\r
+ UserModel currentUser = GitBlitWebSession.get().getUser();\r
+ String createdBy = currentUser.username;\r
+\r
+ if (app().tickets().deleteMilestone(getRepositoryModel(), oldName, createdBy)) {\r
+ setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
+ } else {\r
+ // TODO error processing\r
+ }\r
+ }\r
+ };\r
+ delete.setDefaultFormProcessing(false);\r
+ form.add(delete);\r
}\r
\r
@Override\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.tickets.TicketMilestone;\r
+import com.gitblit.utils.StringUtils;\r
+import com.gitblit.utils.TimeUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
\r
private IModel<String> nameModel;\r
\r
private IModel<Date> dueModel;\r
- \r
+\r
public NewMilestonePage(PageParameters params) {\r
super(params);\r
\r
// ticket service is read-only\r
throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
}\r
- \r
+\r
UserModel currentUser = GitBlitWebSession.get().getUser();\r
if (currentUser == null) {\r
currentUser = UserModel.ANONYMOUS;\r
\r
@Override\r
protected void onSubmit() {\r
- \r
+\r
String name = nameModel.getObject();\r
+ if (StringUtils.isEmpty(name)) {\r
+ return;\r
+ }\r
+\r
Date due = dueModel.getObject();\r
\r
UserModel currentUser = GitBlitWebSession.get().getUser();\r
String createdBy = currentUser.username;\r
- \r
+\r
TicketMilestone milestone = app().tickets().createMilestone(getRepositoryModel(), name, createdBy);\r
if (milestone != null) {\r
milestone.due = due;\r
add(form);\r
\r
nameModel = Model.of("");\r
- dueModel = Model.of(new Date());\r
- \r
+ dueModel = Model.of(new Date(System.currentTimeMillis() + TimeUtils.ONEDAY));\r
+\r
form.add(new TextField<String>("name", nameModel));\r
form.add(new DateTextField("due", dueModel, "yyyy-MM-dd"));\r
\r