From aa2b9116625c1bcb08da5ba0858c035f847eaa26 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Thu, 26 May 2011 17:53:53 +0200 Subject: [PATCH] SONAR-2388 Make it possible to search for 'false-positive' reviews - Adds select box on the search page - Change comment icon color if false-positive - Add "False positive" label on the permalink page - Adjust link that opens the resource to directly open the resource viewer on the false-positives --- .../app/controllers/reviews_controller.rb | 8 ++++-- .../WEB-INF/app/helpers/application_helper.rb | 6 ++--- .../WEB-INF/app/helpers/users_helper.rb | 8 ++++-- .../views/autocomplete/_text_field.html.erb | 6 ++++- .../app/views/reviews/_review.html.erb | 7 ++++- .../WEB-INF/app/views/reviews/index.html.erb | 18 +++++++++---- .../webapp/images/reviews/+false-positive.png | Bin 849 -> 0 bytes .../main/webapp/images/reviews/+review.png | Bin 976 -> 0 bytes .../webapp/images/reviews/false_positive.png | Bin 0 -> 3118 bytes .../src/main/webapp/images/reviews/review.png | Bin 947 -> 0 bytes .../images/reviews/with_false_positives.png | Bin 0 -> 3092 bytes .../src/main/webapp/stylesheets/style.css | 24 ++++++++++++++---- 12 files changed, 58 insertions(+), 19 deletions(-) delete mode 100644 sonar-server/src/main/webapp/images/reviews/+false-positive.png delete mode 100644 sonar-server/src/main/webapp/images/reviews/+review.png create mode 100644 sonar-server/src/main/webapp/images/reviews/false_positive.png delete mode 100644 sonar-server/src/main/webapp/images/reviews/review.png create mode 100644 sonar-server/src/main/webapp/images/reviews/with_false_positives.png 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 ddf519dca1e..5062feb382d 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 @@ -272,7 +272,8 @@ class ReviewsController < ApplicationController @severities = filter_any(params[:severities]) || [''] @statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN] @projects = filter_any(params[:projects]) || [''] - @id = params[:review_id] || "" + @false_positives = params[:false_positives] || 'without' + @id = params[:review_id] || '' @sort = params[:sort] @asc = params[:asc] == "true" end @@ -285,7 +286,7 @@ class ReviewsController < ApplicationController end def search_reviews - options = { 'false_positives' => 'without' } + options = {} unless @statuses == [''] options['statuses']=@statuses.join(',') end @@ -301,6 +302,9 @@ class ReviewsController < ApplicationController if @assignee_id options['assignees']=@assignee_id.to_s end + if @false_positives + options['false_positives']=@false_positives + end unless @id == '' if is_number? @id options['id'] = @id diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index ccc33e692ff..2922bcf0c92 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -315,13 +315,13 @@ module ApplicationHelper period_index=nil if period_index && period_index<=0 if resource.display_dashboard? if options[:dashboard] - link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title]) + link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title]) else # stay on the same page (for example components) - link_to(name || resource.name, {:overwrite_params => {:id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title]) + link_to(name || resource.name, {:overwrite_params => {:id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title]) end else - link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title]) + link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab], :rule => options[:rule]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title]) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb index a99f1fd7b30..7999bc9c69d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb @@ -117,11 +117,14 @@ module UsersHelper # field that is submitted is a hidden one that contains the user ID that corresponds # to the typed name (if the user exists, of course). # + # The 'options' argument can be used to pass HTML elements to the text field. + # (for the moment 'class' is supported). + # # Example: # <%= user_autocomplete_field "assignee_id", @assignee_id -%> # # => generates an input field for the parameter 'assignee_id' # - def user_autocomplete_field(param_id, param_value) + def user_autocomplete_field(param_id, param_value, options={}) param_id_name = param_id param_id_value = param_value @@ -134,7 +137,8 @@ module UsersHelper server_url = url_for :controller => 'users', :action => 'autocomplete' render :partial => 'autocomplete/text_field', :locals => {:param_id_name => param_id_name, :param_id_value => param_id_value, - :param_displayed_value => param_displayed_value, :server_url => server_url } + :param_displayed_value => param_displayed_value, :server_url => server_url, + :options => options.to_options} end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb index 8675ee22515..2e9b6f047e7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb @@ -1,4 +1,8 @@ - + />