aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-01-24 19:19:20 +0100
committerFabrice Bellingard <bellingard@gmail.com>2012-01-24 19:21:16 +0100
commitc339385ccf76ec26cf8db19df901cdfe59c712b8 (patch)
tree7ebae28ecfbcc6c9b01f57144c9042865f2d4c66
parented409e8f0a53554aad46ac438b93b7adc02cc5d8 (diff)
downloadsonarqube-c339385ccf76ec26cf8db19df901cdfe59c712b8.tar.gz
sonarqube-c339385ccf76ec26cf8db19df901cdfe59c712b8.zip
SONAR-1492 Improve rule & active rule edition page
+ use markdown instead of HTML + improve rule doc page
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties18
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb46
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_note.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rule_note.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules/show.html.erb44
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_active_rule_note.html.erb58
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb48
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb24
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb83
-rw-r--r--sonar-server/src/main/webapp/images/reviews/comment.pngbin0 -> 1107 bytes
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css7
11 files changed, 199 insertions, 147 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 802d8947e8f..225d92f67ed 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
@@ -985,16 +985,10 @@ rules_configuration.rule_deleted=Rule deleted
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.rule_description=Description
-rules_configuration.rule_note=Note
-rules_configuration.rule_activation_note=Activation note
-rules_configuration.confirm_delete_note=Do you really want to delete this note?
+rules_configuration.extend_description=Extend description
+rules_configuration.update_description=Update description
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.<br/>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.<br/>HTML tags can be used in this field.
-rules_configuration.create_note=Create note
-rules_configuration.create_activation_note=Create activation note
+rules_configuration.confirm_delete_note=Do you really want to delete this note?
rules_configuration.rule_identification=Identification
rules_configuration.rule_parameters=Parameters
@@ -1004,9 +998,9 @@ 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:
+rules.more_about_rule_on_profile_x=More about this rule on profile "{0}"
+rules.identification=Identification
+rules.parameters=Parameters
#------------------------------------------------------------------------------
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
index b8563fb4a70..91ad6b65236 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb
@@ -30,7 +30,7 @@ class RulesConfigurationController < ApplicationController
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post,
- :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete', 'revert_rule', 'update_note', 'delete_note'],
+ :only => ['activate_rule', 'update_param', 'bulk_edit', 'create', 'update', 'delete', 'revert_rule', 'update_rule_note', 'update_active_rule_note', 'delete_active_rule_note'],
:redirect_to => { :action => 'index' }
before_filter :admin_required, :except => [ 'index', 'export' ]
@@ -315,37 +315,41 @@ class RulesConfigurationController < ApplicationController
end
- def update_note
- if params[:is_active_rule]
- rule = ActiveRule.find(params[:rule_id])
- else
- rule = Rule.find(params[:rule_id])
- end
+ def update_rule_note
+ rule = Rule.find(params[:rule_id])
note = rule.note
unless note
- if params[:is_active_rule]
- note = ActiveRuleNote.new({:rule => rule})
- else
- note = RuleNote.new({:rule => rule})
- end
+ note = RuleNote.new({:rule => rule})
# set the note on the rule to avoid reloading the rule
rule.note = note
end
note.text = params[:text]
note.user_login = current_user.login
note.save!
- render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => true, :is_active_rule => params[:is_active_rule] }
+ render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => true }
end
-
- def delete_note
- if params[:is_active_rule]
- rule = ActiveRule.find(params[:rule_id])
- else
- rule = Rule.find(params[:rule_id])
+
+ def update_active_rule_note
+ active_rule = ActiveRule.find(params[:active_rule_id])
+ note = active_rule.note
+ unless note
+ note = ActiveRuleNote.new({:active_rule => active_rule})
+ # set the note on the rule to avoid reloading the rule
+ active_rule.note = note
end
- rule.note.destroy if rule.note
- render :text => ''
+ note.text = params[:text]
+ note.user_login = current_user.login
+ note.save!
+ render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :is_admin => true }
+ end
+
+
+ def delete_active_rule_note
+ active_rule = ActiveRule.find(params[:active_rule_id])
+ active_rule.note.destroy if active_rule.note
+ active_rule.note = nil
+ render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :is_admin => true }
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_note.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_note.rb
index b306bec7393..568b5461757 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_note.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_note.rb
@@ -20,7 +20,6 @@
class ActiveRuleNote < ActiveRecord::Base
belongs_to :active_rule
alias_attribute :text, :data
- alias_attribute :rule, :active_rule
validates_presence_of :active_rule, :message => "can't be empty"
validates_presence_of :user_login, :message => "can't be empty"
@@ -32,5 +31,13 @@ class ActiveRuleNote < ActiveRecord::Base
user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil
end
end
+
+ def html_text
+ Api::Utils.markdown_to_html(text)
+ end
+
+ def plain_text
+ Api::Utils.convert_string_to_unix_newlines(text)
+ end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_note.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_note.rb
index ca7c805a4f7..94791b88abf 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_note.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_note.rb
@@ -23,7 +23,6 @@ class RuleNote < ActiveRecord::Base
validates_presence_of :rule, :message => "can't be empty"
validates_presence_of :user_login, :message => "can't be empty"
- validates_length_of :data, :minimum => 1
def user
@user ||=
@@ -31,5 +30,13 @@ class RuleNote < ActiveRecord::Base
user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil
end
end
+
+ def html_text
+ Api::Utils.markdown_to_html(text)
+ end
+
+ def plain_text
+ Api::Utils.convert_string_to_unix_newlines(text)
+ 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 1f9fb945606..4de01168813 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,26 +1,29 @@
<h1><%= @rule.name %></h1>
-<div class="subtitle">
-Plugin: <%= @rule.plugin_name -%>&nbsp;&nbsp;&nbsp;
-Key: <%= @rule.plugin_rule_key %>
-</div>
<div class="doc">
- <h2><%= message('rules.description') -%></h2>
- <p><%= @rule.description %></p>
+ <% if @rule.description.strip.start_with?('<p>') %>
+ <%= @rule.description %>
+ <% else %>
+ <p><%= @rule.description %></p>
+ <% end %>
- <% if @rule.note %>
- <p><%= sanitize(@rule.note.text) -%></p>
+ <% if @rule.note && !@rule.note.text.strip.blank? %>
+ <p><%= @rule.note.html_text -%></p>
<% end %>
- <% if @profile %>
- <h2><%= message('rules.rule_activated_on_profile_x', :params => @profile.name) -%></h2>
+ <% if @profile && @active_rule %>
+ <br/>
+ <b>
+ <a href="#" onclick="$('details').toggle();return false;"><%= message('rules.more_about_rule_on_profile_x', :params => @profile.name) %></a>
+ </b>
- <% if @active_rule %>
- <p><%= sanitize(@active_rule.note.text) if @active_rule.note %></p>
+ <div id="details" style="display: none">
+ <p><%= @active_rule.note.html_text if @active_rule.note %></p>
<% unless @rule.parameters.empty? %>
+ <br/>
<h3><%= message('rules.parameters') -%></h3>
- <table>
+ <table style="margin-left:7px">
<% @rule.parameters.each do |parameter|
active_parameter = @active_rule.active_param_by_param_id(parameter.id)
%>
@@ -30,7 +33,7 @@ Key: <%= @rule.plugin_rule_key %>
<%= parameter.name %>: &nbsp;
</td>
<td width="90%" nowrap class="left">
- <%= active_parameter.value unless active_parameter.value.blank? -%>
+ <%= active_parameter.value if active_parameter.value && !active_parameter.value.blank? -%>
</td>
</tr>
<tr>
@@ -43,8 +46,17 @@ Key: <%= @rule.plugin_rule_key %>
<% end %>
</table>
<% end %>
- <% end %>
+
+ <br/>
+ <h3><%= message('rules.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>
+ </div>
+
<% end %>
-
</div>
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
new file mode 100644
index 00000000000..f85e08f1d7b
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_active_rule_note.html.erb
@@ -0,0 +1,58 @@
+<% #locals = active_rule, is_admin
+ note = active_rule.note
+ active_note_detail_div_id = "and_" + active_rule.id.to_s
+ add_active_note_button_id = "aanb_" + active_rule.id.to_s
+ edit_active_note_link_id = "eanl_" + active_rule.id.to_s
+ delete_active_note_link_id = "danl_" + active_rule.id.to_s
+ active_note_form_div_id = "anf_" + active_rule.id.to_s
+ active_note_textarea_id = "ant_" + active_rule.id.to_s
+ submit_active_note_update_button_id = "sanub_" + active_rule.id.to_s
+%>
+
+<div id="<%= active_note_detail_div_id -%>" style="padding: 4px;<%= 'border: 1px solid #DDDDDD;' if note -%>">
+ <% if note %>
+ <h4>
+ <%= image_tag("reviews/comment.png") -%>&nbsp;
+ <b><%= note.user.name -%></b>&nbsp;
+ (<%= distance_of_time_in_words_to_now(note.updated_at) -%>)&nbsp;
+ &nbsp;
+ <%= image_tag 'sep12.png' -%>
+ &nbsp;
+ <a href="#" id="<%= edit_active_note_link_id -%>"
+ onclick="$('<%= active_note_detail_div_id -%>').hide();$('<%= active_note_form_div_id -%>').show();$('<%= active_note_textarea_id -%>').focus();return false;"><%= message('edit') %></a>
+ &nbsp;
+ <%= 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') -%>
+ </h4>
+ <p><%= note.html_text -%></p>
+ <% elsif is_admin %>
+ <input type="button" id="<%= add_active_note_button_id -%>" value="<%= message('rules_configuration.add_note') -%>"
+ onclick="$('<%= active_note_form_div_id -%>').show();$('<%= active_note_detail_div_id -%>').hide();$('<%= active_note_textarea_id -%>').focus();">
+ <% end %>
+</div>
+
+<% if is_admin %>
+<div id="<%= active_note_form_div_id -%>" style="display: none" class="admin">
+ <table>
+ <tbody>
+ <tr>
+ <td class="max-width">
+ <%= form_remote_tag :url => {:action => 'update_active_rule_note', :active_rule_id => active_rule.id},
+ :update => "active_rule_note_#{active_rule.id}" %>
+ <textarea name="text" id="<%= active_note_textarea_id -%>" rows="10" cols="100%"
+ onkeyup="if (this.value=='') $('<%= submit_active_note_update_button_id -%>').disabled=true; else $('<%= submit_active_note_update_button_id -%>').disabled=false;"><%= h(note.plain_text) if note -%></textarea>
+ <br/>
+ <input type="submit" value="<%= note ? message('update_verb') : message('rules_configuration.add_note') -%>" name="commit" id="<%= submit_active_note_update_button_id -%>"/>
+ <a href="#" onclick="$('<%= active_note_detail_div_id -%>').show();$('<%= active_note_form_div_id -%>').hide();return false;"><%= message('cancel') %></a>
+ </form>
+ </td>
+ <td class="markdown-help">
+ <%= render :partial => 'markdown/help' -%>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<% end %> \ No newline at end of file
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
deleted file mode 100644
index fc089848ad9..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_create_rule_note.html.erb
+++ /dev/null
@@ -1,48 +0,0 @@
-<% #locals = rule, active_rule, is_admin
- create_buttons_div_id = "cb_" + rule.id.to_s
- create_rule_note_button_div_id = "cnb_" + rule.id.to_s
- create_active_rule_note_button_div_id = "canb_" + rule.id.to_s
- create_rule_note_form_div_id = "crnf_" + rule.id.to_s
- create_active_rule_note_form_div_id = "carnf_" + rule.id.to_s
- submit_rule_note_id = "srn_" + rule.id.to_s
- submit_active_rule_note_id = "sarn_" + rule.id.to_s
- rule_note_text_id = "rnt_" + rule.id.to_s
- active_rule_note_text_id = "arnt_" + rule.id.to_s
-%>
-
-<div style="margin-top: 10px;">
-
-<div id="<%= create_buttons_div_id -%>">
- <input type="button" id="<%= create_rule_note_button_div_id -%>" value="<%= message('rules_configuration.add_note') -%>"
- onclick="$('<%= create_buttons_div_id -%>').hide();$('<%= create_rule_note_form_div_id -%>').show();$('<%= rule_note_text_id -%>').focus();"
- <%= 'style="display:none;"' if rule.note -%>>
- <input type="button" id="<%= create_active_rule_note_button_div_id -%>" value="<%= message('rules_configuration.add_activation_note') -%>"
- onclick="$('<%= create_buttons_div_id -%>').hide();$('<%= create_active_rule_note_form_div_id -%>').show();$('<%= active_rule_note_text_id -%>').focus();"
- <%= 'style="display:none;"' unless active_rule && !active_rule.note -%>>
-</div>
-
-<div id="<%= create_rule_note_form_div_id -%>" style="display: none" class="admin">
- <%= form_remote_tag :url => {:action => 'update_note', :rule_id => rule.id, :is_active_rule => false},
- :update => "rule_note_#{rule.id}",
- :complete => "$('#{create_rule_note_form_div_id}').hide();$('#{create_buttons_div_id}').show();$('#{create_rule_note_button_div_id}').hide();" %>
- <textarea name="text" id="<%= rule_note_text_id -%>" cols="100" rows="10" onkeyup="if (this.value=='') $('<%= submit_rule_note_id -%>').disabled=true; else $('<%= submit_rule_note_id -%>').disabled=false;"></textarea>
- <div class="note" style="padding: 5px 0px"><%= message('rules_configuration.adding_note_description') -%></div>
- <input type="submit" value="<%= message('rules_configuration.create_note') -%>" name="commit" id="<%= submit_rule_note_id -%>" disabled/>
- <a href="#" onclick="$('<%= create_buttons_div_id -%>').show();$('<%= create_rule_note_form_div_id -%>').hide();return false;"><%= message('cancel') %></a>
- </form>
-</div>
-
-<% if active_rule %>
-<div id="<%= create_active_rule_note_form_div_id -%>" style="display: none" class="admin">
- <%= form_remote_tag :url => {:action => 'update_note', :rule_id => active_rule.id, :is_active_rule => true},
- :update => "active_rule_note_#{active_rule.id}",
- :complete => "$('#{create_active_rule_note_form_div_id}').hide();$('#{create_buttons_div_id}').show();$('#{create_active_rule_note_button_div_id}').hide();" %>
- <textarea name="text" id="<%= active_rule_note_text_id -%>" cols="100" rows="10" onkeyup="if (this.value=='') $('<%= submit_active_rule_note_id -%>').disabled=true; else $('<%= submit_active_rule_note_id -%>').disabled=false;"></textarea>
- <div class="note" style="padding: 5px 0px"><%= message('rules_configuration.adding_activation_note_description')-%></div>
- <input type="submit" value="<%= message('rules_configuration.create_activation_note') -%>" name="commit" id="<%= submit_active_rule_note_id -%>" disabled/>
- <a href="#" onclick="$('<%= create_buttons_div_id -%>').show();$('<%= create_active_rule_note_form_div_id -%>').hide();return false;"><%= message('cancel') %></a>
- </form>
-</div>
-<% end %>
-
-</div> \ No newline at end of file
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 8bbe7a19236..a56225876bb 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
@@ -39,31 +39,18 @@
<tbody>
<tr>
<td width="50%">
- <h3><%= message('rules_configuration.rule_description') -%></h3>
- <p><%= rule.description %></p>
<div id="rule_note_<%= rule.id -%>">
- <%= render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => is_admin, :is_active_rule => false } %>
+ <%= render :partial => 'rule_note', :locals => {:rule => rule, :is_admin => is_admin } %>
</div>
<% if active_rule %>
<div id="active_rule_note_<%= active_rule.id -%>">
- <%= render :partial => 'rule_note', :locals => {:rule => active_rule, :is_admin => is_admin, :is_active_rule => true } %>
+ <%= render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :is_admin => is_admin } %>
</div>
<% end %>
- <% if is_admin %>
- <%= render :partial => 'create_rule_note', :locals => {:rule => rule, :active_rule => active_rule, :is_admin => is_admin } %>
- <% end %>
</td>
<td class="separator"></td>
<td width="50%">
- <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>
- <t/body>
- </table>
<% unless rule.parameters.empty? %>
- <br/>
<h3><%= message('rules_configuration.rule_parameters') -%></h3>
<table style="margin-left:7px">
<% rule.parameters.each do |parameter|
@@ -87,6 +74,13 @@
<%= 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>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb
index 208a1fe98c4..ecda4d7b332 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_note.html.erb
@@ -1,36 +1,53 @@
-<% #locals = rule, is_admin, is_active_rule
- submit_note_update_button_id = (is_active_rule ? 'a' : '') + "snub_" + rule.id.to_s
+<% #locals = rule, is_admin
+ note = rule.note
+ note_detail_div_id = "nd_" + rule.id.to_s
+ note_extend_link_id = "nel_" + rule.id.to_s
+ note_form_div_id = "nf_" + rule.id.to_s
+ note_textarea_id = "nt_" + rule.id.to_s
+ submit_note_update_button_id = "snub_" + rule.id.to_s
%>
-<%
- if rule.note
- note = rule.note
-%>
- <h3><%= is_active_rule ? message('rules_configuration.rule_activation_note') : message('rules_configuration.rule_note') -%></h3>
- <div class="note"><%= note.user.name -%>, <%= l(note.updated_at) -%></div>
- <div id="note_detail_<%= rule.id -%>">
- <p><%= sanitize(note.text) -%></p>
- <% if is_admin %>
- <div style="margin-bottom: 10px">
- <input type="button" value="<%= message('update_verb') -%>" onclick="$('note_detail_<%= rule.id -%>').hide();$('note_form_<%= rule.id -%>').show();">
- <%= button_to_remote message('delete'),
- {:url => {:action => 'delete_note', :rule_id => rule.id, :is_active_rule => is_active_rule },
- :update => "#{'active_' if is_active_rule}rule_note_#{rule.id}",
- :complete => "$('#{is_active_rule ? "canb_"+rule.rule.id.to_s : "cnb_"+rule.id.to_s}').show()",
- :confirm => message('rules_configuration.confirm_delete_note')},
- {:class => 'red-button'} -%>
- </div>
- <% end %>
- </div>
+<div id="<%= note_detail_div_id -%>">
+ <% if rule.description.strip.start_with?('<p>') %>
+ <%= rule.description %>
+ <% else %>
+ <p><%= rule.description %></p>
+ <% end %>
+
+ <% if note && !note.text.strip.blank? %>
+ <p><%= note.html_text -%></p>
+ <% end %>
+
+ <% if is_admin %>
+ <p style="text-align: right; font-style: italic;">
+ ยป <a href="#" id="<%= note_extend_link_id -%>"
+ onclick="$('<%= note_detail_div_id -%>').hide();$('<%= note_form_div_id -%>').show();$('<%= note_textarea_id -%>').focus();return false;"><%= message('rules_configuration.extend_description') %></a>
+ </p>
+ <% end %>
+</div>
- <div id="note_form_<%= rule.id -%>" style="display: none" class="admin">
- <%= form_remote_tag :url => {:action => 'update_note', :rule_id => rule.id, :is_active_rule => is_active_rule},
- :update => "#{'active_' if is_active_rule}rule_note_#{rule.id}" %>
- <textarea name="text" id="update_<%= 'active_' if is_active_rule -%>_rule_note_<%= rule.id -%>" cols="100" rows="10"
- onkeyup="if (this.value=='') $('<%= submit_note_update_button_id -%>').disabled=true; else $('<%= submit_note_update_button_id -%>').disabled=false;"><%= h(note.text) -%></textarea>
- <br/>
- <input type="submit" value="<%= message('update_verb') -%>" name="commit" id="<%= submit_note_update_button_id -%>"/>
- <a href="#" onclick="$('note_detail_<%= rule.id -%>').show();$('note_form_<%= rule.id -%>').hide();return false;"><%= message('cancel') %></a>
- </form>
- </div>
-<% end %> \ No newline at end of file
+<% if is_admin %>
+<div id="<%= note_form_div_id -%>" style="display: none" class="admin">
+ <table>
+ <tbody>
+ <tr>
+ <td style="padding-bottom:20px;" colspan="2"><%= rule.description %></td>
+ </tr>
+ <tr>
+ <td class="max-width">
+ <%= form_remote_tag :url => {:action => 'update_rule_note', :rule_id => rule.id},
+ :update => "rule_note_#{rule.id}" %>
+ <textarea name="text" id="<%= note_textarea_id -%>" rows="10" cols="100%"><%= h(note.plain_text) if note -%></textarea>
+ <br/>
+ <input type="submit" value="<%= message('rules_configuration.update_description') -%>" name="commit" id="<%= submit_note_update_button_id -%>"/>
+ <a href="#" onclick="$('<%= note_detail_div_id -%>').show();$('<%= note_form_div_id -%>').hide();return false;"><%= message('cancel') %></a>
+ </form>
+ </td>
+ <td class="markdown-help">
+ <%= render :partial => 'markdown/help' -%>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<% end %>
diff --git a/sonar-server/src/main/webapp/images/reviews/comment.png b/sonar-server/src/main/webapp/images/reviews/comment.png
new file mode 100644
index 00000000000..d2b4d640851
--- /dev/null
+++ b/sonar-server/src/main/webapp/images/reviews/comment.png
Binary files differ
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index 9d7aaa8e982..4296e0b7b14 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -2059,6 +2059,13 @@ ul.bullet li {
margin-top:10px;
}
+.rule_detail .markdown-help {
+ vertical-align:top;
+ width: 90px;
+ padding-left: 10px;
+ white-space: nowrap;
+}
+
.rule_detail > td > table {
margin: 4px;
}