diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-26 19:09:32 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-26 19:09:32 +0200 |
commit | e4316bd324d4dfc6fc6766e8cac87076c918c13f (patch) | |
tree | 3bc5429aad087a9f4157bb68346993d7881b2ce9 /sonar-server | |
parent | 4cb4cd79d731e41177505d6f339ecbbf7dea3332 (diff) | |
download | sonarqube-e4316bd324d4dfc6fc6766e8cac87076c918c13f.tar.gz sonarqube-e4316bd324d4dfc6fc6766e8cac87076c918c13f.zip |
SONAR-2327 Provide a new "Reviews" service
Diffstat (limited to 'sonar-server')
12 files changed, 186 insertions, 10 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 05ce979a1c3..03472fde201 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 @@ -22,7 +22,10 @@ class ReviewsController < ApplicationController SECTION=Navigation::SECTION_HOME - verify :method => :post, :only => [:violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment], :redirect_to => {:action => :error_not_post} + verify :method => :post, + :only => [:assign, :comment_form, :flag_as_false_positive, + :violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment], + :redirect_to => {:action => :error_not_post} helper(:reviews,:markdown) def index @@ -35,6 +38,81 @@ class ReviewsController < ApplicationController render :partial => 'reviews/show' end + # GET + def assign_form + @user_options = options_for_users() + render :partial => "assign_form" + end + + # POST + def assign + @review = Review.find (params[:id]) + unless current_user + render :text => "<b>Cannot edit the review</b> : access denied." + return + end + + @review.assignee = User.find params[:assignee_id] + @review.save + + render :partial => 'reviews/show' + end + + # GET + def comment_form + @review = Review.find (params[:id]) + render :partial => 'reviews/comment_form' + end + + # POST + def save_comment + @review = Review.find (params[:id]) + unless current_user + render :text => "<b>Cannot create the comment</b> : access denied." + return + end + + if params[:comment_id] + comment = @review.comments.find(params[:comment_id].to_i) + if comment + comment.text=params[:text] + comment.save! + end + else + @review.comments.create!(:user => current_user, :text => params[:text]) + end + + render :partial => "reviews/show" + end + + # GET + def false_positive_form + render :partial => 'reviews/false_positive_form' + end + + # POST + def flag_as_false_positive + @review = Review.find (params[:id]) + unless current_user + render :text => "<b>Cannot create the comment</b> : access denied." + return + end + + RuleFailure.find( :all, :conditions => [ "permanent_id = ?", @review.rule_failure_permanent_id ] ).each do |violation| + violation.switched_off=true + violation.save! + end + + @review.review_type = Review::TYPE_FALSE_POSITIVE + @review.status = Review::STATUS_CLOSED + @review.save! + unless params[:comment].blank? + @review.comments.create(:review_text => params[:comment], :user_id => current_user.id) + end + + render :partial => "reviews/show" + 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 6dd08dd9fb6..7231e3aa75f 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 @@ -53,7 +53,7 @@ <%= link_to_remote (violation.false_positive? ? "Unflag false-positive" : "Flag as false-positive"), :url => { :controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.false_positive? }, :update => "reviewForm" + violation.id.to_s, - :complete => "$('vActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('reviewText" + violation.id.to_s + "').focus();" -%> + :complete => "$('vActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();" -%> </span> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb new file mode 100644 index 00000000000..7aff44c3d4c --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb @@ -0,0 +1,12 @@ +<% form_tag :html => {:style => "display:inline"} do %> + <%= hidden_field_tag :id, params[:review_id] -%> + <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %> + + <%= submit_to_remote "submit_btn", "Assign", + :url => { :action => 'assign' }, + :update => "review" -%> + + <%= link_to_remote 'Cancel', + :url => { :action => 'show', :id => params[:review_id] }, + :update => "review" %> +<% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb new file mode 100644 index 00000000000..6cb2a2bd58e --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb @@ -0,0 +1,39 @@ +<% + button=(@comment ? 'Update comment' : 'Add comment') +%> +<form method="POST" action="save_comment"> + <input type="hidden" name="id" value="<%= params[:id] -%>"/> + <% if @comment %> + <input type="hidden" name="comment_id" value="<%= @comment.id -%>"/> + <% end %> + + <table class="width100"> + <tr> + <td style="vertical-align:top"> + <textarea id="commentText" rows="8" name="text" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"><%= @comment.text if @comment -%></textarea> + <br/> + <%= submit_to_remote "submit_btn", button, :url => { :action => 'save_comment'}, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%> + <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> + </td> + <td class="sep"></td> + <td style="vertical-align:top;width: 90px"> + <h3>Help Tips</h3> + <table> + <tr> + <td>*bold*</td> + <td class="sep"></td> + <td><b>bold</b></td> + </tr> + <tr> + <td>''code''</td> + <td class="sep"></td> + <td><code>code</code></td> + </tr> + <tr> + <td colspan="3">* Bulleted point</td> + </tr> + </table> + </td> + </tr> + </table> +</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb new file mode 100644 index 00000000000..6cc844cb38e --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb @@ -0,0 +1,7 @@ +<form method="POST" action="violation_flag_as_false_positive"> + <input type="hidden" name="id" value="<%= params[:id] -%>"/> + <h3>Why is it a false-positive ?</h3> + <textarea id="commentText" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea> + <%= submit_to_remote "submit_btn", "Flag as false-positive", :url => { :action => 'flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%> + <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> +</form> 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 f9b6a8cd35a..bf7b8b55f2e 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 @@ -2,6 +2,25 @@ <div class="reportTitle"> <div style="float: right"><span class="violation_date">#<%= review.id.to_s -%></span></div> <h2><%= h(review.title) -%></h2> + + <% if current_user && review.status != "CLOSED" %> + <span class="actions" id="rActions"> + + <%= image_tag("sep12.png") -%> + + <%= link_to_remote (review.assignee_id ? "Reassign" : "Assign"), + :url => { :controller => "reviews", :action => "assign_form", :review_id => review.id}, + :update => "assignForm", + :complete => "$('rActions').hide(); $('commentAction').hide(); $('assignee_id').focus();" -%> + + + <%= link_to_remote ("Flag as false-positive"), + :url => { :controller => "reviews", :action => "false_positive_form", :id => review.id }, + :update => "reviewForm", + :complete => "$('rActions').hide(); $('commentAction').hide(); $('reviewForm').show();$('commentText').focus();" -%> + </span> + <% end %> + </div> <table class="reportDetails"> @@ -24,7 +43,9 @@ Assignee: </td> <td class="val"> - <%= review.assignee ? h(review.assignee.name) : '-'-%> + <span id="assignForm"> + <%= review.assignee ? h(review.assignee.name) : '-'-%> + </span> </td> <td class="key"> Created by: @@ -72,4 +93,15 @@ </div> <% end %> </div> + + <% if current_user && review.status != "CLOSED" %> + <div class="discussionComment" id="reviewForm" style="display:none"></div> + <div style="padding: 5px" id="commentAction"> + <%= link_to_remote "Add comment", + :url => { :controller => "reviews", :action => "comment_form", :id => review.id }, + :update => "reviewForm", + :complete => "$('rActions').hide();$('commentAction').hide();$('reviewForm').show();$('commentText').focus()" -%> + </div> + <% end %> + </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb index 933326b8914..daa7600ffcf 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb @@ -1,5 +1,3 @@ - - <% button=(@comment ? 'Update comment' : 'Add comment') %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb index 109f3a292bd..f0e5574fd22 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb @@ -13,7 +13,7 @@ <input type="hidden" name="false_positive" value="true"/> <% end %> <h3><%= title -%></h3> - <textarea rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea> + <textarea id="commentText<%= params[:id] -%>" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea> <%= submit_to_remote "submit_btn", button, :url => { :action => 'violation_flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'vId'+params[:id] -%> <%= link_to_remote 'Cancel', :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> </form> 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 0000c7478bc..6d4daf0d084 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 @@ -84,11 +84,12 @@ <thead> <tr> <th width="1%" nowrap>St.</th> - <th width="1%">Project</th> <th>Title</th> + <th width="1%">Project</th> <th width="1%" nowrap>Se.</th> <th>Assignee</th> <th>Age</th> + <th width="1%" nowrap>Id</th> </tr> </thead> @@ -103,14 +104,17 @@ %> <tr class="<%= cycle('even', 'odd') -%>"> <td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png"/></td> - <td><%= review.project.name -%> - <br/><span class="note"><%= review.resource.long_name -%></span></td> <td> <%= link_to_remote(h(review.title), :update => 'review', :url => {:action => 'show', :id => review.id}, :loading => 'onReviewLoading()', :complete => "onReviewLoaded()") -%> </td> + <td><%= review.project.name -%> + <br/><span class="note"><%= review.resource.long_name -%></span></td> <td><img src="<%= ApplicationController.root_context -%>/images/priority/<%= review.severity -%>.png"/></td> <td><%= review.assignee ? h(review.assignee.name) : '-' -%></td> <td><%= distance_of_time_in_words_to_now(review.created_at) -%></td> + <td style="font-weight:bold"> + <%= link_to_remote( "#"+h(review.id), :update => 'review', :url => {:action => 'show', :id => review.id}, :loading => 'onReviewLoading()', :complete => "onReviewLoaded()") -%> + </td> </tr> <% end diff --git a/sonar-server/src/main/webapp/images/status/closed.png b/sonar-server/src/main/webapp/images/status/CLOSED.png Binary files differindex 5a2fef43e22..5a2fef43e22 100644 --- a/sonar-server/src/main/webapp/images/status/closed.png +++ b/sonar-server/src/main/webapp/images/status/CLOSED.png diff --git a/sonar-server/src/main/webapp/images/status/open.png b/sonar-server/src/main/webapp/images/status/OPEN.png Binary files differindex 454ab685563..454ab685563 100644 --- a/sonar-server/src/main/webapp/images/status/open.png +++ b/sonar-server/src/main/webapp/images/status/OPEN.png diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 513a1962de2..00e5cb59976 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -816,7 +816,7 @@ span.rulename a:hover { div.reportTitle { - background-color: #CAE3F2; + background-color: #E4ECF3; color: #4B9FD5; line-height: 2.2em; margin: 0; @@ -830,6 +830,9 @@ div.reportTitle h2 { font-size: 100%; text-shadow: 0 1px 0 #FFFFFF; } +div.reportTitle span.actions { + font-size: 12px; +} table.reportDetails { width: 100%; border: 0; @@ -869,6 +872,9 @@ div.discussionComment h4 { div.discussionComment h4 img { vertical-align: sub; } +div.discussionComment li { + list-style: square inside; +} |