aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-04-06 19:10:39 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-04-20 08:49:56 +0200
commitdcba2ad8611d097d182d97b064dd8a0195e4f3a6 (patch)
tree9ef6587f68a18946b83bfa0f2e427500f01f0f74 /sonar-server
parentbbcbbd539e5e78c00d6bbd1474daa1f30cf3cc60 (diff)
downloadsonarqube-dcba2ad8611d097d182d97b064dd8a0195e4f3a6.tar.gz
sonarqube-dcba2ad8611d097d182d97b064dd8a0195e4f3a6.zip
[SONAR-1973] Add/list reviews&comments
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb27
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb27
6 files changed, 79 insertions, 27 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 36e2c12a22c..5c1eb333c9a 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
@@ -25,6 +25,11 @@ class ReviewsController < ApplicationController
def index
end
+ def list
+ reviews = Review.find :all, :conditions => ['rule_failure_id=?', params[:rule_failure_id]]
+ render :partial => "list", :locals => { :reviews => reviews }, :layout => false
+ end
+
def form
@review = Review.new
@review.rule_failure_id = params[:violation_id]
@@ -36,19 +41,35 @@ class ReviewsController < ApplicationController
render "_form", :layout => false
end
+ def formComment
+ @review_comment = ReviewComment.new
+ @review_comment.user = current_user
+ @review_comment.review_id = params[:review_id]
+ @review_comment.review_text = ""
+ @rule_failure_id = params[:rule_failure_id]
+ render "_form_comment", :layout => false
+ end
+
def create
review = Review.new(params[:review])
review.user = current_user
review.save
+ #review.review_comments.create(params[:review_comment])
review_comment = ReviewComment.new(params[:review_comment])
review_comment.user = current_user
review_comment.review_id = review.id
review_comment.save
- render "create", :layout => false
+
+ params[:rule_failure_id] = review.rule_failure_id
+ list
end
- def cancel_create
- render :nothing => true
+ def createComment
+ review_comment = ReviewComment.new(params[:review_comment])
+ review_comment.user = current_user
+ review_comment.save
+
+ list
end
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 678064fd265..5353f9b7dc1 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
@@ -5,7 +5,7 @@
<td width="30px" valign="top">
<% if current_user %>
<%= link_to_remote(image_tag("add.png"),
- :update => "review" + violation.id.to_s ,
+ :update => "reviewFailure" + violation.id.to_s,
:url => { :controller => "reviews", :action => "form", :violation_id => violation.id }) -%>
<% end %>
</td>
@@ -22,16 +22,9 @@
%>
<span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span>
<% end %>
-
- <div id="review<%= violation.id -%>" style="padding:5px; background:white">
- <% unless violation.reviews.blank?
- violation.reviews.each do |review|
- %>
- <%= render :partial => "reviews/view", :locals => { :review => review } %>
- <%
- end
- end
- %>
+
+ <div id="reviewFailure<%= violation.id -%>" style="padding:5px; background:white">
+ <%= render :partial => "reviews/list", :locals => { :reviews => violation.reviews } %>
</div>
</td>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
index 334699da652..66539b0c43e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
@@ -1,4 +1,5 @@
-<% form_for :review, @review, :url => { :action => 'create', :id => @review.id } do |f| %>
+<h3>Create a new review</h3>
+<% form_for :review, @review do |f| %>
<%= f.hidden_field :rule_failure_id %>
Review by: <%= @review.user.login -%>
<br/>
@@ -15,9 +16,9 @@
<%= text_area :review_comment, :review_text, :rows => 10 %>
<br/>
<%= submit_to_remote 'create_btn', 'Create review',
- :url => { :action => 'create', :id => @review.id },
- :update => { :success => "review" + @review.rule_failure_id.to_s, :failure => "fail" } %>
+ :url => { :action => 'create' },
+ :update => { :success => "reviewFailure" + @review.rule_failure_id.to_s, :failure => "fail" } %>
<%= submit_to_remote 'cancel_btn', 'Cancel',
- :url => { :action => 'cancel_create' },
- :update => { :success => "review" + @review.rule_failure_id.to_s } %>
+ :url => { :action => 'list', :rule_failure_id => @review.rule_failure_id.to_s },
+ :update => { :success => "reviewFailure" + @review.rule_failure_id.to_s } %>
<% end %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb
new file mode 100644
index 00000000000..b2ed06f0555
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb
@@ -0,0 +1,15 @@
+<% form_for :review_comment, @review_comment do |f| %>
+ <%= f.hidden_field :review_id %>
+ Review by: <%= :user -%>
+ <br/>
+ Comment:
+ <br/>
+ <%= f.text_area :review_text, :rows => 10 %>
+ <br/>
+ <%= submit_to_remote 'create_btn', 'Add comment',
+ :url => { :action => 'createComment', :rule_failure_id => @rule_failure_id },
+ :update => { :success => "reviewFailure" + @rule_failure_id.to_s, :failure => "fail" } %>
+ <%= submit_to_remote 'cancel_btn', 'Cancel',
+ :url => { :action => 'list', :rule_failure_id => @rule_failure_id.to_s },
+ :update => { :success => "reviewFailure" + @rule_failure_id.to_s } %>
+<% end %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb
new file mode 100644
index 00000000000..2fbbd000238
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb
@@ -0,0 +1,11 @@
+<%
+ unless reviews.blank?
+ reviews.each do |review|
+%>
+
+ <%= render :partial => "reviews/view", :locals => { :review => review } %>
+
+<%
+ end
+ end
+%> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
index 32dc6c4ed7b..29c96225414 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
@@ -1,4 +1,4 @@
-<div>
+ <div id="review<%= review.id -%>" style="border:solid 1px black; margin:2px">
User name: <%= h(review.user.name) -%>
<br/>
Status: <%= h(review.status) -%>
@@ -8,15 +8,26 @@
External Link: <%= h(review.external_link) -%>
<br/>
- <% unless review.review_comments.blank?
- review.review_comments.each do |review_comment|
- %>
+ <div>
+ <% unless review.review_comments.blank?
+ review.review_comments.each do |review_comment|
+ %>
+ <div id="commentReview" style="border:solid 1px grey; margin:2px">
<%= l review_comment.created_at -%>, by <%= h(review_comment.user.name) -%>
ยป
<%= h(review_comment.review_text) -%>
<br/>
- <%
- end
+ </div>
+ <%
end
- %>
-</div> \ No newline at end of file
+ end
+ %>
+ </div>
+
+ <%= link_to_remote("Add a comment",
+ :update => "createComment" + review.id.to_s,
+ :url => { :controller => "reviews", :action => "formComment", :review_id => review.id, :rule_failure_id => review.rule_failure_id }) -%>
+ <div id="createComment<%= review.id -%>">
+
+ </div>
+ </div>