@select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort\r
@select_priority = ANY_SELECTION + RULE_PRIORITIES\r
@select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]]\r
-
+\r
@rules = Rule.search(java_facade, {\r
:profile => @profile, :status => @status, :priorities => @priorities,\r
:plugins => @plugins, :searchtext => @searchtext, :include_parameters => true, :language => @profile.language})\r
end\r
\r
end\r
-
-
- #
- #
- # POST /rules_configuration/revert_rule?id=<profile id>&active_rule_id=<active rule id>
- #
- #
- def revert_rule
- id = params[:id].to_i
- rule_id = params[:active_rule_id].to_i
- java_facade.revertRule(id, rule_id)
- redirect_to :action => 'index', :id => params[:id]
- end
-
+\r
+\r
+ #\r
+ #\r
+ # POST /rules_configuration/revert_rule?id=<profile id>&active_rule_id=<active rule id>\r
+ #\r
+ #\r
+ def revert_rule\r
+ id = params[:id].to_i\r
+ rule_id = params[:active_rule_id].to_i\r
+ java_facade.revertRule(id, rule_id)\r
+ redirect_to :action => 'index', :id => params[:id]\r
+ end\r
+\r
\r
#\r
#\r
# deactivate the rule\r
active_rule.destroy if active_rule\r
active_rule=nil\r
- java_facade.ruleDeactivated(profile.id, rule.id)
+ java_facade.ruleDeactivated(profile.id, rule.id)\r
else\r
# activate the rule\r
if active_rule.nil?\r
end\r
active_rule.failure_level=Sonar::RulePriority.id(priority)\r
active_rule.save!\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
end\r
+ active_rule.reload\r
\r
is_admin=true # security has already been checked by controller filters\r
render :update do |page|\r
active_param.destroy\r
active_param = nil\r
end\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
end\r
render :partial => 'rule_param', :object => nil,\r
:locals => {:parameter => rule_param, :active_parameter => active_param, :profile => profile, :active_rule => active_rule, :is_admin => is_admin }\r
count = rules_to_activate.size\r
rules_to_activate.each do |rule|\r
active_rule = profile.active_rules.create(:rule => rule, :failure_level => rule.priority)\r
- java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)
+ java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
end\r
end\r
count\r
profile.active_rules.each do |ar|\r
if rule_ids.include?(ar.rule_id) && !ar.inherited\r
ar.destroy\r
- java_facade.ruleDeactivated(profile.id, ar.rule_id)
+ java_facade.ruleDeactivated(profile.id, ar.rule_id)\r
count+=1\r
end\r
end\r
<td nowrap valign="top" class="left" x="<%= active_rule.failure_level if active_rule -%>" width="1%">
- <% if active_rule.nil? || active_rule.inherited.nil?
- inheritance_status = 0
- else
- inheritance_status = active_rule.inherited
- end
- %>
<form id="levels_<%= rule.id -%>" action="">
<% enable_modification = is_admin && !profile.provided?
select_box_id = "levels_select_#{rule.id}"
:loading => "$('levels_#{rule.id}').replace('<img src=\"#{ApplicationController.root_context}/images/loading.gif\"/>');",
:with => "'level=' + get_level_for_rule(#{rule_select_box},#{rule_check_box})")
%>
- <%= check_box_tag(check_box_id, 'yes', (!active_rule.nil?), :onclick => activate_rule, :disabled => !enable_modification || inheritance_status > 0) %>
+ <%= check_box_tag(check_box_id, 'yes', (!active_rule.nil?), :onclick => activate_rule, :disabled => !enable_modification || (active_rule && (active_rule.inherited? || active_rule.overridden?))) %>
<%= select_tag(select_box_id, options_for_select(RulesConfigurationController::RULE_PRIORITIES, (active_rule.nil? ? rule.priority_text : active_rule.priority_text)),
{:onchange => changel_level, :disabled => (!(enable_modification) || active_rule.nil?)}) %>
+ <% if active_rule %>
+ <% if active_rule.inherited? %>
+ <img src="<%= ApplicationController.root_context -%>/images/relation-vertical-green.png" alt="Inherited from parent" title="Inherited from parent"/>
+ <% elsif active_rule.overridden? %>
+ <img src="<%= ApplicationController.root_context -%>/images/relation-vertical-red.png" alt="Overrides parent definition" title="Overrides parent definition"/>
+ <% end %>
+ <% end %>
</form>
</td>
<td valign="top" class="left">
- <% if inheritance_status == 1 %>
- Inherited from parent profile.<br/>
- <% elsif inheritance_status == 2 %>
- Overrides rule from parent profile.<br/>
- <%= button_to "Revert", :action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id %><br/>
- <% end %>
-
<%= link_to_function("#{h rule.name}", nil, :class => "") do |page|
page.toggle "desc_#{rule.id}"
end
<% if rule.editable? %>
<%= button_to "Edit rule", :action => 'edit', :id => profile.id, :rule_id => rule.id %>
<% end %>
+ <% if active_rule && active_rule.overridden? %>
+ <%= button_to "Revert to parent definition", :action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id %><br/>
+ <% end %>
<% end %>
</div>
</td>