diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-25 19:01:07 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-25 19:02:27 +0100 |
commit | 88c258902a4e33017028bc28207f4b4def3e168e (patch) | |
tree | 53dde7063f78dae918355604031db84dbd0be942 | |
parent | 24654671b37c9a14c9f6fe6316e0983f1b1d6844 (diff) | |
download | sonarqube-88c258902a4e33017028bc28207f4b4def3e168e.tar.gz sonarqube-88c258902a4e33017028bc28207f4b4def3e168e.zip |
SONAR-2124 Show difference when rules in derived profiles are changed
+ link to the rules that has been overriden
+ UI improvements
5 files changed, 53 insertions, 18 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 65ea811bc42..5d321b41a82 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -992,6 +992,9 @@ rules_configuration.add_note=Add note rules_configuration.confirm_delete_note=Do you really want to delete this note? rules_configuration.rule_identification=Identification rules_configuration.rule_parameters=Parameters +rules_configuration.rule_inherited_from_profile_x=Rule inherited from profile "{0}" +rules_configuration.rule_overriding_from_profile_x=Rule overrides parent definition from profile "{0}" +rules_configuration.original_value=Original value #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 91ad6b65236..c1c298abc1f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -137,7 +137,7 @@ class RulesConfigurationController < ApplicationController is_admin=true # security has already been checked by controller filters render :update do |page| - page.replace_html("rule_#{rule.id}", :partial => 'rule', :object => rule, :locals => {:profile => profile, :active_rule => active_rule, :is_admin => is_admin}) + page.replace_html("rule_#{rule.id}", :partial => 'rule', :object => rule, :locals => {:profile => profile, :rule => rule, :active_rule => active_rule, :is_admin => is_admin}) page.assign('localModifications', true) end end @@ -310,8 +310,9 @@ class RulesConfigurationController < ApplicationController java_facade.ruleParamChanged(profile.id, active_rule.id, rule_param.name, old_value, nil, current_user.name) end end - render :partial => 'rule_param', :object => nil, - :locals => {:parameter => rule_param, :active_parameter => active_param, :profile => profile, :active_rule => active_rule, :is_admin => is_admin } + # let's reload the active rule + active_rule = ActiveRule.find(active_rule.id) + render :partial => 'rule', :locals => {:profile => profile, :rule => active_rule.rule, :active_rule => active_rule, :is_admin => is_admin } end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb index a56225876bb..a2e6f2b29f2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb @@ -34,7 +34,8 @@ page.toggle "desc_#{rule.id}" end %> - <div id="desc_<%= rule.id -%>" class="rule_detail" style="display:none"> + <div id="desc_<%= rule.id -%>" class="rule_detail" style="<%= 'display:none' unless rule.id.to_s == params[:rule_id] -%>"> + <a name="rule<%= rule.id -%>"/> <table width="100%"> <tbody> <tr> @@ -50,6 +51,21 @@ </td> <td class="separator"></td> <td width="50%"> + <% + ancestor_profile = profile.parent + ancestor_active_rule = ancestor_profile.active_by_rule_id(rule.id) if ancestor_profile && active_rule && (active_rule.inherited? || active_rule.overrides?) + if ancestor_active_rule + ancestor_active_rule_link = link_to ancestor_profile.name, :controller => 'rules_configuration', :action => 'index', + :id => ancestor_profile.id, :rule_id => rule.id, :anchor => 'rule' + rule.id.to_s + %> + <%= message( active_rule.inherited? ? 'rules_configuration.rule_inherited_from_profile_x' : 'rules_configuration.rule_overriding_from_profile_x', + :params => ancestor_active_rule_link) -%> + <% if is_admin && active_rule.overrides? %> + <br/> + <%= button_to message('rules_configuration.revert_to_parent_definition'), :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id} %><br/> + <% end %> + <% end %> + <% unless rule.parameters.empty? %> <h3><%= message('rules_configuration.rule_parameters') -%></h3> <table style="margin-left:7px"> @@ -58,29 +74,29 @@ %> <tbody id="param_<%= parameter.id -%>"> <%= render :partial => 'rule_param', :object => nil, - :locals => {:parameter => parameter, :active_parameter => active_parameter, :profile => profile, :active_rule => active_rule, :is_admin => is_admin } %> + :locals => {:parameter => parameter, :active_parameter => active_parameter, :profile => profile, + :active_rule => active_rule, :ancestor_active_rule => ancestor_active_rule, :is_admin => is_admin } %> </tbody> <% end %> </table> <% end %> + + <h3><%= message('rules_configuration.rule_identification') -%></h3> + <table style="margin-left:7px"> + <tbody> + <tr><td style="padding-right:10px"><%= message('plugin') -%>:</td><td><%= rule.plugin_name.capitalize %></td></tr> + <tr><td style="padding-right:10px"><%= message('key') -%>:</td><td><%= rule.plugin_rule_key %></td></tr> + </tbody> + </table> <% if is_admin %> + <br/> <% if rule.template? %> <%= button_to message('rules_configuration.copy_rule'), {:action => 'new', :id => profile.id, :rule_id => rule.id}, :id => "copy-#{u rule.key}" %> <% end %> <% if rule.editable? %> <%= button_to message('rules_configuration.edit_rule'), :action => 'edit', :id => profile.id, :rule_id => rule.id %> <% end %> - <% if active_rule && active_rule.overrides? %> - <%= button_to message('rules_configuration.revert_to_parent_definition'), :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id} %><br/> - <% end %> <% end %> - <h3><%= message('rules_configuration.rule_identification') -%></h3> - <table style="margin-left:7px"> - <tbody> - <tr><td style="padding-right:10px"><%= message('plugin') -%>:</td><td><%= rule.plugin_name.capitalize %></td></tr> - <tr><td style="padding-right:10px"><%= message('key') -%>:</td><td><%= rule.plugin_rule_key %></td></tr> - </tbody> - </table> </td> </tr> </tbody> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb index 0a2ee16ba06..49a625cd712 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb @@ -14,8 +14,9 @@ </td> <td width="90%" nowrap class="left"> <%= form_remote_tag :url => {:action => 'update_param', :id => active_param_id, :profile_id => profile.id, :param_id => parameter.id, :active_rule_id => active_rule_id}, - :update => "param_#{parameter.id}", - :loading => "$('param_loading_#{parameter.id}').show();" %> + :update => "rule_#{active_rule.rule_id}", + :loading => "$('param_loading_#{parameter.id}').show();", + :complete => "$('desc_#{active_rule.rule_id}').show();" %> <% span_id = "text_#{parameter.id}" %> <% read_only = !active_rule || !enable_modification %> @@ -33,6 +34,20 @@ <% end %> <% end %> + <% + if active_rule.overrides? && ancestor_active_rule + ancestor_param = ancestor_active_rule.active_param_by_param_id(parameter.id) + ancestor_value = ancestor_param.value unless ancestor_param.value.blank? + + if ancestor_value && ancestor_value != param_value + %> + <span class="note" style="font-weight: bold"> + (<%= message('rules_configuration.original_value') -%>: <%= ancestor_value -%>) + </span> + <% + end + end + %> </form> </td> </tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb index cade9e03b02..d41b19065ab 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb @@ -119,7 +119,7 @@ active_rule = @profile.active_by_rule_id(rule.id) %> <tr id="rule_<%= rule.id -%>" class="<%= cycle('even','odd') -%>"> - <%= render :partial => 'rule', :object => rule, :locals => {:profile => @profile, :active_rule => active_rule, :is_admin => is_admin} %> + <%= render :partial => 'rule', :object => rule, :locals => {:profile => @profile, :rule => rule, :active_rule => active_rule, :is_admin => is_admin} %> </tr> <% end %> </tbody> |