From 296b3716fd5905febeab28abbc40c8e06b2b3fe7 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Fri, 25 Nov 2011 17:04:40 +0100 Subject: [PATCH] SONAR-2399 Fix small bug on widget parameter retrieval => if the user sets the numberOfLines parameter to blank (''), then the widget can't be displayed any more. --- .../org/sonar/plugins/core/widgets/hotspot_metric.html.erb | 5 +---- .../core/widgets/hotspot_most_violated_resources.html.erb | 7 ++----- .../core/widgets/hotspot_most_violated_rules.html.erb | 4 ++-- .../core/widgets/reviews/false_positive_reviews.html.erb | 5 +---- .../sonar/plugins/core/widgets/reviews/my_reviews.html.erb | 5 +---- .../plugins/core/widgets/reviews/project_reviews.html.erb | 5 +---- .../core/widgets/reviews/reviews_per_developer.html.erb | 6 +++--- .../views/project/widgets/reviews/_reviews_list.html.erb | 2 +- 8 files changed, 12 insertions(+), 27 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_metric.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_metric.html.erb index 2317e2b944f..be88c230523 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_metric.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_metric.html.erb @@ -3,10 +3,7 @@ unless metric metric = Metric.find(:first, :conditions => "name = 'ncloc'") end - limit = widget_properties["numberOfLines"] - unless limit - limit = 5 - end + limit = widget_properties["numberOfLines"].to_i==0 ? 5 : widget_properties["numberOfLines"].to_i title = widget_properties["title"] unless title && !title.blank? title = message('widget.hotspot_metric.hotspots_by_x', :params => metric.short_name) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_resources.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_resources.html.erb index f4f5d2dd9e8..29253dfcdfc 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_resources.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_resources.html.erb @@ -1,9 +1,6 @@ <% - limit = widget_properties["numberOfLines"] - unless limit - limit = 5 - end - + limit = widget_properties["numberOfLines"].to_i==0 ? 5 : widget_properties["numberOfLines"].to_i + metric = Metric.find(:first, :conditions => "name = 'weighted_violations'") snapshots_conditions=["snapshots.scope = 'FIL'", "snapshots.islast=:islast"] diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_rules.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_rules.html.erb index 8807f5f17e4..fbf36cdba4d 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_rules.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/hotspot_most_violated_rules.html.erb @@ -1,6 +1,6 @@ <% - limit = widget_properties["numberOfLines"] || 5 - metric_prefix = dashboard_configuration.selected_period? ? 'new_' : '' + limit = widget_properties["numberOfLines"].to_i==0 ? 5 : widget_properties["numberOfLines"].to_i + metric_prefix = dashboard_configuration.selected_period? ? 'new_' : '' value_column = (dashboard_configuration.selected_period? ? "variation_value_#{dashboard_configuration.period_index}" : 'value') measures_by_severity = {} all_measures=[] diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb index 0db06754409..1fdb0177c4b 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/false_positive_reviews.html.erb @@ -1,9 +1,6 @@ <% if has_role?(:user, @project) - limit = widget_properties["numberOfLines"] - unless limit - limit = 5 - end + limit = widget_properties["numberOfLines"].to_i == 0 ? 5 : widget_properties["numberOfLines"].to_i %>

<%= message('widget.false_positive_reviews.name') -%>

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb index 293acfdc33f..0fb0c9d7ace 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/my_reviews.html.erb @@ -1,9 +1,6 @@ <% if current_user && has_role?(:user, @project) - limit = widget_properties["numberOfLines"] - unless limit - limit = 5 - end + limit = widget_properties["numberOfLines"].to_i == 0 ? 5 : widget_properties["numberOfLines"].to_i %>

<%= message('widget.my_reviews.name') -%>

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb index d4efe7a928b..943d37920c2 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/project_reviews.html.erb @@ -1,9 +1,6 @@ <% if has_role?(:user, @project) - limit = widget_properties["numberOfLines"] - unless limit - limit = 5 - end + limit = widget_properties["numberOfLines"].to_i == 0 ? 5 : widget_properties["numberOfLines"].to_i %>

<%= message('widget.project_reviews.name') -%>

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb index b2d722bd16a..fca5f3cc0a3 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/reviews_per_developer.html.erb @@ -2,7 +2,7 @@ options = {} options['statuses'] = 'OPEN,REOPENED' options['projects'] = @project.key - if params[:period] + if @dashboard_configuration.selected_period? from_date = dashboard_configuration.from_datetime options['from'] = from_date to_date = @snapshot.created_at @@ -61,7 +61,7 @@ :projects => [@project.id], :from => from_date, :to => to_date -%> - <%= '+' if params[:period] && !params[:period].blank? -%><%= count.to_s -%> + <%= '+' if @dashboard_configuration.selected_period? -%><%= count.to_s -%> <% if counter_max > 0 %> @@ -81,7 +81,7 @@ :projects => [@project.id], :from => from_date, :to => to_date -%> - <%= '+' if params[:period] && !params[:period].blank? -%><%= counter_no_assignee.to_s -%> + <%= '+' if @dashboard_configuration.selected_period? -%><%= counter_no_assignee.to_s -%> <% if counter_max > 0 %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list.html.erb index b5556c89ef1..f7605f0deb8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/reviews/_reviews_list.html.erb @@ -12,7 +12,7 @@ options['projects'] = project_key options['resolutions'] = resolution options['sort'] = 'updated_at' - if params[:period] + if @dashboard_configuration.selected_period? from_date = @dashboard_configuration.from_datetime options['from'] = from_date to_date = @snapshot.created_at -- 2.39.5