]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2124 Show difference when rules in derived profiles are changed
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 25 Jan 2012 18:01:07 +0000 (19:01 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Wed, 25 Jan 2012 18:02:27 +0000 (19:02 +0100)
+ link to the rules that has been overriden
+ UI improvements

plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb

index 65ea811bc4247eec13070b83cc7ccd374a3ac73c..5d321b41a82050ed9c086adbbe13270abdba75e9 100644 (file)
@@ -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
 
 
 #------------------------------------------------------------------------------
index 91ad6b65236c12c6bb39c46e0e85632cb9a0de9e..c1c298abc1f7aa14252ff0d58403abfddd19ba53 100644 (file)
@@ -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
 
 
index a56225876bb5cbc832f577faedfcc3f2a6c43180..a2e6f2b29f2c70425814e53cf365525b2e946028 100644 (file)
@@ -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>
             </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">
                   %>
                     <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>
index 0a2ee16ba06179cc109f3d85bbd62deea5b63785..49a625cd7126c3d715d816bd49884705d67a39e9 100644 (file)
@@ -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 %>
             <% 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>
index cade9e03b0261daa805ccd44cc30fae5d5b285d1..d41b19065ab71410403ecab4c8c8af85be8be837 100644 (file)
     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>