summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-08 16:29:52 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-08 16:29:52 +0000
commitb899ff096685f5802670af56c3e42a9edea89ce6 (patch)
tree221b469af423b0a102cc26a22dce39b3ff759833
parente72a923c48b7a428f2d43c105a4d72cb0a289546 (diff)
downloadsonarqube-b899ff096685f5802670af56c3e42a9edea89ce6.tar.gz
sonarqube-b899ff096685f5802670af56c3e42a9edea89ce6.zip
SONAR-1941 improve the select box of periods
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb26
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb24
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb20
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 : <ul><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
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' : '')
+ "<option value='#{index}' #{selected}>#{label}</option>"
+ 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
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
- <select id="select-comparison" name="var" onchange="submit()" class="small">
- <option value=""></option>
- <%= variation_select_option(@snapshot, 1) -%>
- <%= variation_select_option(@snapshot, 2) -%>
- <%= variation_select_option(@snapshot, 3) -%>
- <%= variation_select_option(@snapshot, 4) -%>
- <%= variation_select_option(@snapshot, 5) -%>
- </select>
- </form>
+ <% if @snapshot.project_snapshot.variation_modes? %>
+ -
+ <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">Display trends</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+ <% end %>
</h4>
</div>
<% 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? %>
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
- <select id="select-comparison" name="var" onchange="submit()" class="small">
- <option value="">All violations</option>
- <%= variation_select_option(@snapshot, 1) -%>
- <%= variation_select_option(@snapshot, 2) -%>
- <%= variation_select_option(@snapshot, 3) -%>
- <%= variation_select_option(@snapshot, 4) -%>
- <%= variation_select_option(@snapshot, 5) -%>
- </select>
- </form>
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">All violations</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+<% end %>
</h4>
</div>