summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-09-20 15:10:35 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-09-20 15:10:45 +0200
commitcd33c8e45fd4766588604a3527bd3fe51bc0b1fb (patch)
tree383a65972a6586fdbbc0fcd2150d5c529bc8c344
parentdedb6801dc42ee1c4d44f80a063d7121a4208c7f (diff)
downloadsonarqube-cd33c8e45fd4766588604a3527bd3fe51bc0b1fb.tar.gz
sonarqube-cd33c8e45fd4766588604a3527bd3fe51bc0b1fb.zip
SONAR-4260 Hide 'added'/'on new code' data when there is no past snapshot
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb11
3 files changed, 22 insertions, 15 deletions
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 9530ab40825..e4c01a4449f 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
@@ -45,18 +45,23 @@ module DashboardHelper
def period_select_option_tags(snapshot, html_class = '')
selected=(!params[:period] || params[:period] == '0' ? 'selected' : '')
options = "<option #{selected} value='0' class='#{html_class}'/>#{message('time_changes')}...</option>"
+ period_options = ''
(1..5).each { |index|
option = period_select_options(snapshot, index, html_class)
if option
- options += option
+ period_options += option
end
}
- options
+ if !period_options.empty?
+ options += period_options
+ else
+ nil
+ end
end
def period_select_options(snapshot, index, html_class = '')
label = period_label(snapshot, index)
- if label
+ if label && snapshot.period_datetime(index)
selected=(params[:period]==index.to_s ? 'selected' : '')
"<option value='#{index}' #{selected} class='#{html_class}'>&Delta; #{label}</option>"
else
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 d9f6ee8c617..e8191011ade 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
@@ -18,15 +18,16 @@
<h4>
<%= "Version #{@snapshot.version} - " if @snapshot.version.present? -%><%= l @snapshot.created_at -%>
<% if @snapshot.project_snapshot.periods? %>
- <form method="GET" action="<%= url_for :controller => :dashboard, :action => :index, :id => @resource.id -%>" style="display: inline" class="spacer-left">
- <input type="hidden" name="did" value="<%= @dashboard.id -%>"/>
- <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), {
- :width => '230px',
- }, {:id => 'select-comparison', :onchange => 'submit()'} -%>
- </form>
+ <% period_options = period_select_option_tags(@snapshot, 'small') %>
+ <% if period_options %>
+ <form method="GET" action="<%= url_for :controller => :dashboard, :action => :index, :id => @resource.id -%>" style="display: inline" class="spacer-left">
+ <input type="hidden" name="did" value="<%= @dashboard.id -%>"/>
+ <%= dropdown_tag "period", period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
+ </form>
+ <% end %>
<% end %>
</h4>
</div>
<% end %>
</div>
-<% end %> \ No newline at end of file
+<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb
index 1a69136f60b..c8c8130e949 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb
@@ -9,11 +9,12 @@
<% 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.periods? %>
- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left">
- <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), {
- :width => '230px',
- }, {:id => 'select-comparison', :onchange => 'submit()'} -%>
- </form>
+ <% period_options = period_select_option_tags(@snapshot, 'small') %>
+ <% if period_options %>
+ <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left">
+ <%= dropdown_tag 'period', period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
+ </form>
+ <% end %>
<% end %>
</h4>
</div>