From 3547823a971749e0bec7fdb2a5f1ce99f37b23f5 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 23 Jan 2012 19:20:47 +0100 Subject: [PATCH] SONAR-1492 Allow notes per quality rule => Improve the display of rules with notes and parameters --- .../resources/org/sonar/l10n/core.properties | 10 +++++ .../app/controllers/rules_controller.rb | 6 +++ .../app/views/resource/_violation.html.erb | 2 +- .../WEB-INF/app/views/rules/show.html.erb | 45 ++++++++++++++++++- .../src/main/webapp/stylesheets/style.css | 8 ++++ 5 files changed, 68 insertions(+), 3 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 6be2ee69ff8..3dc7db53031 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 @@ -998,6 +998,16 @@ rules_configuration.rule_identification=Identification rules_configuration.rule_parameters=Parameters +#------------------------------------------------------------------------------ +# +# RULES DOCUMENTATION PAGE +# +#------------------------------------------------------------------------------ +rules.description=Description +rules.rule_activated_on_profile_x=Rule activated on profile "{0}" +rules.parameters=Parameters: + + #------------------------------------------------------------------------------ # # EMAIL CONFIGURATION diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb index 3d3e6850625..22a1fae82a9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb @@ -30,6 +30,12 @@ class RulesController < ApplicationController @rule=Rule.find(key) end @page_title=@rule.name + + if params[:resource_id] + resource = Project.find(params[:resource_id]) + @profile = resource.root_project.profile + @active_rule = @profile.active_by_rule_id(@rule.id) + end end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb index f8bbcfa6710..cc4854d90b9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb @@ -18,7 +18,7 @@   - <%= h(violation.rule.name) -%> + <%= h(violation.rule.name) -%>   diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb index c7850424fdf..4f601111b85 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb @@ -1,7 +1,48 @@

<%= @rule.name %>

Plugin: <%= @rule.plugin_name -%>    -Key: <%= @rule.plugin_rule_key %>
+Key: <%= @rule.plugin_rule_key %> + +
+

<%= message('rules.description') -%>

<%= @rule.description %>

-
\ No newline at end of file + + <% if @rule.note %> +

<%= sanitize(@rule.note.text) -%>

+ <% end %> + + <% if @profile %> +

<%= message('rules.rule_activated_on_profile_x', :params => @profile.name) -%>

+ + <% if @active_rule %> +

<%= sanitize(@active_rule.note.text) if @active_rule.note %>

+ +

<%= message('rules.parameters') -%>

+ + <% @rule.parameters.each do |parameter| + active_parameter = @active_rule.active_param_by_param_id(parameter.id) + %> + + + + + + + + + + + <% end %> +
+ <%= parameter.name %>:   + + <%= active_parameter.value unless active_parameter.value.blank? -%> +
+ <%= h parameter.description -%> +
+ <% end %> + <% end %> + + + diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index b2438ffdec5..2ad72396f36 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -533,6 +533,14 @@ h4, .h4 { } /* ------------------- DOCUMENTATION --------------------- */ +.doc { + margin: 0px 10px; +} + +.doc h2 { + margin-top: 10px; +} + .doc p { margin: 10px 0; } -- 2.39.5