From 128122b05d5452ef932bb9cf2b0c02838c14988f Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 6 Feb 2012 12:10:03 +0100 Subject: [PATCH] SONAR-1492 Improve rendering for rules in quality profiles --- .../resources/org/sonar/l10n/core.properties | 3 +- .../_active_rule_note.html.erb | 21 +-- .../views/rules_configuration/_rule.html.erb | 135 +++++++++--------- .../rules_configuration/_rule_note.html.erb | 6 +- .../rules_configuration/_rule_param.html.erb | 88 ++++++------ .../views/rules_configuration/index.html.erb | 2 +- .../src/main/webapp/stylesheets/style.css | 20 +-- 7 files changed, 129 insertions(+), 146 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 1de8b496d0e..1de49ac8c87 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 @@ -988,11 +988,10 @@ rules_configuration.unknown_rule=Unknown rule rules_configuration.x_rules_have_been_activated={0} rules have been activated. rules_configuration.x_rules_have_been_deactivated={0} rules have been deactivated. rules_configuration.extend_description=Extend description +rules_configuration.edit_note=Edit note rules_configuration.update_description=Update description 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/views/rules_configuration/_active_rule_note.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_active_rule_note.html.erb index abb7ffb3795..60a2c050d06 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_active_rule_note.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_active_rule_note.html.erb @@ -9,29 +9,30 @@ submit_active_note_update_button_id = "sanub_" + active_rule.id.to_s %> -
+
<% if note %> -

- <%= image_tag("reviews/comment.png") -%>  - <%= note.user.name -%>  - (<%= distance_of_time_in_words_to_now(note.updated_at) -%>)  +
+ + <%= note.user.name -%> (<%= distance_of_time_in_words_to_now(note.updated_at) -%>)    <% if is_admin %> <%= image_tag 'sep12.png' -%>   - <%= message('edit') %>   <%= link_to_remote message('delete'), :url => {:action => 'delete_active_rule_note', :active_rule_id => active_rule.id }, :update => "active_rule_note_#{active_rule.id}", - :confirm => message('rules_configuration.confirm_delete_note') -%> + :confirm => message('rules_configuration.confirm_delete_note'), + :html => {:class => 'link-action spacer-right'} -%> <% end %> -

+

<%= note.html_text -%>

+ <% elsif is_admin && !active_rule.rules_profile.provided? %> - + <%= message('rules_configuration.add_note') -%> <% 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 57123c9ea6e..838543e069d 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 @@ -30,81 +30,84 @@ - <%= link_to_function("#{h rule.name}", nil, :class => "") do |page| +
<%= link_to_function("#{h rule.name}", nil, :class => "") do |page| page.toggle "desc_#{rule.id}" end - %> + %>
+
- - - - - - + - -
-
- <%= render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => is_admin } %> -
- <% if active_rule %> -
- <%= render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :is_admin => is_admin } %> -
- <% end %> -
- <% - 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', + +
+ <%= render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => is_admin } %> +
+ + <% + 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 || !rule.parameters.empty? + %> + + <% + 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 ancestor_active_rule.priority != active_rule.priority %> - (<%= message('rules_configuration.original_severity') -%>: <%= ancestor_active_rule.priority_text -%>) - <% end %> - <% if is_admin && 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} %>
- <% end %> - <% end %> - - <% unless rule.parameters.empty? %> -

<%= message('rules_configuration.rule_parameters') -%>

-
- <% rule.parameters.each do |parameter| - active_parameter = active_rule.active_param_by_param_id(parameter.id) if active_rule - %> - - <%= render :partial => 'rule_param', :object => nil, - :locals => {:parameter => parameter, :active_parameter => active_parameter, :profile => profile, :rule => rule, - :active_rule => active_rule, :ancestor_active_rule => ancestor_active_rule, :is_admin => is_admin } %> - - <% end %> -
+ %> +
+ <%= message( active_rule.inherited? ? 'rules_configuration.rule_inherited_from_profile_x' : 'rules_configuration.rule_overriding_from_profile_x', + :params => ancestor_active_rule_link) -%> + <% if ancestor_active_rule.priority != active_rule.priority %> + Overrides parent definition + <%= message('rules_configuration.original_severity') -%>: <%= ancestor_active_rule.priority_text -%> <% end %> - -

<%= message('rules_configuration.rule_identification') -%>

- - - - - -
<%= message('plugin') -%>:<%= rule.plugin_name.capitalize %>
<%= message('key') -%>:<%= rule.plugin_rule_key %>
- <% if is_admin %> -
- <% 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 is_admin && active_rule.overrides? %> +
+ +
<% end %>
-
+ <% end %> + <% unless rule.parameters.empty? + rule.parameters.each do |parameter| + active_parameter = active_rule.active_param_by_param_id(parameter.id) if active_rule + %> + + <%= render :partial => 'rule_param', :object => nil, + :locals => {:parameter => parameter, :active_parameter => active_parameter, :profile => profile, :rule => rule, + :active_rule => active_rule, :ancestor_active_rule => ancestor_active_rule, :is_admin => is_admin } %> + + <% + end + end + %> + + <% end %> + + <% if active_rule %> +
+ <%= render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :is_admin => is_admin } %> +
+ <% end %> + + <% if is_admin %> +
+ <% if rule.template? %> + <%= link_to message('rules_configuration.copy_rule'), {:action => 'new', :id => profile.id, :rule_id => rule.id}, :id => "copy-#{u rule.key}", :class => 'link-action spacer-right' %> + <% end %> + <% if rule.editable? %> + <%= link_to message('rules_configuration.edit_rule'), {:action => 'edit', :id => profile.id, :rule_id => rule.id}, :class => 'link-action spacer-right' %> + <% end %> + <% end %> + +
+
+ <%= rule.plugin_name.capitalize %>: + <%= rule.plugin_rule_key %> +
+
+