From: James Moger Date: Thu, 20 Nov 2014 14:23:32 +0000 (-0500) Subject: Revise severity & priority permissions X-Git-Tag: v1.7.0~1^2~101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e2c0c97867829f7db5a95f5e055bb6251cad6a65;p=gitblit.git Revise severity & priority permissions Ticket reporters should be able to specify severity whereas only those with repository push access should be able to specify priority. This also fixes a bug related to non-admin users creating tickets. --- diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html index e11aed82..b12d0c77 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.html @@ -39,10 +39,10 @@ + + - - @@ -73,5 +73,9 @@ + + + + \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java index 7c02c0be..192b48ca 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditTicketPage.java @@ -83,9 +83,9 @@ public class EditTicketPage extends RepositoryPage { private IModel milestoneModel; private Label descriptionPreview; - + private IModel priorityModel; - + private IModel severityModel; public EditTicketPage(PageParameters params) { @@ -167,6 +167,9 @@ public class EditTicketPage extends RepositoryPage { status.add(new DropDownChoice("status", statusModel, statusChoices)); form.add(status); + List severityChoices = Arrays.asList(TicketModel.Severity.choices()); + form.add(new DropDownChoice("severity", severityModel, severityChoices)); + if (currentUser.canAdmin(ticket, getRepositoryModel())) { // responsible Set userlist = new TreeSet(ticket.getParticipants()); @@ -220,19 +223,17 @@ public class EditTicketPage extends RepositoryPage { milestones.add(new TicketMilestone(NIL)); } + // milestone Fragment milestone = new Fragment("milestone", "milestoneFragment", this); - milestone.add(new DropDownChoice("milestone", milestoneModel, milestones)); form.add(milestone.setVisible(!milestones.isEmpty())); // priority + Fragment priority = new Fragment("priority", "priorityFragment", this); List priorityChoices = Arrays.asList(TicketModel.Priority.choices()); - form.add(new DropDownChoice("priority", priorityModel, priorityChoices)); - - // severity - List severityChoices = Arrays.asList(TicketModel.Severity.choices()); - form.add(new DropDownChoice("severity", severityModel, severityChoices)); - + priority.add(new DropDownChoice("priority", priorityModel, priorityChoices)); + form.add(priority); + // mergeTo (integration branch) List branches = new ArrayList(); for (String branch : getRepositoryModel().getLocalBranches()) { @@ -252,6 +253,7 @@ public class EditTicketPage extends RepositoryPage { form.add(new Label("responsible").setVisible(false)); form.add(new Label("milestone").setVisible(false)); form.add(new Label("mergeto").setVisible(false)); + form.add(new Label("priority").setVisible(false)); } form.add(new AjaxButton("update") { @@ -329,7 +331,7 @@ public class EditTicketPage extends RepositoryPage { change.setField(Field.milestone, milestone.name); } } - + TicketModel.Priority priority = priorityModel.getObject(); if (!ticket.priority.equals(priority)) { @@ -341,7 +343,7 @@ public class EditTicketPage extends RepositoryPage { { change.setField(Field.severity, severity); } - + String mergeTo = mergeToModel.getObject(); if ((StringUtils.isEmpty(ticket.mergeTo) && !StringUtils.isEmpty(mergeTo)) || (!StringUtils.isEmpty(mergeTo) && !mergeTo.equals(ticket.mergeTo))) { diff --git a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.html b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.html index 7b71ada0..9b5af023 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.html @@ -39,10 +39,10 @@ * + + - - @@ -69,5 +69,9 @@ + + + + \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java index ea3e9602..0c52505c 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java @@ -75,9 +75,9 @@ public class NewTicketPage extends RepositoryPage { private IModel milestoneModel; private Label descriptionPreview; - + private IModel priorityModel; - + private IModel severityModel; public NewTicketPage(PageParameters params) { @@ -111,6 +111,7 @@ public class NewTicketPage extends RepositoryPage { form.add(new DropDownChoice("type", typeModel, Arrays.asList(TicketModel.Type.choices()))); form.add(new TextField("title", titleModel)); form.add(new TextField("topic", topicModel)); + form.add(new DropDownChoice("severity", severityModel, Arrays.asList(TicketModel.Severity.choices()))); final IModel markdownPreviewModel = Model.of(); descriptionPreview = new Label("descriptionPreview", markdownPreviewModel); @@ -159,11 +160,10 @@ public class NewTicketPage extends RepositoryPage { form.add(milestone.setVisible(!milestones.isEmpty())); // priority - form.add(new DropDownChoice("priority", priorityModel, Arrays.asList(TicketModel.Priority.choices()))); - - //severity - form.add(new DropDownChoice("severity", severityModel, Arrays.asList(TicketModel.Severity.choices()))); - + Fragment priority = new Fragment("priority", "priorityFragment", this); + priority.add(new DropDownChoice("priority", priorityModel, Arrays.asList(TicketModel.Priority.choices()))); + form.add(priority); + // integration branch List branches = new ArrayList(); for (String branch : getRepositoryModel().getLocalBranches()) { @@ -183,6 +183,7 @@ public class NewTicketPage extends RepositoryPage { form.add(new Label("responsible").setVisible(false)); form.add(new Label("milestone").setVisible(false)); form.add(new Label("mergeto").setVisible(false)); + form.add(new Label("priority").setVisible(false)); } form.add(new AjaxButton("create") { @@ -223,14 +224,14 @@ public class NewTicketPage extends RepositoryPage { if (milestone != null) { change.setField(Field.milestone, milestone.name); } - + // severity TicketModel.Severity severity = TicketModel.Severity.defaultSeverity; if (severityModel.getObject() != null) { severity = severityModel.getObject(); } change.setField(Field.severity, severity); - + // priority TicketModel.Priority priority = TicketModel.Priority.defaultPriority; if (priorityModel.getObject() != null) {