]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 Display action plan on issue detail page
authorJulien Lancelot <julien.lancelot@gmail.com>
Mon, 6 May 2013 12:57:57 +0000 (14:57 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Mon, 6 May 2013 12:57:57 +0000 (14:57 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/java/org/sonar/server/issue/ServerIssueFinder.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_issue.html.erb
sonar-server/src/test/java/org/sonar/server/issue/ServerIssueFinderTest.java

index 1707520ffefc43a8360c78cf55009d7b1eed67be..4973e370057674efcf4875ec1c418f6a04676c08 100644 (file)
@@ -528,6 +528,10 @@ reviews.filtered_by.to=To date
 #------------------------------------------------------------------------------
 
 issues.issue_number=Issue #{0}
+issues.no_action_plan=None
+issues.planned_for_x=Planned for {0}
+issues.planned_for_label=Planned for
+issues.an_action_plan_must_be_created_first=An action plan should be first created to plan the remediation effort of this violation.
 issues.hide_this_message=Hide this message
 issues.user_does_not_exist=\ : user does not exist. \\nPlease select a valid user or leave the field blank.
 issues.new_severity_label=New severity:
index 864d6e43036ec6d65a53f57a0e4d5f8376b431bd..51e82d1cd0e6f4640b518fdbc6ff5235fa46bc0e 100644 (file)
@@ -99,6 +99,7 @@ public class ServerIssueFinder implements IssueFinder {
 
           ruleIds.add(dto.getRuleId());
           componentIds.add(dto.getResourceId());
+          actionPlanKeys.add(dto.getActionPlanKey());
         }
       }
 
index 5c6690ec503d212a3f286ba6d1424e63397aa466..aeb725b5dad333374a241cc0f22836676e58b08a 100644 (file)
@@ -33,7 +33,8 @@ class Api::IssuesController < Api::ApiController
             :securityExclusions => results.securityExclusions,
             :paging => paging_to_json(results.paging),
             :issues => results.issues.map { |issue| issue_to_json(issue) },
-            :rules => results.rules.map { |rule| rule_to_json(rule) }
+            :rules => results.rules.map { |rule| rule_to_json(rule) },
+            :actionPlans => results.actionPlans.map { |action_plan| action_plan_to_json(action_plan) }
         }
     )
   end
@@ -183,6 +184,7 @@ class Api::IssuesController < Api::ApiController
         :rule => issue.ruleKey.toString(),
         :status => issue.status
     }
+    json[:actionPlan] = issue.actionPlanKey if issue.actionPlanKey
     json[:resolution] = issue.resolution if issue.resolution
     json[:severity] = issue.severity if issue.severity
     json[:desc] = issue.description if issue.description
@@ -216,6 +218,16 @@ class Api::IssuesController < Api::ApiController
     json
   end
 
+  def action_plan_to_json(action_plan)
+    json = {:key => action_plan.key(), :name => action_plan.name(), :status => action_plan.status()}
+    json[:desc] = action_plan.description() if action_plan.description() && !action_plan.description().blank?
+    json[:userLogin] = action_plan.userLogin() if action_plan.userLogin()
+    json[:deadLine] = format_java_datetime(action_plan.deadLine()) if action_plan.deadLine()
+    json[:creationDate] = format_java_datetime(action_plan.creationDate()) if action_plan.creationDate()
+    json[:updateDate] = format_java_datetime(action_plan.updateDate()) if action_plan.updateDate()
+    json
+  end
+
   def paging_to_json(paging)
     {
         :pageIndex => paging.pageIndex,
index d9e31eb255feec1e000ae115a6b7c182ff604cce..c5ed9cf1ec70f1dacc678ca76621a1915db016b0 100644 (file)
@@ -177,8 +177,8 @@ class IssueController < ApplicationController
   protected
 
   def init_issue(issue_key)
-    issue_result = find_issue(issue_key)
-    @issue = issue_result.issues[0]
+    @issue_result = find_issue(issue_key)
+    @issue = @issue_result.issues[0]
   end
 
   def init_resource
index 6a0c2fb39c16a4f5b145acec66283074ff20ab33..e2237ca947e3216ffff0275d48e3335700280f59 100644 (file)
         <%= l(Api::Utils.to_date(@issue.updateDate())) if @issue.updateDate() -%>
       </td>
     </tr>
-
-    <% # TODO action plan %>
-
-
+    <% if @issue.actionPlanKey() %>
+      <% action_plan = @issue_result.actionPlan(@issue) %>
+      <tr>
+        <td class="key">
+          <%= message('issues.planned_for_label') -%>:
+        </td>
+        <td class="val" colspan="3">
+          <%= h(action_plan.name()) -%>
+        </td>
+      </tr>
+    <% end %>
     <% if @issue.rule_key %>
-      <% rule_name = Internal.rules.ruleL10nName(@issue.rule_key) %>
+      <% rule_name = Internal.rules.ruleL10nName(@issue_result.rule(@issue)) %>
       <tr>
         <td class="key">
           <%= message('rule') -%>:
index d17782ac261083e4ee7f32fe4ace82c515dba648..372fcd57625fac313e6b6f78489af8be67a0bb7b 100644 (file)
@@ -37,7 +37,6 @@
       <% end %>
       <%
          # TODO display assignee name instead of login
-         #if violation.review && violation.review.assignee_id
          if issue.assignee
       %>
         <%= image_tag 'sep12.png' -%>
index 114d377f1afc7a733ed454c1342da092878fb66b..0b1429c4aeb3aec46516a21e1600cd2141baf64d 100644 (file)
@@ -197,13 +197,12 @@ public class ServerIssueFinderTest {
     when(issueDao.selectIssueIdsAndComponentsId(eq(query), any(SqlSession.class))).thenReturn(dtoList);
     when(issueDao.selectByIds(anyCollection(), any(SqlSession.class))).thenReturn(dtoList);
 
-
     IssueFinder.Results results = finder.find(query, null, UserRole.USER);
     assertThat(results.issues()).hasSize(2);
-    Issue issue = results.issues().iterator().next();
     assertThat(results.issues()).hasSize(2);
-    assertThat(results.component(issue)).isEqualTo(component);
     assertThat(results.components()).hasSize(1);
+    Issue issue = results.issues().iterator().next();
+    assertThat(results.component(issue)).isEqualTo(component);
   }
 
   @Test
@@ -225,11 +224,11 @@ public class ServerIssueFinderTest {
     List<IssueDto> dtoList = newArrayList(issue1, issue2);
     when(issueDao.selectIssueIdsAndComponentsId(eq(query), any(SqlSession.class))).thenReturn(dtoList);
     when(issueDao.selectByIds(anyCollection(), any(SqlSession.class))).thenReturn(dtoList);
-
     when(actionPlanFinder.findByKeys(anyCollection())).thenReturn(newArrayList(actionPlan1, actionPlan2));
 
     IssueFinder.Results results = finder.find(query, null, UserRole.USER);
     assertThat(results.issues()).hasSize(2);
+    assertThat(results.actionPlans()).hasSize(2);
     Issue issue = results.issues().iterator().next();
     assertThat(results.actionPlan(issue)).isNotNull();
   }