]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1973 Add possibility to show only switched-off violations
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 20 Apr 2011 13:24:07 +0000 (15:24 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Wed, 20 Apr 2011 13:25:23 +0000 (15:25 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb

index bc4d569dd8db64a8b820eb5320ea343c9812202a..e9cf723d21d66cee616d363c20587603a7428d9f 100644 (file)
@@ -171,7 +171,7 @@ class ResourceController < ApplicationController
     @expandable=(@lines!=nil)
     @filtered=!@expanded
 
-    conditions='switched_off is not true AND snapshot_id=?'
+    conditions='snapshot_id=?'
     values=[@snapshot.id]
     unless params[:rule].blank?
       severity=Sonar::RulePriority.id(params[:rule])
@@ -194,6 +194,15 @@ class ResourceController < ApplicationController
         conditions+=' AND id=-1'
       end
     end
+    
+    if params[:switchedOff]
+      @switchedOff=true
+      conditions+='AND switched_off=?'
+      values<<true
+    else
+      conditions+='AND (switched_off IS NULL OR switched_off=?)'
+      values<<false
+    end
 
     RuleFailure.find(:all, :include => ['rule', 'reviews' ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation|
       # sorted by severity => from blocker to info
index ca8ef32259a1ed98e3f8dbb0942f633f3cb0ee53..a0efbef164588b4713ee3e020aaaf719022136ef 100644 (file)
@@ -199,7 +199,7 @@ class ReviewsController < ApplicationController
   def add_all_users ( user_options )
     User.find( :all ).each do |user|
       userName = user.name
-      if current_user.id == user.id
+      if current_user && current_user.id == user.id
         userName = "Me (" + user.name + ")"
       end
       user_options << [userName, user.id.to_s]
index 7e76510220662e227bdc2f467cbd9100ba86abf8..e1594d7d44105fd6c031585f9c1bea8274789ca9 100644 (file)
          end %>
 
       <% if @display_violations %>
+        <td class="<%= 'first' if first -%>">
+          <input type="checkbox" value="true" name="switchedOff" id="switchedOff" <%= 'checked' if @switchedOff -%> onclick="applyOptions()"/>
+          <label for="expand">Show only switched-off violations</label>
+        </td>
         <td class="<%= 'first' if first -%>">
           <select id="period" name="period" onchange="applyOptions()">
             <option value="">Time changes...</option>