From a40990d95004e966ded0e740ebe422565b9209de Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Sat, 28 May 2011 02:56:48 +0400 Subject: [PATCH] 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). --- .../app/controllers/profiles_controller.rb | 25 ++++++++++++++----- .../app/views/profiles/changelog.html.erb | 13 ++++++++++ 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= @@ -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=&parent_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'} %>
+ <% 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 %> @@ -70,4 +82,5 @@ <% end %>
+ <% end %>
-- 2.39.5