aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-05-26 17:53:53 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-05-26 17:53:53 +0200
commitaa2b9116625c1bcb08da5ba0858c035f847eaa26 (patch)
tree52895171d2b3bb116a8711a5529fca010472752a
parent9a063925d2458740464a15281a1cd69d5b854898 (diff)
downloadsonarqube-aa2b9116625c1bcb08da5ba0858c035f847eaa26.tar.gz
sonarqube-aa2b9116625c1bcb08da5ba0858c035f847eaa26.zip
SONAR-2388 Make it possible to search for 'false-positive' reviews
- Adds select box on the search page - Change comment icon color if false-positive - Add "False positive" label on the permalink page - Adjust link that opens the resource to directly open the resource viewer on the false-positives
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb18
-rw-r--r--sonar-server/src/main/webapp/images/reviews/+false-positive.pngbin849 -> 0 bytes
-rw-r--r--sonar-server/src/main/webapp/images/reviews/+review.pngbin976 -> 0 bytes
-rw-r--r--sonar-server/src/main/webapp/images/reviews/false_positive.pngbin0 -> 3118 bytes
-rw-r--r--sonar-server/src/main/webapp/images/reviews/review.pngbin947 -> 0 bytes
-rw-r--r--sonar-server/src/main/webapp/images/reviews/with_false_positives.pngbin0 -> 3092 bytes
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css24
12 files changed, 58 insertions, 19 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 ddf519dca1e..5062feb382d 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
@@ -272,7 +272,8 @@ class ReviewsController < ApplicationController
@severities = filter_any(params[:severities]) || ['']
@statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN]
@projects = filter_any(params[:projects]) || ['']
- @id = params[:review_id] || ""
+ @false_positives = params[:false_positives] || 'without'
+ @id = params[:review_id] || ''
@sort = params[:sort]
@asc = params[:asc] == "true"
end
@@ -285,7 +286,7 @@ class ReviewsController < ApplicationController
end
def search_reviews
- options = { 'false_positives' => 'without' }
+ options = {}
unless @statuses == ['']
options['statuses']=@statuses.join(',')
end
@@ -301,6 +302,9 @@ class ReviewsController < ApplicationController
if @assignee_id
options['assignees']=@assignee_id.to_s
end
+ if @false_positives
+ options['false_positives']=@false_positives
+ end
unless @id == ''
if is_number? @id
options['id'] = @id
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
index ccc33e692ff..2922bcf0c92 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
@@ -315,13 +315,13 @@ module ApplicationHelper
period_index=nil if period_index && period_index<=0
if resource.display_dashboard?
if options[:dashboard]
- link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title])
+ link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
else
# stay on the same page (for example components)
- link_to(name || resource.name, {:overwrite_params => {:id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab]}}, :title => options[:title])
+ link_to(name || resource.name, {:overwrite_params => {:id => (resource.copy_resource_id||resource.id), :period => period_index, :tab => options[:tab], :rule => options[:rule]}}, :title => options[:title])
end
else
- link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title])
+ link_to(name || resource.name, {:controller => 'resource', :action => 'index', :id => resource.id, :period => period_index, :tab => options[:tab], :rule => options[:rule]}, :popup => ['resource', 'height=800,width=900,scrollbars=1,resizable=1'], :title => options[:title])
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb
index a99f1fd7b30..7999bc9c69d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb
@@ -117,11 +117,14 @@ module UsersHelper
# field that is submitted is a hidden one that contains the user ID that corresponds
# to the typed name (if the user exists, of course).
#
+ # The 'options' argument can be used to pass HTML elements to the text field.
+ # (for the moment 'class' is supported).
+ #
# Example:
# <%= user_autocomplete_field "assignee_id", @assignee_id -%>
# # => generates an input field for the parameter 'assignee_id'
#
- def user_autocomplete_field(param_id, param_value)
+ def user_autocomplete_field(param_id, param_value, options={})
param_id_name = param_id
param_id_value = param_value
@@ -134,7 +137,8 @@ module UsersHelper
server_url = url_for :controller => 'users', :action => 'autocomplete'
render :partial => 'autocomplete/text_field', :locals => {:param_id_name => param_id_name, :param_id_value => param_id_value,
- :param_displayed_value => param_displayed_value, :server_url => server_url }
+ :param_displayed_value => param_displayed_value, :server_url => server_url,
+ :options => options.to_options}
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb
index 8675ee22515..2e9b6f047e7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb
@@ -1,4 +1,8 @@
- <input type="text" id="autocompleteText-<%= param_id_name -%>" value="<%= param_displayed_value -%>" onfocus="$('<%= param_id_name -%>').value=''; this.value=''"/>
+ <input type="text"
+ id="autocompleteText-<%= param_id_name -%>"
+ value="<%= param_displayed_value -%>"
+ onfocus="$('<%= param_id_name -%>').value=''; this.value=''"
+ <%= "class=\"" + options[:class] + "\"" if options[:class] -%>/>
<input type="hidden" id="<%= param_id_name -%>" name="<%= param_id_name -%>" value="<%= param_id_value -%>"/>
<div id="autocomplete-<%= param_id_name -%>" class="autocomplete"></div>
<script>
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 ef3ea5b72fa..dd702ee4158 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
@@ -1,6 +1,11 @@
<div id="rev_<%= review.id -%>">
<div class="reportTitle">
<h2>Review #<%= h(review.id.to_s) -%> - <%= h(review.title) -%></h2>
+ <% if review.false_positive %>
+ <%= image_tag("sep12.png") -%>
+ &nbsp;
+ <span class="falsePositive">False-Positive</span>
+ <% end %>
<%
if current_user && review.status != "CLOSED" && review.rule_failure
@@ -91,7 +96,7 @@
<td class="val" colspan="3">
<%= qualifier_icon(@review.resource) -%>
<% if !review.on_project? %> <%= @review.project.long_name -%> <%= image_tag 'sep12.png' -%> <% end %>
- <%= link_to_resource(review.resource, review.resource.long_name, { :tab => :violations } ) %>
+ <%= link_to_resource(review.resource, review.resource.long_name, { :tab => :violations, :rule => "f-positive" } ) %>
</td>
</tr>
</table>
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 0b1d521a583..bb2b91e8aa9 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
@@ -7,7 +7,8 @@ function reviewIdFieldModified(field) {
$('author_id').value = ''
$('autocompleteText-author_id').value = ''
$('assignee_id').value = ''
- $('autocompleteText-assignee_id').value = ''
+ $('autocompleteText-assignee_id').value = ''
+ $('false_positives').value = 'with'
}
}
function launchSearch(columnName, link) {
@@ -63,13 +64,19 @@ function launchSearch(columnName, link) {
</td>
<td width="1%" nowrap>
<span class="note">Created by</span><br/>
- <%= user_autocomplete_field "author_id", @author_id -%>
+ <%= user_autocomplete_field "author_id", @author_id, { :class => "max-width" } -%>
<br/>
<span class="note">Assigned to</span><br/>
- <%= user_autocomplete_field "assignee_id", @assignee_id -%>
+ <%= user_autocomplete_field "assignee_id", @assignee_id, { :class => "max-width" } -%>
<br/>
+ <br/>
+ <select name="false_positives" id="false_positives" class="withIcons">
+ <option <%= 'selected' if @false_positives=='without' -%> value="without" class="sel-without-false-positives">Without false positives</option>
+ <option <%= 'selected' if @false_positives=='only' -%> value="only" class="sel-only-false-positives">Only false positives</option>
+ <option <%= 'selected' if @false_positives=='with' -%> value="with" class="sel-with-false-positives">With false positives</option>
+ </select>
</td>
- <td width="1%" nowrap>
+ <td width="1%" style="padding-left: 20px" nowrap>
<span class="note">Id</span><br/>
<%= text_field_tag "review_id", @id, :size => 10, :onkeyup => "reviewIdFieldModified(this)" -%>
<br/>
@@ -140,7 +147,8 @@ function launchSearch(columnName, link) {
<td>
<%= link_to h(review.title), :controller => "reviews", :action => "view", :id => review.id -%>
<div class="comment-excerpt">
- <%= image_tag("reviews/comment.png") -%> &nbsp;<b><%= comment.user.name -%> :</b>
+ <img src="<%= ApplicationController.root_context -%>/images/reviews/<%= review.false_positive ? "false_positive" : "comment" -%>.png" title="<%= 'False positive' if review.false_positive -%>"/>
+ &nbsp;<b><%= comment.user.name -%> :</b>
<%= comment.excerpt -%>
</div>
</td>
diff --git a/sonar-server/src/main/webapp/images/reviews/+false-positive.png b/sonar-server/src/main/webapp/images/reviews/+false-positive.png
deleted file mode 100644
index 84edfdf4b3a..00000000000
--- a/sonar-server/src/main/webapp/images/reviews/+false-positive.png
+++ /dev/null
Binary files differ
diff --git a/sonar-server/src/main/webapp/images/reviews/+review.png b/sonar-server/src/main/webapp/images/reviews/+review.png
deleted file mode 100644
index 622e48e194a..00000000000
--- a/sonar-server/src/main/webapp/images/reviews/+review.png
+++ /dev/null
Binary files differ
diff --git a/sonar-server/src/main/webapp/images/reviews/false_positive.png b/sonar-server/src/main/webapp/images/reviews/false_positive.png
new file mode 100644
index 00000000000..42e6a028f9d
--- /dev/null
+++ b/sonar-server/src/main/webapp/images/reviews/false_positive.png
Binary files differ
diff --git a/sonar-server/src/main/webapp/images/reviews/review.png b/sonar-server/src/main/webapp/images/reviews/review.png
deleted file mode 100644
index 3af02f48d89..00000000000
--- a/sonar-server/src/main/webapp/images/reviews/review.png
+++ /dev/null
Binary files differ
diff --git a/sonar-server/src/main/webapp/images/reviews/with_false_positives.png b/sonar-server/src/main/webapp/images/reviews/with_false_positives.png
new file mode 100644
index 00000000000..64e06e1c9f6
--- /dev/null
+++ b/sonar-server/src/main/webapp/images/reviews/with_false_positives.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 c3d24f1689f..3b137d5fd6a 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -693,6 +693,8 @@ div.vtitle{
}
.falsePositive {
background-color: #FFF6BF;
+ padding-left: 5px;
+ padding-right: 5px;
}
div.vtitle a.action {
color: #777;
@@ -898,11 +900,23 @@ div.discussionComment li {
list-style: square inside;
}
div.comment-excerpt {
- background-color: transparent;
- margin-top: 5px;
- margin-bottom: 5px;
- color: #777777;
- font-size: 90%;
+ background-color: transparent;
+ margin-top: 5px;
+ margin-bottom: 5px;
+ color: #777777;
+ font-size: 90%;
+}
+.max-width {
+ width: 100%;
+}
+option.sel-with-false-positives {
+ background-image: url('../images/reviews/with_false_positives.png');
+}
+option.sel-only-false-positives {
+ background-image: url('../images/reviews/false_positive.png');
+}
+option.sel-without-false-positives {
+ background-image: url('../images/reviews/comment.png');
}