]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4282 Change action plan deadline format to YYYY-MM-DD, change link from action...
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 31 May 2013 08:35:55 +0000 (10:35 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 31 May 2013 08:36:06 +0000 (10:36 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb
sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java

index 72291d3a6be822ad27fde22fa96cf5546e7e3665..f47c1ba034bc7d096e8a65de872564c2385d70fb 100644 (file)
@@ -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
index 5054635cd9a38732b154619743c657b77d556f26..049808fddfc70245582d605a805a5d73bdbd9a9b 100644 (file)
@@ -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>
index 05ea65440dd49bdac148567c9dd3537a71e704ed..1f2884fcfa006768cc40783e6b3184736f702612 100644 (file)
@@ -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"));
       }
     }
index 4a0854f76aa4de36d6f7899499c0707ee8718615..8d38916322ed189d46b02383a120651cc054acc6 100644 (file)
@@ -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)
index 0aab48eee0a61c29c18f91f8651b85b7fbb0becd..9e842a31497e826217e88ac3332205f4e609fc1c 100644 (file)
@@ -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') -%>
index 6ec4fd13590cfbb7ec70e3c3e34a64e08e751f60..7e19c56cb29cb59e3757b9e0f82b1f34bf2a3247 100644 (file)
@@ -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>
index f49177d898999b83891a177e0d173cac4a770cad..336e88c95e2afcbe31f10e4bfada69e554a5a951 100644 (file)
@@ -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();