From e86b05a3cd25415544cfbf0698244fa321e7699f Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 27 Apr 2011 11:06:47 +0200 Subject: [PATCH] SONAR-2327 Provide a new "Reviews" service --- .../WEB-INF/app/controllers/reviews_controller.rb | 14 ++++++++++++++ .../WEB-INF/app/views/reviews/_review.html.erb | 4 ++-- .../WEB-INF/app/views/reviews/index.html.erb | 11 ++++++++++- sonar-server/src/main/webapp/stylesheets/style.css | 7 ++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb index 74311837a18..4df243f2de1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -262,6 +262,7 @@ class ReviewsController < ApplicationController @severities = filter_any(params[:severities]) || [''] @statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN] @projects = filter_any(params[:projects]) || [''] + @id = params[:id] || "" end def options_for_users @@ -303,10 +304,23 @@ class ReviewsController < ApplicationController conditions << "assignee_id in (:assignees)" values[:assignees]=@assignees.map{|s| s.to_i} end + unless @id == "" + if is_number? @id + conditions << "id = :id" + values[:id] = @id + else + conditions << "id = :id" + values[:id] = -1 + end + end @reviews = Review.find( :all, :order => "created_at DESC", :conditions => [ conditions.join(" AND "), values] ).uniq end + def is_number?(s) + true if Float(s) rescue false + end + def has_rights_to_modify?(violation) current_user && has_role?(:user, violation.snapshot) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb index bc87b3a9ad1..aa13895b6ed 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb @@ -51,7 +51,7 @@ Created by: - <%= h(review.user.name) -%> on <%= l(review.created_at, :format => :long) -%> + <%= h(review.user.name) -%>, on <%= l(review.created_at, :format => :long) -%> <% if review.rule %> @@ -77,7 +77,7 @@ <% if review.rule_failure && review.resource_line && review.rule_failure.snapshot %> -
+
<%= snapshot_source_to_html(review.rule_failure.snapshot, {:line_range => (review.resource_line-5)..(review.resource_line+5), :highlighted_lines => [review.resource_line]}) -%>
<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb index 6d4daf0d084..7926a401119 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb @@ -67,9 +67,18 @@ Assigned to
<%= select_tag "assignees", options_for_select(@user_names, @assignees), :multiple => true, :size => 6 %> - + + Id
+ <%= text_field_tag "id", @id, :size => 10 -%> +
+

+
+
<%= submit_tag "Search", :id => 'submit_search' %> +
+ + diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 00e5cb59976..d1d5b596431 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -814,7 +814,12 @@ span.rulename a:hover { - +div#review .actions{ + visibility: hidden; +} +div#review:hover .actions{ + visibility: visible; +} div.reportTitle { background-color: #E4ECF3; color: #4B9FD5; -- 2.39.5