aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-05-28 02:56:48 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-05-28 02:58:42 +0400
commita40990d95004e966ded0e740ebe422565b9209de (patch)
tree328998a6fa93e75792123f19a60a4a97c9141a85
parente2136eabb58be699e3caf541efd4cfe7bb8c7e9f (diff)
downloadsonarqube-a40990d95004e966ded0e740ebe422565b9209de.tar.gz
sonarqube-a40990d95004e966ded0e740ebe422565b9209de.zip
SONAR-1922 Improve UI for profile changelog
* Show message instead of empty table, when no changes were done. * Add a select box to only show changelog between the last version and another selected version (penultimate by default).
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb25
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb13
2 files changed, 32 insertions, 6 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 81160982d52..555a8adc02f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -196,7 +196,7 @@ class ProfilesController < ApplicationController
profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?) and enabled=?', @profile.language, @profile.id, @profile.name, true], :order => 'name')
@select_parent = [['None', nil]] + profiles.collect{ |profile| [profile.name, profile.name] }
end
-
+
#
#
# GET /profiles/changelog?id=<profile id>
@@ -204,12 +204,25 @@ class ProfilesController < ApplicationController
#
def changelog
@profile = Profile.find(params[:id])
-
- @changes=ActiveRuleChange.find(:all, :conditions => ['profile_id=?', @profile.id], :order => 'id desc')
-
+
+ @versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version')
+ @versions.sort! { |a,b| b.profile_version <=> a.profile_version }
+
+ if @versions.empty?
+ @last_version = 1
+ else
+ @last_version = @versions[0].profile_version
+ @past_versions = @versions[1, @versions.length]
+ if params[:since].blank?
+ @since_version = @last_version - 1
+ else
+ @since_version = params[:since].to_i
+ end
+ @changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and profile_version>?', @profile.id, @since_version], :order => 'id desc')
+ end
end
-
-
+
+
#
#
# POST /profiles/change_parent?id=<profile id>&parent_name=<parent profile name>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
index a46645b46fb..979c550f135 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
@@ -2,6 +2,18 @@
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
<div class="tabs-panel marginbottom10">
+ <% if @versions.empty? %>
+ No changes has been done on this quality profile.
+ <% else %>
+
+ <% if !@past_versions.empty? %>
+ <% form_tag({:action => 'changelog'}, {:method => 'post'}) do %>
+ <%= hidden_field_tag "id", @profile.id %>
+ Changelog between last version (<%= @versions[0].change_date.strftime("%Y/%m/%d %H:%M:%S") %>) and
+ <%= select_tag "since", options_for_select(@past_versions.map {|u| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]}, @since_version) %>
+ <%= submit_tag "Load", :id => 'submit_since'%>
+ <% end %>
+ <% end %>
<table class="data width100">
<thead>
@@ -70,4 +82,5 @@
<% end %>
</table>
+ <% end %>
</div>