aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-05-31 10:35:55 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-05-31 10:36:06 +0200
commit5d490dfffa66bfc7802c97ca0498331a04fc4094 (patch)
treeaf6f6dfe114553b4225deed84dfe3d7a6671a3ab
parent942d823359234eb9cdd9e42c33235d2a5e96375b (diff)
downloadsonarqube-5d490dfffa66bfc7802c97ca0498331a04fc4094.tar.gz
sonarqube-5d490dfffa66bfc7802c97ca0498331a04fc4094.zip
SONAR-4282 Change action plan deadline format to YYYY-MM-DD, change link from action plan widget, removed option "unplanned" in code viewer
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties6
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb7
-rw-r--r--sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java10
7 files changed, 22 insertions, 19 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index 72291d3a6be..f47c1ba034b 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -541,8 +541,8 @@ issue.transition.resolve=Resolve
issue.transition.falsepositive=False-Positive
issue.transition.reopen=Reopen
issue.transition.close=Close
-issue.set_severity=Set Severity
-issue.set_severity.submit=Set Severity
+issue.set_severity=Change Severity
+issue.set_severity.submit=Change Severity
issue.do_plan=Plan
issue.plan.submit=Plan
issue.unplanned=Unplanned
@@ -638,7 +638,7 @@ action_plans.confirm_close=Close this action plan? There are still open issues l
action_plans.create_form_title=Create Action Plan
action_plans.edit_action_plan=Edit Action Plan
action_plans.same_name_in_same_project=An action plan with this name already exists in this project.
-action_plans.date_format_help=The date should be entered using the following pattern: 'day/month/year'. For instance, '31/12/2011'.
+action_plans.date_format_help=The date should be entered using the following pattern: 'year-month-day'. For instance, '2014-12-31'.
action_plans.date_not_valid=Date not valid
action_plans.date_cant_be_in_past=The dead-line can't be in the past
action_plans.closed_action_plan=Closed Action Plans
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb
index 5054635cd9a..049808fddfc 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb
@@ -9,7 +9,7 @@
<div class="line-block">
<% if has_role?(:admin, @project) %>
<div style="float:right">
- <a href="<%= url_for :controller => 'issues_action_plans', :action => 'index', :id => @project.id -%>">
+ <a href="<%= url_for :controller => 'action_plans', :action => 'index', :id => @project.id -%>">
<%= message('widgets.more') -%>
</a>
</div>
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
index 05ea65440dd..1f2884fcfa0 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
@@ -23,13 +23,14 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.issue.ActionPlan;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueComment;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.SonarException;
import org.sonar.core.issue.ActionPlanStats;
import org.sonar.core.issue.DefaultActionPlan;
import org.sonar.core.issue.DefaultIssue;
@@ -42,7 +43,7 @@ import org.sonar.server.user.UserSession;
import org.sonar.server.util.RubyUtils;
import javax.annotation.Nullable;
-import java.text.SimpleDateFormat;
+
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -268,13 +269,12 @@ public class InternalRubyIssueService implements ServerComponent {
if (!Strings.isNullOrEmpty(deadLineParam)) {
try {
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- deadLine = dateFormat.parse(deadLineParam);
+ deadLine = DateUtils.parseDate(deadLineParam);
Date today = new Date();
- if (deadLine.before(today) && !DateUtils.isSameDay(deadLine, today)) {
+ if (deadLine.before(today) && !org.apache.commons.lang.time.DateUtils.isSameDay(deadLine, today)) {
result.addError(Result.Message.ofL10n("action_plans.date_cant_be_in_past"));
}
- } catch (Exception e) {
+ } catch (SonarException e) {
result.addError(Result.Message.ofL10n("errors.is_not_valid", "date"));
}
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
index 4a0854f76aa..8d38916322e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
@@ -82,6 +82,8 @@ class IssueController < ApplicationController
Internal.issues.setSeverity(issue_key, params[:severity])
elsif action_type=='plan'
Internal.issues.plan(issue_key, params[:plan])
+ elsif action_type=='unplan'
+ Internal.issues.plan(issue_key, nil)
end
@issue_results = Api.issues.find(issue_key)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
index 0aab48eee0a..9e842a31497 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
@@ -27,7 +27,7 @@
<td class="thin nowrap center">
<img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status() -%>.png" title="<%= message("action_plans.status.#{plan.status}") -%>"/></td>
<td class="thin nowrap"><%= h(plan.name()) -%></td>
- <td class="thin nowrap <%= 'over-due' if plan.overDue() -%>" align="right"><%= format_date(plan.deadLine(), :time_if_today => true) -%></td>
+ <td class="thin nowrap <%= 'over-due' if plan.overDue() -%>" align="right"><%= format_date(plan.deadLine()) -%></td>
<% if plan.totalIssues()==0 %>
<td class="noprogress thin nowrap">
<%= message('action_plans.no_issues_linked_to_action_plan') -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb
index 6ec4fd13590..7e19c56cb29 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb
@@ -10,7 +10,7 @@
<%
else
first_plan = plans[0]
- plan_options = options_for_select([[message('issue.unplanned'), '']] + plans.map { |plan|
+ plan_options = options_for_select(plans.map { |plan|
if plan.deadLine
label = "#{h plan.name} (#{format_date(plan.deadLine)})"
else
@@ -22,7 +22,7 @@
%>
<form method="POST">
<input type="hidden" name="issue" value="<%= params[:issue] -%>"/>
- <input type="hidden" name="id" value="plan"/>
+ <input type="hidden" id="action-<%= plans_select_box_id %>" name="id" value="plan"/>
<%= dropdown_tag('plan', plan_options, {:show_search_box => false}, {:id => plans_select_box_id}) -%>
@@ -31,7 +31,8 @@
<% if @issue.actionPlanKey %>
<%= image_tag 'sep12.png' -%>
&nbsp;
- <input type="button" value="<%= message('issue.unplan.submit') -%>" onclick="$j('#<%= plans_select_box_id -%>').val('');$j('#<%= plans_select_box_id -%>').prop('disabled', false);submitIssueForm(this)">
+ <input type="button" value="<%= message('issue.unplan.submit') -%>"
+ onclick="$j('#action-<%= plans_select_box_id %>').val('unplan'); $j('#<%= plans_select_box_id -%>').prop('disabled', false); submitIssueForm(this)">
<% end %>
<%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>&nbsp;
<span class="loading hidden"></span>
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java
index f49177d8989..336e88c95e2 100644
--- a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java
@@ -58,7 +58,7 @@ public class InternalRubyIssueServiceTest {
parameters.put("name", "Long term");
parameters.put("description", "Long term issues");
parameters.put("project", "org.sonar.Sample");
- parameters.put("deadLine", "13/05/2113");
+ parameters.put("deadLine", "2113-05-13");
ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class);
Result result = internalRubyIssueService.createActionPlan(parameters);
@@ -81,7 +81,7 @@ public class InternalRubyIssueServiceTest {
Map<String, String> parameters = newHashMap();
parameters.put("name", "New Long term");
parameters.put("description", "New Long term issues");
- parameters.put("deadLine", "13/05/2113");
+ parameters.put("deadLine", "2113-05-13");
ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class);
Result result = internalRubyIssueService.updateActionPlan("ABCD", parameters);
@@ -104,7 +104,7 @@ public class InternalRubyIssueServiceTest {
Map<String, String> parameters = newHashMap();
parameters.put("name", "New Long term");
parameters.put("description", "New Long term issues");
- parameters.put("deadLine", "13/05/2113");
+ parameters.put("deadLine", "2113-05-13");
parameters.put("project", "org.sonar.MultiSample");
ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class);
@@ -221,7 +221,7 @@ public class InternalRubyIssueServiceTest {
parameters.put("name", "Long term");
parameters.put("description", "Long term issues");
parameters.put("project", "org.sonar.Sample");
- parameters.put("deadLine", "2013-05-18");
+ parameters.put("deadLine", "18/05/2013");
Result result = internalRubyIssueService.createActionPlanResult(parameters);
assertThat(result.ok()).isFalse();
@@ -234,7 +234,7 @@ public class InternalRubyIssueServiceTest {
parameters.put("name", "Long term");
parameters.put("description", "Long term issues");
parameters.put("project", "org.sonar.Sample");
- parameters.put("deadLine", "01/01/2000");
+ parameters.put("deadLine", "2000-01-01");
Result result = internalRubyIssueService.createActionPlanResult(parameters);
assertThat(result.ok()).isFalse();