status.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));\r
form.add(status);\r
\r
- // responsible\r
- Set<String> userlist = new TreeSet<String>(ticket.getParticipants());\r
+ if (currentUser.canAdmin(ticket, getRepositoryModel())) {\r
+ // responsible\r
+ Set<String> userlist = new TreeSet<String>(ticket.getParticipants());\r
\r
- for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
- if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {\r
- userlist.add(rp.registrant);\r
+ for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
+ if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {\r
+ userlist.add(rp.registrant);\r
+ }\r
}\r
- }\r
\r
- List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
- for (String username : userlist) {\r
- UserModel user = app().users().getUserModel(username);\r
- if (user != null) {\r
- TicketResponsible responsible = new TicketResponsible(user);\r
- responsibles.add(responsible);\r
- if (user.username.equals(ticket.responsible)) {\r
- responsibleModel.setObject(responsible);\r
+ List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
+ for (String username : userlist) {\r
+ UserModel user = app().users().getUserModel(username);\r
+ if (user != null) {\r
+ TicketResponsible responsible = new TicketResponsible(user);\r
+ responsibles.add(responsible);\r
+ if (user.username.equals(ticket.responsible)) {\r
+ responsibleModel.setObject(responsible);\r
+ }\r
}\r
}\r
- }\r
- Collections.sort(responsibles);\r
- responsibles.add(new TicketResponsible(NIL, "", ""));\r
- Fragment responsible = new Fragment("responsible", "responsibleFragment", this);\r
- responsible.add(new DropDownChoice<TicketResponsible>("responsible", responsibleModel, responsibles));\r
- form.add(responsible.setVisible(!responsibles.isEmpty()));\r
-\r
- // milestone\r
- List<TicketMilestone> milestones = app().tickets().getMilestones(getRepositoryModel(), Status.Open);\r
- for (TicketMilestone milestone : milestones) {\r
- if (milestone.name.equals(ticket.milestone)) {\r
- milestoneModel.setObject(milestone);\r
- break;\r
+ Collections.sort(responsibles);\r
+ responsibles.add(new TicketResponsible(NIL, "", ""));\r
+ Fragment responsible = new Fragment("responsible", "responsibleFragment", this);\r
+ responsible.add(new DropDownChoice<TicketResponsible>("responsible", responsibleModel, responsibles));\r
+ form.add(responsible.setVisible(!responsibles.isEmpty()));\r
+\r
+ // milestone\r
+ List<TicketMilestone> milestones = app().tickets().getMilestones(getRepositoryModel(), Status.Open);\r
+ for (TicketMilestone milestone : milestones) {\r
+ if (milestone.name.equals(ticket.milestone)) {\r
+ milestoneModel.setObject(milestone);\r
+ break;\r
+ }\r
+ }\r
+ if (milestoneModel.getObject() == null && !StringUtils.isEmpty(ticket.milestone)) {\r
+ // ensure that this unrecognized milestone is listed\r
+ // so that we get the <nil> selection.\r
+ TicketMilestone tms = new TicketMilestone(ticket.milestone);\r
+ milestones.add(tms);\r
+ milestoneModel.setObject(tms);\r
+ }\r
+ if (!milestones.isEmpty()) {\r
+ milestones.add(new TicketMilestone(NIL));\r
}\r
- }\r
- if (milestoneModel.getObject() == null && !StringUtils.isEmpty(ticket.milestone)) {\r
- // ensure that this unrecognized milestone is listed\r
- // so that we get the <nil> selection.\r
- TicketMilestone tms = new TicketMilestone(ticket.milestone);\r
- milestones.add(tms);\r
- milestoneModel.setObject(tms);\r
- }\r
- if (!milestones.isEmpty()) {\r
- milestones.add(new TicketMilestone(NIL));\r
- }\r
\r
- Fragment milestone = new Fragment("milestone", "milestoneFragment", this);\r
+ Fragment milestone = new Fragment("milestone", "milestoneFragment", this);\r
\r
- milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
- form.add(milestone.setVisible(!milestones.isEmpty()));\r
+ milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
+ form.add(milestone.setVisible(!milestones.isEmpty()));\r
\r
- // mergeTo (integration branch)\r
- List<String> branches = new ArrayList<String>();\r
- for (String branch : getRepositoryModel().getLocalBranches()) {\r
- // exclude ticket branches\r
- if (!branch.startsWith(Constants.R_TICKET)) {\r
- branches.add(Repository.shortenRefName(branch));\r
+ // mergeTo (integration branch)\r
+ List<String> branches = new ArrayList<String>();\r
+ for (String branch : getRepositoryModel().getLocalBranches()) {\r
+ // exclude ticket branches\r
+ if (!branch.startsWith(Constants.R_TICKET)) {\r
+ branches.add(Repository.shortenRefName(branch));\r
+ }\r
}\r
- }\r
- branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
- branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
-\r
- Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
- mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
- form.add(mergeto.setVisible(!branches.isEmpty()));\r
+ branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
+ branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
\r
+ Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
+ mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
+ form.add(mergeto.setVisible(!branches.isEmpty()));\r
+ } else {\r
+ // user can not admin this ticket\r
+ form.add(new Label("responsible").setVisible(false));\r
+ form.add(new Label("milestone").setVisible(false));\r
+ form.add(new Label("mergeto").setVisible(false));\r
+ }\r
form.add(new Button("update"));\r
Button cancel = new Button("cancel") {\r
private static final long serialVersionUID = 1L;\r
import org.apache.wicket.markup.html.panel.Fragment;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
+import org.eclipse.jgit.lib.Repository;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.Constants.AccessPermission;\r
import com.gitblit.models.RegistrantAccessPermission;\r
import com.gitblit.models.TicketModel;\r
\r
private IModel<String> topicModel;\r
\r
+ private IModel<String> mergeToModel;\r
+\r
private IModel<TicketResponsible> responsibleModel;\r
\r
private IModel<TicketMilestone> milestoneModel;\r
typeModel = Model.of(TicketModel.Type.defaultType);\r
titleModel = Model.of();\r
topicModel = Model.of();\r
+ mergeToModel = Model.of(Repository.shortenRefName(getRepositoryModel().HEAD));\r
responsibleModel = Model.of();\r
milestoneModel = Model.of();\r
\r
change.setField(Field.milestone, milestone.name);\r
}\r
\r
+ // integration branch\r
+ String mergeTo = mergeToModel.getObject();\r
+ if (!StringUtils.isEmpty(mergeTo)) {\r
+ change.setField(Field.mergeTo, mergeTo);\r
+ }\r
+\r
TicketModel ticket = app().tickets().createTicket(getRepositoryModel(), 0L, change);\r
if (ticket != null) {\r
TicketNotifier notifier = app().tickets().createNotifier();\r
descriptionEditor.setRepository(repositoryName);\r
form.add(descriptionEditor);\r
\r
- if (currentUser != null && currentUser.isAuthenticated && currentUser.canPush(getRepositoryModel())) {\r
+ if (currentUser.canAdmin(null, getRepositoryModel())) {\r
// responsible\r
List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();\r
for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {\r
Fragment milestone = new Fragment("milestone", "milestoneFragment", this);\r
milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
form.add(milestone.setVisible(!milestones.isEmpty()));\r
+\r
+ // integration branch\r
+ List<String> branches = new ArrayList<String>();\r
+ for (String branch : getRepositoryModel().getLocalBranches()) {\r
+ // exclude ticket branches\r
+ if (!branch.startsWith(Constants.R_TICKET)) {\r
+ branches.add(Repository.shortenRefName(branch));\r
+ }\r
+ }\r
+ branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
+ branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
+\r
+ Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
+ mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
+ form.add(mergeto.setVisible(!branches.isEmpty()));\r
} else {\r
- // user does not have permission to assign milestone or responsible\r
+ // user does not have permission to assign milestone, responsible, or mergeto\r
form.add(new Label("responsible").setVisible(false));\r
form.add(new Label("milestone").setVisible(false));\r
+ form.add(new Label("mergeto").setVisible(false));\r
}\r
\r
form.add(new Button("create"));\r