From 033b6d93dcf2ef91b481fc242ec724902dbd75e1 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 20 Apr 2011 15:24:07 +0200 Subject: [PATCH] SONAR-1973 Add possibility to show only switched-off violations --- .../WEB-INF/app/controllers/resource_controller.rb | 11 ++++++++++- .../WEB-INF/app/controllers/reviews_controller.rb | 2 +- .../WEB-INF/app/views/resource/_options.html.erb | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index bc4d569dd8d..e9cf723d21d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -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< ['rule', 'reviews' ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| # sorted by severity => from blocker to info diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb index ca8ef32259a..a0efbef1645 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -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] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb index 7e765102206..e1594d7d441 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb @@ -49,6 +49,10 @@ end %> <% if @display_violations %> + + onclick="applyOptions()"/> + +