From 845c4a64b09a2f5455e50862f757ed6b3eb32fff Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 20 Jun 2014 13:14:26 +0200 Subject: [PATCH] SONAR-5329 Remove changelog2 and take into account current profile, since and to parameters --- .../app/controllers/profiles_controller.rb | 49 +------- .../WEB-INF/app/views/profiles/_tabs.html.erb | 3 - .../app/views/profiles/changelog.html.erb | 115 +++++++----------- .../app/views/profiles/changelog2.html.erb | 55 --------- 4 files changed, 48 insertions(+), 174 deletions(-) delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog2.html.erb 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 48e6f65be91..27b70e9a7ca 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 @@ -244,55 +244,10 @@ class ProfilesController < ApplicationController # GET /profiles/changelog?id= def changelog require_parameters 'id' - @profile = Profile.find(params[:id]) - - versions = ActiveRuleChange.all(:select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version') - # Add false change version 1 when no change have been made in profile version 1 - versions << ActiveRuleChange.new(:profile_version => 1, :profile_id => @profile.id) unless versions.find { |version| version.profile_version == 1 } - versions.sort! { |a, b| b.profile_version <=> a.profile_version } - - # SONAR-2986 - # Display changelog only from profile version 2 - if @profile.version > 1 - last_version = versions[0].profile_version - if params[:since].blank? - @since_version = last_version - 1 - else - @since_version = params[:since].to_i - end - if params[:to].blank? - @to_version = last_version - else - @to_version = params[:to].to_i - end - if @since_version > @to_version - @since_version, @to_version = @to_version, @since_version - end - @changes = ActiveRuleChange.all(:conditions => ['profile_id=? and ? 'id desc') - - @select_versions = versions.map do |u| - if u.change_date - message = message(u.profile_version == last_version ? 'quality_profiles.last_version_x_with_date' : 'quality_profiles.version_x_with_date', - :params => [u.profile_version.to_s, l(u.change_date)]) - else - # Specific case when no change have been made in profile version 1 -> no date will be displayed - message = message('quality_profiles.version_x', :params => u.profile_version) - end - [message, u.profile_version] - end - end - - set_profile_breadcrumbs - end - - # GET /profiles/changelog?id= - def changelog2 - require_parameters 'id' @profile = Internal.quality_profiles.profile(params[:id].to_i) - #search = {'profileKeys' => @profile.key().to_s, 'since' => params[:since], 'to' => params[:to]} - # search = {'profileKeys' => @profile.key().to_s} - @changes = Internal.component(Java::OrgSonarServerActivity::RubyActivityService.java_class).search({}) + search = {'profileKeys' => @profile.key().to_s, 'since' => params[:since], 'to' => params[:to]} + @changes = Internal.component(Java::OrgSonarServerActivity::RubyActivityService.java_class).search(search) set_profile_breadcrumbs end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb index e7efb2952ac..0e686faa0d6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb @@ -18,9 +18,6 @@
  • id="tab-changelog"><%= message('changelog') -%>
  • -
  • - Changelog2 -
  • <% if new_tab %>
  • <%= new_tab -%> 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 5817dbeb357..464adc6905c 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,78 +2,55 @@ <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
    - <% if @select_versions.nil? %> - <% if !@profile.used_profile %> - <%= message('quality_profiles.not_used') -%> - <% else %> - <%= message('quality_profiles.first_use_without_change') -%> - <% end %> + <% if @changes.empty? %> + <%= message('quality_profiles.changelog.empty') -%> <% else %> +
    + + <%= message('quality_profiles.changelog_from') -%> + + <%= message('to').downcase -%> + + +
    - <% form_tag({:action => 'changelog'}, {:method => 'post', :class => 'marginbottom10'}) do %> - <%= hidden_field_tag "id", @profile.id %> - <%= message('quality_profiles.changelog_from') -%> - <%= select_tag "since", options_for_select(@select_versions, @since_version) %> - <%= message('to').downcase -%> - <%= select_tag "to", options_for_select(@select_versions, @to_version) %> - <%= submit_tag message('load_verb'), :id => 'submit'%> - <% end %> - - - - - - - - - - - - - <% - @changes.each do |change| - %> - - - - - - - + + <% end %> +
    <%= message('quality_profiles.profile_version') -%><%= message('date') -%><%= message('user') -%><%= message('action') -%><%= message('rule') -%><%= message('parameters') -%>
    <%= change.profile_version - 1 %> -> <%= change.profile_version %><%= l(change.change_date) -%><%= change.username ? change.username : 'System' %><%= change.action_text %><%= change.rule.name %> - <% if change.old_severity - if change.new_severity %> - <%= message('quality_profiles.severity_changed_from_x_to', :params => ["", change.old_severity_text]) -%> - <% else %> - <%= message('quality_profiles.severity_was_x', :params => ["", change.old_severity_text]) -%> - <% end - end %> - <% if change.new_severity - if change.old_severity %> - <%= change.new_severity_text %> - <% else %> - <%= message('quality_profiles.severity_set_to_x', :params => ["", change.new_severity_text]) -%> - <% end - end %> - <% if (change.old_severity or change.new_severity) and change.parameters.size > 0 %> -
    - <% end %> - <% change.parameters.each do |param_change| %> - <% if not param_change.old_value %> - <%= message('quality_profiles.parameter_set_to_x', :params => [param_change.name, param_change.new_value]) -%> - <% elsif not param_change.new_value - if change.enabled == false %> - <%= message('quality_profiles.parameter_was_x', :params => [param_change.name, param_change.old_value]) -%> - <% else %> - <%= message('quality_profiles.parameter_reset_to_default_value_x', :params => [param_change.name, param_change.old_value]) -%> - <% end - else %> - <%= message('quality_profiles.parameter_changed_from_x_to_x', :params => [param_change.name, param_change.old_value, param_change.new_value]) -%> + + + + + + + + + + + <% + @changes.each do |change| + %> + + <% + action = change.action() + action_message = message('quality_profiles.changelog.' + action.downcase) if action + author = change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System' + rule = change.ruleName() ? change.ruleName() : change.ruleKey() + %> + + + + + - - <% end %> -
    <%= message('date') -%><%= message('user') -%><%= message('action') -%><%= message('rule') -%><%= message('parameters') -%>
    <%= Internal.i18n.formatDateTime(change.time()) -%><%= author %><%= action_message %><%= rule %> + <% if change.severity() %> + <%= message('quality_profiles.severity_set_to_x', :params => ["", change.severity()]) -%> +
    <% end %> - <% end%> -
    + <% change.parameters().each do |param_key, param_value| %> + <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%> +
    + <% end %> +
    <% end %>
    diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog2.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog2.html.erb deleted file mode 100644 index 96fd48b2d2d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog2.html.erb +++ /dev/null @@ -1,55 +0,0 @@ -
    -<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %> - -
    - <% if @changes.empty? %> - <%= message('quality_profiles.changelog.empty') -%> - <% else %> -
    - - <%= message('quality_profiles.changelog_from') -%> - - <%= message('to').downcase -%> - - -
    - - - - - - - - - - - - <% - @changes.each do |change| - %> - - <% - action = change.action() - action_message = message('quality_profiles.changelog.' + action.downcase) if action - %> - - - - - - - <% end %> -
    <%= message('date') -%><%= message('user') -%><%= message('action') -%><%= message('rule') -%><%= message('parameters') -%>
    <%= Internal.i18n.formatDateTime(change.time()) -%><%= change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System' %><%= action_message %><%= change.ruleName() ? change.ruleName() : change.ruleKey() %> - <% if change.severity() %> - <%= message('quality_profiles.severity_set_to_x', :params => ["", change.severity()]) -%> -
    - <% end %> - <% change.parameters().each do |param_key, param_value| %> - <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%> -
    - <% end %> -
    - - <% end %> -
    -
    -- 2.39.5