From 5d490dfffa66bfc7802c97ca0498331a04fc4094 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 31 May 2013 10:35:55 +0200 Subject: [PATCH] SONAR-4282 Change action plan deadline format to YYYY-MM-DD, change link from action plan widget, removed option "unplanned" in code viewer --- .../main/resources/org/sonar/l10n/core.properties | 6 +++--- .../core/widgets/issues/action_plans.html.erb | 2 +- .../sonar/server/issue/InternalRubyIssueService.java | 12 ++++++------ .../WEB-INF/app/controllers/issue_controller.rb | 2 ++ .../WEB-INF/app/views/action_plans/index.html.erb | 2 +- .../WEB-INF/app/views/issue/_plan_form.html.erb | 7 ++++--- .../server/issue/InternalRubyIssueServiceTest.java | 10 +++++----- 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 @@
<% if has_role?(:admin, @project) %>
- + <%= message('widgets.more') -%>
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 @@ "/> <%= h(plan.name()) -%> - <%= format_date(plan.deadLine(), :time_if_today => true) -%> + <%= format_date(plan.deadLine()) -%> <% if plan.totalIssues()==0 %> <%= 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 @@ %>
- + <%= 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' -%>   - + <% end %> <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>  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 actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); Result result = internalRubyIssueService.createActionPlan(parameters); @@ -81,7 +81,7 @@ public class InternalRubyIssueServiceTest { Map 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 actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); Result result = internalRubyIssueService.updateActionPlan("ABCD", parameters); @@ -104,7 +104,7 @@ public class InternalRubyIssueServiceTest { Map 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 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(); -- 2.39.5