]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4003 Improve "Action Plans" widget: display or not closed reviews
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Wed, 16 Jan 2013 13:25:08 +0000 (14:25 +0100)
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Wed, 16 Jan 2013 13:25:51 +0000 (14:25 +0100)
=> Make the "Action Plans" widget support a new option to display or
   not the closed reviews in each action plan

plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ActionPlansWidget.java
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/action_plans.html.erb
sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
sonar-server/src/main/webapp/stylesheets/style.css

index f64f68ad1a1db92fce5aeebce6599ddde8616312..eb6ccebdac6122cab3299d2f421e9a51865d445a 100644 (file)
 package org.sonar.plugins.core.widgets;
 
 import org.sonar.api.web.WidgetCategory;
+import org.sonar.api.web.WidgetProperties;
+import org.sonar.api.web.WidgetProperty;
+import org.sonar.api.web.WidgetPropertyType;
 
 @WidgetCategory({"Action plans", "Reviews"})
+@WidgetProperties({
+  @WidgetProperty(key = "showClosedReviews", type = WidgetPropertyType.BOOLEAN, defaultValue = "true")
+})
 public class ActionPlansWidget extends CoreWidget {
   public ActionPlansWidget() {
     super("action_plans", "Action plans", "/org/sonar/plugins/core/widgets/action_plans.html.erb");
   }
-}
\ No newline at end of file
+}
index b318e6e9e73641edcd56e4b9581261bef5070eec..046b45a49ac7d0186f783d08f51335ee04277618 100644 (file)
@@ -931,6 +931,7 @@ widget.action_plans.name=Action plans
 widget.action_plans.description=Shows all the open action plans of the project
 widget.action_plans.title=Open action plans
 widget.action_plans.no_action_plan=No action plan
+widget.action_plans.x_open_reviews={0} open reviews
 
 widget.planned_reviews.name=Planned reviews
 widget.planned_reviews.description=Shows all the planned reviews of the project, gathered by action plan
index 208641dca2b96f33772d75a9ca066806d8784bf8..e6de5f33999c2864392e51bb515fbff5bf028acc 100644 (file)
 <div id="<%= div_id -%>">
 
 <% if open_action_plans.size ==0 %>
+
   <span class="empty_widget"><%= message('widget.action_plans.no_action_plan') -%></span>
-<% else %>
+
+<% 
+   else
+     show_closed_reviews = widget_properties["showClosedReviews"]
+     if show_closed_reviews
+       line_class = "top"
+     else
+       line_class = "middle"
+       max_open_reviews = open_action_plans.map {|plan| plan.open_reviews.size}.max
+     end 
+%>
+
   <table class="width100 actionPlans">
     <thead>
     <tr>
-      <th colspan="3"></th>
+      <th colspan="<%= show_closed_reviews ? '3' : '4' %>"></th>
     </tr>
     </thead>
     <tbody>
          open_action_plans.each do |plan|
       %>
       <tr>
-        <td class="nowrap"><%= h(plan.name) -%></td>
-        <td class="nowrap small <%= 'over-due' if plan.over_due? -%>" style="text-align: right; padding-left:10px"><%= plan.deadline ? plan.deadline.strftime("%d %b %Y") : ' '  -%></td>
-        <% if plan.progress[:total]==0 %>
-        <td class="noprogress nowrap"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
-        <% else %>
-        <td class="progress">
-            <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
-        </td>
+        <td class="nowrap <%= line_class -%>"><%= h(plan.name) -%></td>
+        <td class="nowrap small <%= line_class -%> <%= 'over-due' if plan.over_due? -%>" style="text-align: right; padding-left:10px"><%= plan.deadline ? plan.deadline.strftime("%d %b %Y") : ' '  -%></td>
+        
+        <% if show_closed_reviews %>
+          <% if plan.progress[:total]==0 %>
+            <td class="noprogress nowrap <%= line_class -%>"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
+          <% else %>
+            <td class="progress <%= line_class -%>">
+              <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
+            </td>
+          <% end %>
+        <% 
+           else
+             open_reviews_size = plan.open_reviews.size
+        %>
+          <td class="right note <%= line_class -%>" style="padding-left:20px">
+            <% if open_reviews_size == 0 %>
+              <%= open_reviews_size -%>
+            <% else %>
+              <a href="<%= url_for({:controller => 'project_reviews', :action => 'index', :action_plan_id => plan.id, 
+                                    :id => plan.project_id, :statuses => Review::STATUS_OPEN + ',' + Review::STATUS_REOPENED}) -%>" 
+                 title="<%= message('widget.action_plans.x_open_reviews', :params => open_reviews_size.to_s) -%>"><%= open_reviews_size -%></a>
+            <% end %>
+          </td>
+          <td class="<%= line_class -%>" style="padding: 0 40px 0 10px; width: 300px;">
+            <div class="barchart" style="width: 100%">
+              <div style="width: <%= max_open_reviews > 0 ? 100 * open_reviews_size / max_open_reviews : 0 -%>%;background-color:#777;"></div>
+            </div>
+          </td>
         <% end %>
+        
       </tr>
       <% 
          end 
       %>
     </tbody>
   </table>
+
 <% end %>
   
 </div>
index 4c532642ce8b90d2e2238c5bd08b005767ff3b34..a58c1c11a9a13ca321cbfb6723c36bf5e6b5b449 100644 (file)
@@ -58,7 +58,11 @@ class ActionPlan < ActiveRecord::Base
   end
   
   def has_open_reviews?
-    reviews.select {|r| r.open? || r.reopened?}.size > 0
+    open_reviews.size > 0
+  end
+  
+  def open_reviews
+    reviews.select {|r| r.open? || r.reopened?}
   end
   
   def over_due?
index d76921f08f430b84f26ca9cf04a31a9982d3c0df..2394d8c6dd676575fc95e3e3a1371e2e225aba23 100644 (file)
   text-align: center;
 }
 
+.top {
+  vertical-align: top;
+}
+
+.bottom {
+  vertical-align: bottom;
+}
+
+.middle {
+  vertical-align: middle;
+}
+
 .nowrap {
   white-space: nowrap;
 }
@@ -1031,10 +1043,6 @@ table.actionPlans {
   margin-top: 10px;
 }
 
-table.actionPlans td {
-  vertical-align: top;
-}
-
 table.actionPlans td.progress {
   width: 300px;
   padding: 0px 40px;