# GET /profiles/changelog?id=<profile 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 ?<profile_version and profile_version<=?', @profile.id, @since_version, @to_version], :order => '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=<profile 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
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
<div class="tabs-panel marginbottom10">
- <% 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 %>
+ <form class="marginbottom10" method="get" action="<%= ApplicationController.root_context %>/profiles/changelog">
+ <input name="id" type="hidden" value="<%= @profile.id %>"/>
+ <%= message('quality_profiles.changelog_from') -%>
+ <input name="since" type="text" value="<%= params['since'] %>"/>
+ <%= message('to').downcase -%>
+ <input name="to" type="text" value="<%= params['to'] %>"/>
+ <input type="submit" value="<%= h message('load_verb') -%>" id="submit"/>
+ </form>
- <% 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 %>
-
- <table id="profile-changelog" class="data width100">
- <thead>
- <tr>
- <th><%= message('quality_profiles.profile_version') -%></th>
- <th><%= message('date') -%></th>
- <th><%= message('user') -%></th>
- <th><%= message('action') -%></th>
- <th><%= message('rule') -%></th>
- <th><%= message('parameters') -%></th>
- </tr>
- </thead>
- <%
- @changes.each do |change|
- %>
- <tr class="<%= cycle('even', 'odd') -%>">
- <td valign="top" width="1%" nowrap><%= change.profile_version - 1 %> -> <%= change.profile_version %></td>
- <td valign="top" width="1%" nowrap><%= l(change.change_date) -%></td>
- <td valign="top" width="1%" nowrap><%= change.username ? change.username : 'System' %></td>
- <td valign="top" width="1%" nowrap><%= change.action_text %></td>
- <td valign="top"><%= change.rule.name %></td>
- <td valign="top">
- <% if change.old_severity
- if change.new_severity %>
- <%= message('quality_profiles.severity_changed_from_x_to', :params => ["<i></i>", change.old_severity_text]) -%>
- <% else %>
- <%= message('quality_profiles.severity_was_x', :params => ["<i class=\"icon-severity-#{change.old_severity_text.downcase}\"></i>", change.old_severity_text]) -%>
- <% end
- end %>
- <% if change.new_severity
- if change.old_severity %>
- <i class="icon-severity-#{change.new_severity_text.downcase}"></i><b><%= change.new_severity_text %></b>
- <% else %>
- <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.new_severity_text.downcase}\"></i>", change.new_severity_text]) -%>
- <% end
- end %>
- <% if (change.old_severity or change.new_severity) and change.parameters.size > 0 %>
- <br/>
- <% 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]) -%>
+ <table id="profile-changelog" class="data width100">
+ <thead>
+ <tr>
+ <th><%= message('date') -%></th>
+ <th><%= message('user') -%></th>
+ <th><%= message('action') -%></th>
+ <th><%= message('rule') -%></th>
+ <th><%= message('parameters') -%></th>
+ </tr>
+ </thead>
+ <%
+ @changes.each do |change|
+ %>
+ <tr class="<%= cycle('even', 'odd') -%>">
+ <%
+ 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()
+ %>
+ <td valign="top" width="1%" nowrap><%= Internal.i18n.formatDateTime(change.time()) -%></td>
+ <td valign="top" width="1%" nowrap><%= author %></td>
+ <td valign="top" width="1%" nowrap><%= action_message %></td>
+ <td valign="top"><%= rule %></td>
+ <td valign="top">
+ <% if change.severity() %>
+ <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.severity().downcase}\"></i>", change.severity()]) -%>
+ <br/>
<% end %>
- <% end%>
- </td>
- </tr>
- <% end %>
- </table>
+ <% change.parameters().each do |param_key, param_value| %>
+ <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%>
+ <br/>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </table>
<% end %>
</div>
+++ /dev/null
-<div class="page">
-<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
-
-<div class="tabs-panel marginbottom10">
- <% if @changes.empty? %>
- <%= message('quality_profiles.changelog.empty') -%>
- <% else %>
- <form class="marginbottom10" method="post" action="<%= ApplicationController.root_context %>/profiles/changelog">
- <input name="id" type="hidden" value="<%= @profile.id %>"/>
- <%= message('quality_profiles.changelog_from') -%>
- <input name="since" type="text" value="<%= %>"/>
- <%= message('to').downcase -%>
- <input name="to" type="text" value="<%= %>"/>
- <input type="submit" value="<%= h message('load_verb') -%>" id="submit"/>
- </form>
-
- <table id="profile-changelog" class="data width100">
- <thead>
- <tr>
- <th><%= message('date') -%></th>
- <th><%= message('user') -%></th>
- <th><%= message('action') -%></th>
- <th><%= message('rule') -%></th>
- <th><%= message('parameters') -%></th>
- </tr>
- </thead>
- <%
- @changes.each do |change|
- %>
- <tr class="<%= cycle('even', 'odd') -%>">
- <%
- action = change.action()
- action_message = message('quality_profiles.changelog.' + action.downcase) if action
- %>
- <td valign="top" width="1%" nowrap><%= Internal.i18n.formatDateTime(change.time()) -%></td>
- <td valign="top" width="1%" nowrap><%= change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System' %></td>
- <td valign="top" width="1%" nowrap><%= action_message %></td>
- <td valign="top"><%= change.ruleName() ? change.ruleName() : change.ruleKey() %></td>
- <td valign="top">
- <% if change.severity() %>
- <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.severity().downcase}\"></i>", change.severity()]) -%>
- <br/>
- <% end %>
- <% change.parameters().each do |param_key, param_value| %>
- <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%>
- <br/>
- <% end %>
- </td>
- </tr>
- <% end %>
- </table>
-
- <% end %>
-</div>
-</div>