diff options
author | James Moger <james.moger@gitblit.com> | 2014-11-20 09:23:32 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-11-20 09:23:32 -0500 |
commit | e2c0c97867829f7db5a95f5e055bb6251cad6a65 (patch) | |
tree | 4f55bdcfe673d61f995544d3979424b1238c1e02 | |
parent | 4f91e35621929e1ebcebcd58bdaa3d858302df74 (diff) | |
download | gitblit-e2c0c97867829f7db5a95f5e055bb6251cad6a65.tar.gz gitblit-e2c0c97867829f7db5a95f5e055bb6251cad6a65.zip |
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.
4 files changed, 35 insertions, 24 deletions
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 @@ </div>
</td></tr>
<tr wicket:id="status"></tr>
+ <tr><th><wicket:message key="gb.severity"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="severity"></select></td></tr>
+ <tr wicket:id="priority"></tr>
<tr wicket:id="responsible"></tr>
<tr wicket:id="milestone"></tr>
- <tr><th><wicket:message key="gb.priority"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="priority"></select></td></tr>
- <tr><th><wicket:message key="gb.severity"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="severity"></select></td></tr>
<tr wicket:id="mergeto"></tr>
</table>
</div>
@@ -73,5 +73,9 @@ <th><wicket:message key="gb.mergeTo"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="mergeto"></select></td>
</wicket:fragment>
+<wicket:fragment wicket:id="priorityFragment">
+ <th><wicket:message key="gb.priority"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="priority"></select></td>
+</wicket:fragment>
+
</wicket:extend>
</html>
\ 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<TicketMilestone> milestoneModel;
private Label descriptionPreview;
-
+
private IModel<TicketModel.Priority> priorityModel;
-
+
private IModel<TicketModel.Severity> severityModel;
public EditTicketPage(PageParameters params) {
@@ -167,6 +167,9 @@ public class EditTicketPage extends RepositoryPage { status.add(new DropDownChoice<TicketModel.Status>("status", statusModel, statusChoices));
form.add(status);
+ List<TicketModel.Severity> severityChoices = Arrays.asList(TicketModel.Severity.choices());
+ form.add(new DropDownChoice<TicketModel.Severity>("severity", severityModel, severityChoices));
+
if (currentUser.canAdmin(ticket, getRepositoryModel())) {
// responsible
Set<String> userlist = new TreeSet<String>(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<TicketMilestone>("milestone", milestoneModel, milestones));
form.add(milestone.setVisible(!milestones.isEmpty()));
// priority
+ Fragment priority = new Fragment("priority", "priorityFragment", this);
List<TicketModel.Priority> priorityChoices = Arrays.asList(TicketModel.Priority.choices());
- form.add(new DropDownChoice<TicketModel.Priority>("priority", priorityModel, priorityChoices));
-
- // severity
- List<TicketModel.Severity> severityChoices = Arrays.asList(TicketModel.Severity.choices());
- form.add(new DropDownChoice<TicketModel.Severity>("severity", severityModel, severityChoices));
-
+ priority.add(new DropDownChoice<TicketModel.Priority>("priority", priorityModel, priorityChoices));
+ form.add(priority);
+
// mergeTo (integration branch)
List<String> branches = new ArrayList<String>();
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 @@ </div>
</td></tr>
<tr><th><wicket:message key="gb.type"></wicket:message><span style="color:red;">*</span></th><td class="edit"><select class="input-large" wicket:id="type"></select></td></tr>
+ <tr><th><wicket:message key="gb.severity"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="severity"></select></td></tr>
+ <tr wicket:id="priority"></tr>
<tr wicket:id="responsible"></tr>
<tr wicket:id="milestone"></tr>
- <tr><th><wicket:message key="gb.priority"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="priority"></select></td></tr>
- <tr><th><wicket:message key="gb.severity"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="severity"></select></td></tr>
<tr wicket:id="mergeto"></tr>
</table>
</div>
@@ -69,5 +69,9 @@ <th><wicket:message key="gb.mergeTo"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="mergeto"></select></td>
</wicket:fragment>
+<wicket:fragment wicket:id="priorityFragment">
+ <th><wicket:message key="gb.priority"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="priority"></select></td>
+</wicket:fragment>
+
</wicket:extend>
</html>
\ 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<TicketMilestone> milestoneModel;
private Label descriptionPreview;
-
+
private IModel<TicketModel.Priority> priorityModel;
-
+
private IModel<TicketModel.Severity> severityModel;
public NewTicketPage(PageParameters params) {
@@ -111,6 +111,7 @@ public class NewTicketPage extends RepositoryPage { form.add(new DropDownChoice<TicketModel.Type>("type", typeModel, Arrays.asList(TicketModel.Type.choices())));
form.add(new TextField<String>("title", titleModel));
form.add(new TextField<String>("topic", topicModel));
+ form.add(new DropDownChoice<TicketModel.Severity>("severity", severityModel, Arrays.asList(TicketModel.Severity.choices())));
final IModel<String> 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<TicketModel.Priority>("priority", priorityModel, Arrays.asList(TicketModel.Priority.choices())));
-
- //severity
- form.add(new DropDownChoice<TicketModel.Severity>("severity", severityModel, Arrays.asList(TicketModel.Severity.choices())));
-
+ Fragment priority = new Fragment("priority", "priorityFragment", this);
+ priority.add(new DropDownChoice<TicketModel.Priority>("priority", priorityModel, Arrays.asList(TicketModel.Priority.choices())));
+ form.add(priority);
+
// integration branch
List<String> branches = new ArrayList<String>();
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) {
|