From d3c27297ab3f1e89df137d9fa1bae6c7a0f1c21e Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Tue, 24 Jan 2012 10:56:40 +0100 Subject: [PATCH] SONAR-1492 Allow notes per quality rule Fix some issues --- .../resources/org/sonar/l10n/core.properties | 4 +- .../app/controllers/rules_controller.rb | 2 +- .../WEB-INF/app/views/rules/show.html.erb | 46 ++++++++++--------- .../_create_rule_note.html.erb | 8 ++-- .../views/rules_configuration/_rule.html.erb | 18 +++----- .../views/rules_configuration/index.html.erb | 6 +-- .../src/main/webapp/stylesheets/style.css | 1 + 7 files changed, 42 insertions(+), 43 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 3dc7db53031..785960d3791 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 @@ -990,8 +990,8 @@ rules_configuration.rule_activation_note=Activation note rules_configuration.confirm_delete_note=Do you really want to delete this note? rules_configuration.add_note=Add note rules_configuration.add_activation_note=Add activation note -rules_configuration.adding_note_description=This note will be linked to the current rule (whatever the profile) and will be visible to every user. It can be used to extend the predefined rule description. -rules_configuration.adding_activation_note_decsription=This activation note will be linked to the active rule of the current profile and will be visible to every user. It can be used to explain why this rule was activated on this profile and/or why such parameter was specified. +rules_configuration.adding_note_description=This note will be linked to the current rule (whatever the profile) and will be visible to every user. It can be used to extend the predefined rule description.
HTML tags can be used in this field. +rules_configuration.adding_activation_note_description=This activation note will be linked to the active rule of the current profile and will be visible to every user. It can be used to explain why this rule was activated on this profile and/or why such parameter was specified.
HTML tags can be used in this field. rules_configuration.create_note=Create note rules_configuration.create_activation_note=Create activation note rules_configuration.rule_identification=Identification 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 22a1fae82a9..c3fbea89bed 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 @@ -33,7 +33,7 @@ class RulesController < ApplicationController if params[:resource_id] resource = Project.find(params[:resource_id]) - @profile = resource.root_project.profile + @profile = resource.root_project.profile || Profile.default_profile @active_rule = @profile.active_by_rule_id(@rule.id) end end 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 4f601111b85..1f9fb945606 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 @@ -18,29 +18,31 @@ Key: <%= @rule.plugin_rule_key %> <% if @active_rule %>

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

+ <% unless @rule.parameters.empty? %>

<%= 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 -%> -
+ + <% @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 %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb index ebc2ddaaa9a..fc089848ad9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb @@ -18,7 +18,7 @@ <%= 'style="display:none;"' if rule.note -%>> > + <%= 'style="display:none;"' unless active_rule && !active_rule.note -%>> -<% if active_rule%> +<% if active_rule %>