From: simonbrandhof Date: Mon, 25 Apr 2011 21:12:50 +0000 (+0200) Subject: SONAR-2327 split actions for resource viewer and reviews page X-Git-Tag: 2.8~129 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dbc988359bac8e7a5ca426fa42f27ae0b8c36063;p=sonarqube.git SONAR-2327 split actions for resource viewer and reviews page --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index b0827f546f4..4634bcb01fe 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -214,7 +214,7 @@ public class CorePlugin extends SonarPlugin { extensions.add(NoSonarFilter.class); extensions.add(DirectoriesDecorator.class); extensions.add(FilesDecorator.class); - extensions.add(ReviewsDecorator.class); + extensions.add(CloseReviewsDecorator.class); // time machine extensions.add(TendencyDecorator.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java new file mode 100644 index 00000000000..e037cd03877 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java @@ -0,0 +1,72 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.sensors; + +import javax.persistence.Query; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorContext; +import org.sonar.api.batch.DependsUpon; +import org.sonar.api.database.DatabaseSession; +import org.sonar.api.database.model.Snapshot; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Resource; +import org.sonar.batch.index.ResourcePersister; + +/** + * Decorator that currently only closes a review when its corresponding violation has been fixed. + */ +@DependsUpon("ViolationPersisterDecorator") +public class CloseReviewsDecorator implements Decorator { + + private static final Logger LOG = LoggerFactory.getLogger(CloseReviewsDecorator.class); + + private ResourcePersister resourcePersister; + private DatabaseSession databaseSession; + + public CloseReviewsDecorator(ResourcePersister resourcePersister, DatabaseSession databaseSession) { + this.resourcePersister = resourcePersister; + this.databaseSession = databaseSession; + } + + public boolean shouldExecuteOnProject(Project project) { + return true; + } + + public void decorate(Resource resource, DecoratorContext context) { + Snapshot currentSnapshot = resourcePersister.getSnapshot(resource); + if (currentSnapshot != null) { + int resourceId = currentSnapshot.getResourceId(); + int snapshotId = currentSnapshot.getId(); + Query query = databaseSession.createNativeQuery(generateSqlRequest(resourceId, snapshotId)); + int rowUpdated = query.executeUpdate(); + LOG.debug("- {} reviews set to 'closed' on resource #{}", rowUpdated, resourceId); + databaseSession.commit(); + } + } + + String generateSqlRequest(int resourceId, int snapshotId) { + return "UPDATE reviews SET status='CLOSED' " + "WHERE resource_id = " + resourceId + " AND rule_failure_permanent_id NOT IN " + + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id = " + snapshotId + " AND permanent_id IS NOT NULL)"; + } + +} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java deleted file mode 100644 index c4be5daf4f0..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.sensors; - -import javax.persistence.Query; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.batch.Decorator; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.batch.DependsUpon; -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; -import org.sonar.batch.index.ResourcePersister; - -/** - * Decorator that currently only closes a review when its corresponding violation has been fixed. - */ -@DependsUpon("ViolationPersisterDecorator") -public class ReviewsDecorator implements Decorator { - - private static final Logger LOG = LoggerFactory.getLogger(ReviewsDecorator.class); - - private ResourcePersister resourcePersister; - private DatabaseSession databaseSession; - - public ReviewsDecorator(ResourcePersister resourcePersister, DatabaseSession databaseSession) { - this.resourcePersister = resourcePersister; - this.databaseSession = databaseSession; - } - - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - public void decorate(Resource resource, DecoratorContext context) { - Snapshot currentSnapshot = resourcePersister.getSnapshot(resource); - if (currentSnapshot != null) { - int resourceId = currentSnapshot.getResourceId(); - int snapshotId = currentSnapshot.getId(); - Query query = databaseSession.createNativeQuery(generateSqlRequest(resourceId, snapshotId)); - int rowUpdated = query.executeUpdate(); - LOG.debug("- {} reviews set to 'closed' on resource #{}", rowUpdated, resourceId); - databaseSession.commit(); - } - } - - protected String generateSqlRequest(int resourceId, int snapshotId) { - return "UPDATE reviews SET status='closed' " + "WHERE resource_id = " + resourceId + " AND rule_failure_permanent_id NOT IN " - + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id = " + snapshotId + ")"; - } - -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java new file mode 100644 index 00000000000..493352c1147 --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java @@ -0,0 +1,45 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.sensors; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.sql.Statement; + +import org.junit.Test; +import org.sonar.test.persistence.DatabaseTestCase; + +public class CloseReviewsDecoratorTest extends DatabaseTestCase { + + @Test + public void shouldCloseReviewWithoutCorrespondingViolation() throws Exception { + setupData("fixture"); + + CloseReviewsDecorator reviewsDecorator = new CloseReviewsDecorator(null, null); + String sqlRequest = reviewsDecorator.generateSqlRequest(666, 222); + + Statement stmt = getConnection().createStatement(); + int count = stmt.executeUpdate(sqlRequest); + + assertThat(count, is(1)); + assertTables("shouldCloseReviewWithoutCorrespondingViolation", "reviews"); + } +} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java deleted file mode 100644 index 53c42d1b06a..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.core.sensors; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -import java.sql.Statement; - -import org.junit.Test; -import org.sonar.test.persistence.DatabaseTestCase; - -public class ReviewsDecoratorTest extends DatabaseTestCase { - - @Test - public void shouldCloseReviewWithoutCorrespondingViolation() throws Exception { - setupData("fixture"); - - ReviewsDecorator reviewsDecorator = new ReviewsDecorator(null, null); - String sqlRequest = reviewsDecorator.generateSqlRequest(666, 222); - System.out.println(sqlRequest); - - Statement stmt = getConnection().createStatement(); - int count = stmt.executeUpdate(sqlRequest); - - assertThat(count, is(1)); - assertTables("shouldCloseReviewWithoutCorrespondingViolation", "reviews"); - } -} diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml new file mode 100644 index 00000000000..6142cbf4f3b --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml new file mode 100644 index 00000000000..d46429ddf3d --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml deleted file mode 100644 index d57973770cb..00000000000 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml deleted file mode 100644 index 7d614f3112c..00000000000 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 4e221556509..72893127e98 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -49,6 +49,7 @@ class ResourceController < ApplicationController end end + private def load_extensions @@ -205,7 +206,7 @@ class ResourceController < ApplicationController end end - RuleFailure.find(:all, :include => ['rule', 'reviews' ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| + RuleFailure.find(:all, :include => ['rule', 'review' ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| # sorted by severity => from blocker to info if violation.line && violation.line>0 && @lines @lines[violation.line-1].add_violation(violation) 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 d7d038e98df..ab023eb4311 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,10 +22,9 @@ class ReviewsController < ApplicationController SECTION=Navigation::SECTION_HOME - verify :method => :post, :only => [ :create, :create_comment ], :redirect_to => { :action => :error_not_post } + verify :method => :post, :only => [:violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment], :redirect_to => {:action => :error_not_post} + helper(:reviews,:markdown) - helper(:reviews, :markdown) - def index init_params search_reviews @@ -36,193 +35,149 @@ class ReviewsController < ApplicationController render :partial => 'reviews/show' end - def list - reviews = find_reviews_for_rule_failure params[:rule_failure_permanent_id] - render :partial => "list", :locals => { :reviews => reviews } - end + # + # + # ACTIONS FROM VIOLATIONS TAB OF RESOURCE VIEWER + # + # + + # GET def display_violation - violation = find_last_rule_failure_with_permanent_id params[:rule_failure_permanent_id] + violation = RuleFailure.find(params[:id]) render :partial => "resource/violation", :locals => { :violation => violation } end - def form - rule_failure = find_last_rule_failure_with_permanent_id params[:rule_failure_permanent_id] - @review = Review.new - @review.rule_failure_permanent_id = rule_failure.permanent_id - @review_comment = ReviewComment.new - @review_comment.review_text = "" - if params[:switch_off] - @review.review_type = "f-positive" - else - @review.review_type = Review.default_type - end - render :partial => "form" + # GET + def violation_assign_form + @user_options = options_for_users() + render :partial => "violation_assign_form" end - def create - rule_failure = find_last_rule_failure_with_permanent_id params[:review][:rule_failure_permanent_id] - unless has_rights_to_modify? rule_failure - render :text => "Cannot create the review : access denied." + # POST + def violation_assign + violation = RuleFailure.find(params[:id]) + unless current_user + render :text => "Cannot edit the review : access denied." return end + sanitize_violation(violation) + + violation.build_review(:user_id => current_user.id) + violation.review.assignee = User.find params[:assignee_id] + violation.review.save! + violation.save + + render :partial => "resource/violation", :locals => { :violation => violation } + end + + # GET + def violation_false_positive_form + render :partial => 'reviews/violation_false_positive_form' + end - @review = Review.new(params[:review]) - @review.user = current_user - if params[:assign_to_me] - @review.assignee = current_user + # POST + def violation_flag_as_false_positive + violation=RuleFailure.find params[:id] + unless has_rights_to_modify?(violation) + render :text => "Cannot switch on the violation : access denied." + return end - @review.title = rule_failure.message - @review.status = Review.default_status - @review.severity = Sonar::RulePriority.to_s rule_failure.failure_level - @review.resource = RuleFailure.find( @review.rule_failure_permanent_id, :include => ['snapshot'] ).snapshot.project - @review_comment = ReviewComment.new(params[:review_comment]) - @review_comment.user = current_user - @review.review_comments << @review_comment - if @review.valid? - if @review.review_type == "f-positive" - if rule_failure.get_open_review - current_open_review = rule_failure.get_open_review - current_open_review.status = "closed" - current_open_review.save - end - rule_failure.switched_off = true - rule_failure.save + sanitize_violation(violation) + false_positive=(params[:false_positive]=='true') + violation.switched_off=false_positive + violation.save! + + unless params[:comment].blank? + if violation.review.nil? + violation.build_review(:user_id => current_user.id) end - @review.save - @violation = rule_failure + violation.review.review_type=(false_positive ? Review::TYPE_FALSE_POSITIVE : Review::TYPE_VIOLATION) + violation.review.status=(false_positive ? Review::STATUS_CLOSED : Review::STATUS_OPEN) + violation.review.save! + violation.review.comments.create(:review_text => params[:comment], :user_id => current_user.id) end - render "create_result" + + render :partial => "resource/violation", :locals => { :violation => violation } end - def form_comment - @review_comment = ReviewComment.new - @review_comment.user = current_user - @review_comment.review_id = params[:review_id] - @review_comment.review_text = "" - @rule_failure_permanent_id = params[:rule_failure_permanent_id] - if params[:update_comment] - @update_comment = true - @review_comment.review_text = params[:review_text] + # GET + def violation_comment_form + @violation = RuleFailure.find params[:id] + if !params[:comment_id].blank? && @violation.review + @comment = @violation.review.comments.find(params[:comment_id]) end - render :partial => "form_comment" + render :partial => 'reviews/violation_comment_form' end - def create_comment - rule_failure = find_last_rule_failure_with_permanent_id params[:rule_failure_permanent_id] - unless has_rights_to_modify? rule_failure + # POST + def violation_save_comment + violation = RuleFailure.find params[:id] + unless has_rights_to_modify?(violation) render :text => "Cannot create the comment : access denied." return end + sanitize_violation(violation) - @review_comment = ReviewComment.new(params[:review_comment]) - @review_comment.user = current_user - @rule_failure_permanent_id = params[:rule_failure_permanent_id] - if @review_comment.valid? - @review_comment.save - # -- TODO : should create a Review#create_comment and put the following logic in it - review = @review_comment.review - review.updated_at = @review_comment.created_at - review.save - # -- End of TODO code -- - @violation = rule_failure + unless violation.review + violation.create_review!( + :assignee => (params['assign_to_me']=='me' ? current_user : nil), + :user => current_user) end - render "create_comment_result" - end - def update_comment - review = Review.find params[:review_comment][:review_id] - @review_comment = review.review_comments.last - unless current_user && current_user.id == @review_comment.user_id - render :text => "Cannot modify the comment : access denied." - return + if params[:comment_id] + comment=violation.review.comments.find(params[:comment_id].to_i) + if comment + comment.text=params[:text] + comment.save! + end + else + violation.review.comments.create!(:user => current_user, :text => params[:text]) end - @review_comment.review_text = params[:review_comment][:review_text] - @review_comment.created_at = DateTime.now - @rule_failure_permanent_id = params[:rule_failure_permanent_id] - if @review_comment.valid? - @review_comment.save - review.updated_at = @review_comment.updated_at - review.save - @violation = find_last_rule_failure_with_permanent_id review.rule_failure_permanent_id - end - render "create_comment_result" - end - - def form_assign - @user_options = add_all_users [] - @review_id = params[:review_id] - @rule_failure_permanent_id = params[:rule_failure_permanent_id] - render :partial => "form_assign" - end - - def assign - review = Review.find params[:review_id] - unless current_user - render :text => "Cannot edit the review : access denied." - return - end - - review.assignee = User.find params[:assignee_id] - review.save - violation = find_last_rule_failure_with_permanent_id review.rule_failure_permanent_id render :partial => "resource/violation", :locals => { :violation => violation } end - - def close_review - review = Review.find params[:review_id] - unless current_user - render :text => "Cannot edit the review : access denied." + + # POST + def violation_delete_comment + violation = RuleFailure.find params[:id] + unless has_rights_to_modify?(violation) + render :text => "Cannot delete the comment : access denied." return end - - review.status = "closed" - review.save - violation = find_last_rule_failure_with_permanent_id review.rule_failure_permanent_id - render :partial => "resource/violation", :locals => { :violation => violation } - end - - def switch_on_violation - rule_failure = RuleFailure.find params[:rule_failure_id] - unless has_rights_to_modify? rule_failure - render :text => "Cannot switch on the violation : access denied." - return + sanitize_violation(violation) + if violation.review + comment=violation.review.comments.find(params[:comment_id].to_i) + comment.delete if comment end - - rule_failure.switched_off = false - rule_failure.save - - review = rule_failure.get_open_review - review.status = "closed" - review.save - - render :partial => "resource/violation", :locals => { :violation => rule_failure } + render :partial => "resource/violation", :locals => { :violation => violation } end + + ## -------------- PRIVATE -------------- ## private def init_params - @user_names = [["Any", ""]] + @user_names = [["Any", ""]] + options_for_users default_user = (current_user ? [current_user.id.to_s] : ['']) - add_all_users @user_names @authors = filter_any(params[:authors]) || [''] @assignees = filter_any(params[:assignees]) || default_user @severities = filter_any(params[:severities]) || [''] @statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN] @projects = filter_any(params[:projects]) || [''] end - - def add_all_users ( user_options ) + + def options_for_users + options=[] User.find( :all ).each do |user| - userName = user.name + username = user.name if current_user && current_user.id == user.id - userName = "Me (" + user.name + ")" + username = "Me (" + user.name + ")" end - user_options << [userName, user.id.to_s] + options<<[username, user.id.to_s] end - return user_options + options end def filter_any(array) @@ -233,8 +188,8 @@ class ReviewsController < ApplicationController end def search_reviews - conditions=[] - values={} + conditions=['review_type<>:not_type'] + values={:not_type => Review::TYPE_FALSE_POSITIVE} unless @statuses == [""] conditions << "status in (:statuses)" @@ -246,36 +201,30 @@ class ReviewsController < ApplicationController end unless @authors == [""] conditions << "user_id in (:authors)" - values[:authors]=@authors + values[:authors]=@authors.map{|s| s.to_i} end unless @assignees == [""] conditions << "assignee_id in (:assignees)" - values[:assignees]=@assignees + values[:assignees]=@assignees.map{|s| s.to_i} end @reviews = Review.find( :all, :order => "created_at DESC", :conditions => [ conditions.join(" AND "), values] ).uniq end - def find_reviews_for_rule_failure ( rule_failure_permanent_id ) - return Review.find :all, :conditions => ['rule_failure_permanent_id=?', rule_failure_permanent_id] - end - - def find_last_rule_failure_with_permanent_id ( rule_failure_permanent_id ) - return RuleFailure.last( :all, :conditions => [ "permanent_id = ?", rule_failure_permanent_id ], :include => ['snapshot'] ) - end - - def has_rights_to_modify? ( rule_failure ) - return false unless current_user - - project = rule_failure.snapshot.root_project - unless has_role?(:user, project) - return false - end - return true + def has_rights_to_modify?(violation) + current_user && has_role?(:user, violation.snapshot) end def error_not_post render :text => "Create actions must use POST method." end + def sanitize_violation(violation) + # the field RULE_FAILURES.PERMANENT_ID is not set when upgrading to version 2.8. + # It must be manually set when using a violation created before v2.8. + if violation.permanent_id.nil? + violation.permanent_id=violation.id + violation.save + end + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index 0e45f87f94b..b05498c097f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -23,32 +23,20 @@ class Review < ActiveRecord::Base belongs_to :resource, :class_name => "Project", :foreign_key => "resource_id" belongs_to :project, :class_name => "Project", :foreign_key => "project_id" has_many :review_comments, :order => "created_at", :dependent => :destroy + alias_attribute :comments, :review_comments belongs_to :rule_failure, :foreign_key => 'rule_failure_permanent_id' validates_presence_of :user, :message => "can't be empty" - validates_presence_of :title, :message => "can't be empty" validates_presence_of :review_type, :message => "can't be empty" validates_presence_of :status, :message => "can't be empty" before_save :assign_project - TYPE_COMMENTS = "comments" - TYPE_FALSE_POSITIVE = "f-positive" + TYPE_VIOLATION = 'VIOLATION' + TYPE_FALSE_POSITIVE = 'FALSE_POSITIVE' - STATUS_OPEN = "open" - STATUS_CLOSED = "closed" - - def self.default_severity - return Severity::MAJOR - end - - def self.default_type - return TYPE_COMMENTS - end - - def self.default_status - return STATUS_OPEN - end + STATUS_OPEN = 'OPEN' + STATUS_CLOSED = 'CLOSED' def on_project? resource_id==project_id @@ -61,10 +49,6 @@ class Review < ActiveRecord::Base end end - def comments - review_comments - end - private def assign_project diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review_comment.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review_comment.rb index c690fd5ff4f..fa427eb43a5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review_comment.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review_comment.rb @@ -28,7 +28,7 @@ class ReviewComment < ActiveRecord::Base private def comment_should_not_be_empty - errors.add("Comment", " cannot be empty") if review_text.strip.blank? + errors.add("Comment", " cannot be empty") if review_text.blank? end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index b284b305bcb..890c4e7dd90 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -22,17 +22,25 @@ class RuleFailure < ActiveRecord::Base belongs_to :rule belongs_to :snapshot - has_many :reviews, :primary_key => "permanent_id", :foreign_key => "rule_failure_permanent_id", :order => "created_at" + has_one :review, :primary_key => "permanent_id", :foreign_key => "rule_failure_permanent_id", :order => "created_at" - def get_open_review - reviews.each do |review| - if review.status == "open" - return review - end - end - return nil + def false_positive? + switched_off==true end - + + # first line of message + def title + @title||= + begin + if message.blank? + rule.name + else + parts=message.split(/\r?\n|\r/, -1) + parts.size==0 ? rule.name : parts[0] + end + end + end + def to_hash_json json = {} json['message'] = message @@ -53,8 +61,7 @@ class RuleFailure < ActiveRecord::Base :qualifier => snapshot.project.qualifier, :language => snapshot.project.language } - open_review = get_open_review - json['review'] = open_review.to_hash_json ( false ) if open_review + json['review'] = review.to_hash_json(false) if review json end @@ -85,4 +92,20 @@ class RuleFailure < ActiveRecord::Base datetime.strftime("%Y-%m-%dT%H:%M:%S%z") end + def build_review(options={}) + if review.nil? + self.review=Review.new( + {:review_type => Review::TYPE_VIOLATION, + :status => Review::STATUS_OPEN, + :severity => Sonar::RulePriority.to_s(failure_level), + :resource_line => line, + :resource => snapshot.resource, + :title => title}.merge(options)) + end + end + + def create_review!(options={}) + build_review(options) + self.review.save! + 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 4d52a57dcfe..a6adaa5e811 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 @@ -1,80 +1,51 @@ -
-<% - current_open_review = violation.get_open_review - false_positive = (current_open_review && current_open_review.review_type == "f-positive") -%> - +
-
- <% if current_open_review %> -
#<%= current_open_review.id.to_s -%>
+ <% if violation.review %> +
#<%= violation.review.id -%>
<% end %> - <%= image_tag("priority/" + violation.failure_level.to_s + ".png") -%> + <%= image_tag("priority/" + violation.failure_level.to_s + '.png') -%>   <%= image_tag("sep12.png") -%> -    +   <%= h(violation.rule.name) -%> -    +   <%= image_tag("sep12.png") -%> -    - <% - if violation.created_at - duration=Date.today - violation.created_at.to_date - %> - <%= duration==0 ? 'today' : "#{duration} days ago" -%> -    +   + <% if violation.created_at %> + <%= distance_of_time_in_words_to_now(violation.created_at) -%> +   <% end %> - <% if false_positive %> + <% if violation.false_positive? %> <%= image_tag("sep12.png") -%> -    - False-Positive -    +   + False-Positive +   <% end %> - <% if current_open_review && current_open_review.assignee %> + <% if violation.review && violation.review.assignee_id %> <%= image_tag("sep12.png") -%> -    - <%= h(current_open_review.assignee.name) -%> -    +   + Assigned to: <%= h(violation.review.assignee.name) -%> +   <% end %> - <% if current_user %> - + <%= image_tag("sep12.png") -%> -    - <% if current_open_review && !false_positive %> - <%= link_to_remote "Close review", - :url => { :controller => "reviews", :action => "close_review", :review_id => current_open_review.id, :rule_failure_permanent_id => violation.permanent_id }, - :update => "vId" + violation.permanent_id.to_s -%> -    - <%= link_to_remote (current_open_review.assignee == nil ? "Assign" : "Reassign"), - :url => { :controller => "reviews", :action => "form_assign", :review_id => current_open_review.id, :rule_failure_permanent_id => violation.permanent_id }, - :update => "vActions" + violation.permanent_id.to_s, - :complete => "$('vActions" + violation.permanent_id.to_s + "').style.visibility='visible';$('assignee_id').focus();" -%> -    - <% end %> - <% unless current_open_review %> - <%= link_to_remote "Review", - :url => { :controller => "reviews", :action => "form", :rule_failure_permanent_id => violation.permanent_id }, - :update => "reviewForm" + violation.permanent_id.to_s, - :complete => "$('reviewForm" + violation.permanent_id.to_s + "').style.display='';$('reviewText').focus();" -%> -    - <% end %> - <% if violation.switched_off %> - <%= link_to_remote "Switch-on", - :url => { :controller => "reviews", :action => "switch_on_violation", :rule_failure_id => violation.id }, - :update => "vId" + violation.permanent_id.to_s -%> - <% else %> - <%= link_to_remote "Switch-off", - :url => { :controller => "reviews", :action => "form", :rule_failure_permanent_id => violation.permanent_id, :switch_off => true }, - :update => "reviewForm" + violation.permanent_id.to_s, - :complete => "$('reviewForm" + violation.permanent_id.to_s + "').style.display='';$('reviewText').focus();" -%> - <% end %> -    +   + <%= link_to_remote (violation.review && violation.review.assignee_id ? "Reassign" : "Assign"), + :url => { :controller => "reviews", :action => "violation_assign_form", :violation_id => violation.id}, + :update => "vActions" + violation.id.to_s, + :complete => "$('vActions" + violation.id.to_s + "').show();$('assignee_id').focus();" -%> +   + + <%= 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();" -%> <% end %> @@ -85,26 +56,30 @@
<% - if current_open_review - last_comment = current_open_review.review_comments.last - current_open_review.review_comments.each do |review_comment| + if violation.review + violation.review.comments.each_with_index do |review_comment, comment_index| + is_last_comment=(comment_index==violation.review.comments.size-1) %>
- <% duration=Date.today - review_comment.created_at.to_date %> -

<%= image_tag("reviews/comment.png") -%>  <%= review_comment.user.name -%> (<%= duration==0 ? 'today' : "#{duration} days ago" -%>) - <% if review_comment == last_comment && current_user && current_user.id == review_comment.user.id %> +

<%= image_tag("reviews/comment.png") -%>  <%= review_comment.user.name -%> (<%= distance_of_time_in_words_to_now(review_comment.created_at) -%>) + <% if is_last_comment && current_user && current_user.id == review_comment.user_id %>    <%= image_tag("sep12.png") -%>    <%= link_to_remote "Edit", - :url => { :controller => "reviews", :action => "form_comment", :review_id => current_open_review.id, :rule_failure_permanent_id => violation.permanent_id, :review_text => last_comment.review_text, :update_comment => "true" }, - :update => "lastComment" + violation.permanent_id.to_s, - :complete => "$('commentText" + violation.permanent_id.to_s + "').focus()" -%> + :url => { :controller => "reviews", :action => "violation_comment_form", :comment_id => review_comment.id, :id => violation.id }, + :update => "lastComment" + violation.id.to_s, + :complete => "$('reviewForm#{violation.id}').hide();$('vActions#{violation.id}').hide();$('commentText#{violation.id}').focus();" -%> + + <%= link_to_remote "Delete", + :url => { :controller => "reviews", :action => "violation_delete_comment", :comment_id => review_comment.id, :id => violation.id }, + :update => "vId" + violation.id.to_s, + :confirm => "Do you want to delete this comment ?" -%> <% end %>

- <% if review_comment == last_comment %> + <% if is_last_comment %>
<%= markdown_to_html(review_comment.text) -%>
@@ -117,17 +92,17 @@ end %> - - +
-<% if current_user && current_open_review %> -
- <%= link_to_remote "Add comment", - :url => { :controller => "reviews", :action => "form_comment", :review_id => current_open_review.id, :rule_failure_permanent_id => violation.permanent_id }, - :update => "reviewForm" + violation.permanent_id.to_s, - :complete => "$('commentAction" + violation.permanent_id.to_s + "').style.display='none';$('reviewForm" + violation.permanent_id.to_s + "').style.display='';$('commentText" + violation.permanent_id.to_s + "').focus()" -%> + + +<% if current_user %> +
+ <%= link_to_remote "Add comment", + :url => { :controller => "reviews", :action => "violation_comment_form", :id => violation.id }, + :update => "reviewForm" + violation.id.to_s, + :complete => "$('vActions#{violation.id}').hide();$('commentAction" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus()" -%>
<% end %> 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 deleted file mode 100644 index 494bc2974fc..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -<% form_for :review, @review do |f| %> - <%= f.hidden_field :rule_failure_permanent_id -%> - <%= f.hidden_field :review_type -%> - - <% if @review.review_type == "f-positive" %> - Why is it a false-positive ? - <% end %> - <%= text_area :review_comment, :review_text, - :id => "reviewText", :rows => 8, - :style => "width:100%", :onKeyUp => "if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';" -%> -
- -
- <% - if @review.review_type == "comments" - button_text = "Post review" - else - button_text = "Switch-off violation" - end - %> - <%= submit_to_remote "submit_btn", button_text, :url => { :action => 'create' }, :html => { :id => "submit_btn", :disabled => "true" } -%> -    - Cancel - <% if @review.review_type == "comments" %> -    - <%= check_box_tag "assign_to_me", "me", true -%> Assign to me - <% end %> -
-
-<% end %> \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_assign.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_assign.html.erb deleted file mode 100644 index 4c53bb70131..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_assign.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<%= image_tag("sep12.png") -%> -   -<% form_tag :html => {:style => "display:inline"} do %> - <%= hidden_field_tag :review_id, @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 => "vId" + @rule_failure_permanent_id.to_s -%> -    - <%= link_to_remote 'Cancel', - :url => { :action => 'display_violation', :rule_failure_permanent_id => @rule_failure_permanent_id }, - :update => "vId" + @rule_failure_permanent_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 deleted file mode 100644 index 016e8052e99..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<% form_for :review_comment, @review_comment do |f| %> - <%= f.hidden_field :review_id %> - <%= f.text_area :review_text, :rows => 8, - :id => "commentText" + @rule_failure_permanent_id.to_s, - :style => "width:100%", - :onKeyUp => "if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';" %> -
- - <% if @update_comment %> - <%= submit_to_remote 'submit_btn', 'Update comment', - :url => { :action => 'update_comment', - :rule_failure_permanent_id => @rule_failure_permanent_id }, - :html => { :id => "submit_btn" } %> -    - <%= link_to_remote 'Cancel', - :url => { :action => 'display_violation', - :rule_failure_permanent_id => @rule_failure_permanent_id }, - :update => "vId" + @rule_failure_permanent_id.to_s %> - <% else %> - <%= submit_to_remote 'submit_btn', 'Post comment', - :url => { :action => 'create_comment', - :rule_failure_permanent_id => @rule_failure_permanent_id }, - :html => { :id => "submit_btn", :disabled => true } %> -    - Cancel - <% end %> - -<% 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 deleted file mode 100644 index 2fbbd000238..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% - 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/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb index 970a328bfee..80a5c613d14 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 @@ -10,13 +10,13 @@ Status: - <%= image_tag "status/#{review.status}.png" -%> <%= review.status -%> + <%= image_tag "status/#{review.status}.png" -%> <%= review.status.capitalize -%> Severity: - <%= image_tag "priority/#{review.severity}.png" -%> <%= review.severity -%> + <%= image_tag "priority/#{review.severity}.png" -%> <%= review.severity.capitalize -%> @@ -39,7 +39,7 @@ Rule: - <%= h(review.rule.key) -%> + <%= h(review.rule.name) -%> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_show.html.erb index 45b8bc3a8af..7e90b13accb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_show.html.erb @@ -1,5 +1,5 @@ <%= render :partial => 'reviews/review', :locals => {:review => @review} -%> \ 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 deleted file mode 100644 index aa12cbc38fb..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb +++ /dev/null @@ -1,65 +0,0 @@ -
-
- Review #<%= review.id -%> - <%= h(review.title) -%> -
- <% if review.assignee %> - Assigned to <%= h(review.assignee.name) -%> - <% end %> -
- -
- <% unless review.review_comments.blank? - last_comment = review.review_comments.last - review.review_comments.each do |review_comment| - %> - - - - - - - - -
- <%= image_tag("user.png") -%> <%= h(review_comment.user.name) -%> - - <%= l review_comment.created_at -%> -
- <% if review_comment == last_comment %> -
- <%= h(review_comment.review_text) -%> -
- <% else %> - <%= h(review_comment.review_text) -%> - <% end %> -
- <% - end - end - %> - - <% if current_user %> -
- <% if current_user.id == review.review_comments.last.user_id %> - <%= image_tag("pencil.png") -%> - <%= link_to_remote "Edit my last comment", - :url => { :controller => "reviews", :action => "form_comment", - :review_id => review.id, - :rule_failure_permanent_id => review.rule_failure_permanent_id, - :review_text => review.review_comments.last.review_text, - :update_comment => "true" }, - :update => "lastComment" + review.id.to_s, - :complete => "$('commentText" + review.id.to_s + "').focus()" -%> -   - <% end %> - <%= image_tag("pencil.png") -%> - <%= link_to_remote "Add a new comment", - :url => { :controller => "reviews", :action => "form_comment", :review_id => review.id, :rule_failure_permanent_id => review.rule_failure_permanent_id }, - :update => "createComment" + review.id.to_s, - :complete => "$('commentText" + review.id.to_s + "').focus()" -%> -
-
- <% end %> -
- -
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb new file mode 100644 index 00000000000..2b2b35030bb --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb @@ -0,0 +1,14 @@ +<%= image_tag("sep12.png") -%> +   +<% form_tag :html => {:style => "display:inline"} do %> + <%= hidden_field_tag :id, params[:violation_id] -%> + <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %> +    + <%= submit_to_remote "submit_btn", "Assign", + :url => { :action => 'violation_assign' }, + :update => "vId" + params[:violation_id] -%> +    + <%= link_to_remote 'Cancel', + :url => { :action => 'display_violation', :id => params[:violation_id] }, + :update => "vId" + params[:violation_id] %> +<% end %> \ 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 new file mode 100644 index 00000000000..18e604906e1 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb @@ -0,0 +1,18 @@ +<% + button=(@comment ? 'Update comment' : 'Add comment') +%> + +
+ + <% if @comment %> + + <% end %> + + <%= submit_to_remote "submit_btn", button, :url => { :action => 'violation_save_comment'}, :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] -%> + + <% if @violation.review.nil? || @violation.review.comments.size==0 %> +    + <%= check_box_tag "assign_to_me", "me", true -%> + <% end %> +
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 new file mode 100644 index 00000000000..109f3a292bd --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb @@ -0,0 +1,19 @@ +<% + if params[:false_positive]=='true' + title = "Why is it a false-positive ?" + button = "Flag as false-positive" + else + title = "Why is it not a false-positive anymore ?" + button = "Unflag as false-positive" + end + %> +
+ + <% if params[:false_positive]=='true' -%> + + <% end %> +

<%= title -%>

+ + <%= 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] -%> +
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_comment_result.js.rjs b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_comment_result.js.rjs deleted file mode 100644 index 3281ad51d3b..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_comment_result.js.rjs +++ /dev/null @@ -1,5 +0,0 @@ -if @violation - page.replace "vId" + @violation.permanent_id.to_s, :partial => "resource/violation", :locals => { :violation => @violation } -else - page.replace_html "reviewForm" + @rule_failure_permanent_id.to_s, :partial => "form_comment" -end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs deleted file mode 100644 index 9e735242a22..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs +++ /dev/null @@ -1,5 +0,0 @@ -if @violation - page.replace "vId" + @violation.permanent_id.to_s, :partial => "resource/violation", :locals => { :violation => @violation } -else - page.replace_html "reviewForm" + @review.rule_failure_permanent_id.to_s, :partial => "form" -end \ No newline at end of file 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 67707ac52f6..0000c7478bc 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 @@ -1,124 +1,130 @@ - - - + + \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/191_create_review.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/191_create_review.rb index e2827654bed..224f95f3804 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/191_create_review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/191_create_review.rb @@ -30,7 +30,7 @@ class CreateReview < ActiveRecord::Migration t.column 'user_id', :integer, :null => true t.column 'assignee_id', :integer, :null => true t.column 'title', :string, :null => true, :limit => 500 - t.column 'review_type', :string, :null => true, :limit => 10 + t.column 'review_type', :string, :null => true, :limit => 15 t.column 'status', :string, :null => true, :limit => 10 t.column 'severity', :string, :null => true, :limit => 10 t.column 'rule_failure_permanent_id', :integer, :null => true diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index ed955431b87..513a1962de2 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -687,9 +687,12 @@ div.vtitle{ margin:0; padding:0 10px; line-height: 2.2em; - text-shadow: 1px 1px 0 #FFF; + text-shadow: 0 1px 0 #FFF; color:#777 } +.falsePositive { + background-color: #FFF6BF; +} div.vtitle a.action { color: #777; } @@ -1108,10 +1111,10 @@ select.withIcons option { vertical-align: middle; } option.status_open { - background-image: url('../images/status/open.png'); + background-image: url('../images/status/OPEN.png'); } option.status_closed { - background-image: url('../images/status/closed.png'); + background-image: url('../images/status/CLOSED.png'); } option.sev_INFO { background-image: url('../images/priority/INFO.png');