From b899ff096685f5802670af56c3e42a9edea89ce6 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 8 Dec 2010 16:29:52 +0000 Subject: SONAR-1941 improve the select box of periods --- .../java/org/sonar/plugins/core/CorePlugin.java | 2 +- .../WEB-INF/app/helpers/application_helper.rb | 11 ++++----- .../webapp/WEB-INF/app/helpers/dashboard_helper.rb | 9 ++++---- .../webapp/WEB-INF/app/helpers/drilldown_helper.rb | 26 +++++++++++++++++++++- .../src/main/webapp/WEB-INF/app/models/snapshot.rb | 4 ++++ .../WEB-INF/app/views/dashboard/_header.html.erb | 24 +++++++++++--------- .../app/views/drilldown/violations.html.erb | 20 +++++++++-------- 7 files changed, 62 insertions(+), 34 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 2f67910eb81..5e994281585 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -116,7 +116,7 @@ import java.util.List; @Property( key = "sonar.timemachine.variation1", name = "Variation 1", - description = "To be defined. For the moment the number of days", + description = "Period used to compare measures and track new violations. Values are : ", project = false, global = true ), 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 191370f66ac..d240996c7c0 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 @@ -390,7 +390,6 @@ module ApplicationHelper # Display the trend icon : # # === Optional parameters - # * big: true|false. Default is false. # * empty: true|false. Show an empty transparent image when no trend or no measure. Default is false. # # === Examples @@ -405,9 +404,8 @@ module ApplicationHelper m = @snapshot.measure(metric_or_measure) end - big=options[:big]||false if m.nil? || m.tendency.nil? || m.tendency==0 - return options[:empty] ? image_tag("transparent.gif", :width => big ? "18" : "16", :alt => "") : nil + return options[:empty] ? image_tag("transparent.gif", :width => "16", :alt => "") : nil end filename = m.tendency.to_s @@ -419,8 +417,7 @@ module ApplicationHelper when 1 filename+= '-green' end - suffix = (big ? '' : '-small') - image_tag("tendency/#{filename}#{suffix}.png") + image_tag("tendency/#{filename}-small.png") end # @@ -428,7 +425,7 @@ module ApplicationHelper # Numeric value of variation # # === Optional parameters - # * index: integer between 1 and 3. By default the index is defined by the dashboard variation select-box + # * index: integer between 1 and 5. By default the index is defined by the dashboard variation select-box # # === Examples # variation_value('ncloc') @@ -457,7 +454,7 @@ module ApplicationHelper # # === Optional parameters # * color: true|false. Default is true. - # * index: integer between 1 and 3. By default the index is defined by the dashboard variation select-box + # * index: integer between 1 and 5. By default the index is defined by the dashboard variation select-box # # === Examples # format_variation('ncloc') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index 2f97370f9db..4a4ebbe441d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -35,13 +35,13 @@ module DashboardHelper if mode if mode=='days' - label = "Last %s days" % mode_param + label = "Compare to %s previous days" % mode_param elsif mode=='version' - label = "Version %s" % mode_param + label = "Compare to version %s" % mode_param elsif mode=='previous_analysis' - label = "Previous analysis (%s)" % localize(Date.parse(mode_param)) + label = "Compare to previous analysis (%s)" % localize(Date.parse(mode_param)) elsif mode=='date' - label = localize(Date.parse(mode_param)) + label = "Compare to #{localize(Date.parse(mode_param))}" end if label selected=(params[:var]==index.to_s ? 'selected' : '') @@ -50,6 +50,5 @@ module DashboardHelper else nil end - end end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb index 7820bc17503..8f39c478642 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb @@ -18,7 +18,31 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # module DrilldownHelper - include DashboardHelper + + def variation_select_option(snapshot, index) + return nil if snapshot.nil? || snapshot.project_snapshot.nil? + mode=snapshot.project_snapshot.send "variation_mode_#{index}" + mode_param=snapshot.project_snapshot.send "variation_param_#{index}" + + if mode + if mode=='days' + label = "New violations from %s previous days" % mode_param + elsif mode=='version' + label = "New violations since version %s" % mode_param + elsif mode=='previous_analysis' + label = "New violations since previous analysis (%s)" % localize(Date.parse(mode_param)) + elsif mode=='date' + label = "New violations since #{localize(Date.parse(mode_param))}" + end + if label + selected=(params[:var]==index.to_s ? 'selected' : '') + "" + end + else + nil + end + + end def measure_or_variation_value(measure) if measure diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index 94daa90e107..f68b78e331d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -176,6 +176,10 @@ class Snapshot < ActiveRecord::Base project end + def variation_modes? + (variation_mode_1 || variation_mode_2 || variation_mode_3 || variation_mode_4 || variation_mode_5) != nil + end + def resource_id_for_authorization root_project_id || project_id end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index 331bea8eb7c..88d39462456 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -21,17 +21,19 @@ %> <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %> <% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %> - - Compare to -
- -
+ <% if @snapshot.project_snapshot.variation_modes? %> + - +
+ +
+ <% end %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb index b59824efa91..acf1ff3fccd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb @@ -5,16 +5,18 @@ %> <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %> <% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %> +<% if @snapshot.project_snapshot.variation_modes? %> -
- -
+ + +<% end %> -- cgit v1.2.3