diff options
Diffstat (limited to 'sonar-server/src/main')
60 files changed, 116 insertions, 4280 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 5fb1aea2951..a1605e29579 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -59,7 +59,6 @@ import org.sonar.core.test.TestablePerspectiveLoader; import org.sonar.core.timemachine.Periods; import org.sonar.core.user.DefaultUserFinder; import org.sonar.core.user.HibernateUserFinder; -import org.sonar.core.workflow.ReviewDatabaseStore; import org.sonar.core.workflow.WorkflowEngine; import org.sonar.jpa.dao.MeasuresDao; import org.sonar.jpa.dao.ProfilesDao; @@ -209,7 +208,6 @@ public final class Platform { private void startServiceComponents() { servicesContainer = coreContainer.createChild(); servicesContainer.addSingleton(DefaultWorkflow.class); - servicesContainer.addSingleton(ReviewDatabaseStore.class); servicesContainer.addSingleton(WorkflowEngine.class); servicesContainer.addSingleton(HttpDownloader.class); servicesContainer.addSingleton(UriReader.class); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java index 01a963443f3..4aa9d3e3f59 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java @@ -28,7 +28,7 @@ import org.sonar.api.web.*; */ public final class DefaultPages { - private static final View[] PAGES = {new SourceTab(), new CoverageTab(), new ViolationsTab(), new IssuesTab(), new DuplicationsTab()}; + private static final View[] PAGES = {new SourceTab(), new CoverageTab(), new IssuesTab(), new DuplicationsTab()}; private DefaultPages() { } @@ -98,39 +98,11 @@ public final class DefaultPages { @NavigationSection(NavigationSection.RESOURCE_TAB) @DefaultTab( - metrics = {CoreMetrics.VIOLATIONS_DENSITY_KEY, CoreMetrics.WEIGHTED_VIOLATIONS_KEY, CoreMetrics.VIOLATIONS_KEY, CoreMetrics.BLOCKER_VIOLATIONS_KEY, - CoreMetrics.CRITICAL_VIOLATIONS_KEY, CoreMetrics.MAJOR_VIOLATIONS_KEY, CoreMetrics.MINOR_VIOLATIONS_KEY, CoreMetrics.INFO_VIOLATIONS_KEY, - CoreMetrics.NEW_VIOLATIONS_KEY, CoreMetrics.NEW_BLOCKER_VIOLATIONS_KEY, CoreMetrics.NEW_CRITICAL_VIOLATIONS_KEY, CoreMetrics.NEW_MAJOR_VIOLATIONS_KEY, - CoreMetrics.NEW_MINOR_VIOLATIONS_KEY, CoreMetrics.NEW_INFO_VIOLATIONS_KEY, CoreMetrics.ACTIVE_REVIEWS_KEY, CoreMetrics.UNASSIGNED_REVIEWS_KEY, - CoreMetrics.UNPLANNED_REVIEWS_KEY, CoreMetrics.FALSE_POSITIVE_REVIEWS_KEY, CoreMetrics.UNREVIEWED_VIOLATIONS_KEY, CoreMetrics.NEW_UNREVIEWED_VIOLATIONS_KEY}) - @ResourceQualifier( - value = {Qualifiers.VIEW, Qualifiers.SUBVIEW, Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.CLASS, - Qualifiers.UNIT_TEST_FILE}) - @UserRole(UserRole.CODEVIEWER) - private static final class ViolationsTab implements RubyRailsPage { - public String getTemplate() { - // not used, hardcoded in BrowseController - return "browse/index"; - } - - public String getId() { - return "violations"; - } - - public String getTitle() { - return "Violations"; - } - } - - @NavigationSection(NavigationSection.RESOURCE_TAB) - @DefaultTab( - metrics = {CoreMetrics.ISSUES_DENSITY_KEY, CoreMetrics.WEIGHTED_ISSUES_KEY, CoreMetrics.ISSUES_KEY, CoreMetrics.BLOCKER_ISSUES_KEY, - CoreMetrics.CRITICAL_ISSUES_KEY, CoreMetrics.MAJOR_ISSUES_KEY, CoreMetrics.MINOR_ISSUES_KEY, CoreMetrics.INFO_ISSUES_KEY, - CoreMetrics.NEW_ISSUES_KEY, CoreMetrics.NEW_BLOCKER_ISSUES_KEY, CoreMetrics.NEW_CRITICAL_ISSUES_KEY, CoreMetrics.NEW_MAJOR_ISSUES_KEY, - CoreMetrics.NEW_MINOR_ISSUES_KEY, CoreMetrics.NEW_INFO_ISSUES_KEY, - CoreMetrics.UNASSIGNED_ISSUES_KEY, CoreMetrics.FALSE_POSITIVE_ISSUES_KEY - // TODO -// CoreMetrics.UNPLANNED_REVIEWS_KEY + metrics = {CoreMetrics.VIOLATIONS_DENSITY_KEY, CoreMetrics.WEIGHTED_VIOLATIONS_KEY, CoreMetrics.VIOLATIONS_KEY, CoreMetrics.BLOCKER_VIOLATIONS_KEY, + CoreMetrics.CRITICAL_VIOLATIONS_KEY, CoreMetrics.MAJOR_VIOLATIONS_KEY, CoreMetrics.MINOR_VIOLATIONS_KEY, CoreMetrics.INFO_VIOLATIONS_KEY, + CoreMetrics.NEW_VIOLATIONS_KEY, CoreMetrics.NEW_BLOCKER_VIOLATIONS_KEY, CoreMetrics.NEW_CRITICAL_VIOLATIONS_KEY, CoreMetrics.NEW_MAJOR_VIOLATIONS_KEY, + CoreMetrics.NEW_MINOR_VIOLATIONS_KEY, CoreMetrics.NEW_INFO_VIOLATIONS_KEY, + CoreMetrics.FALSE_POSITIVE_ISSUES_KEY }) @ResourceQualifier( value = {Qualifiers.VIEW, Qualifiers.SUBVIEW, Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.CLASS, diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/gwp_resources_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/gwp_resources_controller.rb index 8dd46e4f28f..e1a641c6096 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/gwp_resources_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/gwp_resources_controller.rb @@ -20,7 +20,8 @@ require "json" -# Google Wire Protocol controller helper +# Google Wire Protocol controller helper. +# Used by the MotionChart plugin. class Api::GwpResourcesController < Api::ResourceRestController before_filter :parse_gwp_params diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb deleted file mode 100644 index 50a3c3c4a06..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb +++ /dev/null @@ -1,326 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -require 'json' - -class Api::ReviewsController < Api::ApiController - - verify :method => :put, :only => [:add_comment, :reassign, :resolve, :reopen] - verify :method => :post, :only => [:create] - - # - # --- Search reviews --- - # Since 2.8 - # - # GET /api/reviews - # Optional parameters : - # - 'statuses' - # - 'resolutions' (since 2.9) - # - 'severities' - # - 'projects' - # - 'resources' - # - 'authors' - # - 'assignees' - # - def index - reviews=select_authorized(:user, Review.search(params.merge({'limit' => 500})), :project) - - render_reviews(reviews, params[:output] == 'HTML') - end - - # Review of an existing violation or create a new violation. - # - # Since 2.9 - # POST /api/reviews - # - # ==== Requirements - # - # * If the violation must be created on a given line of a file, then source code must be available. It - # means that it's not compatible with the property sonar.importSources=false. - # - # * Requires the USER role on the related project - # - # ==== Parameters - # - # To review an existing violation : - # * 'violation_id' : the violation on which the review should be created - # - # To create a violation : - # * 'rule_name' : the name of the rule in the repository "manual". If it does not exist then the rule is created. - # * 'resource' : id or key of the resource to review - # * 'line' : optional line. It starts from 1. If 0 then no specific line. Default value is 0. - # * 'severity' : BLOCKER, CRITICAL, MAJOR, MINOR or INFO. Default value is MAJOR. - # * 'cost' : optional numeric cost - # - # Other parameters : - # * 'status' : the initial status (can be 'OPEN' or 'RESOLVED') - # * 'comment' : the text of the comment - # * 'resolution' (optional) : if status 'RESOLVED', then resolution must be provided (can be 'FIXED' or 'FALSE-POSITIVE') - # * 'assignee' (optional) : login used to create a review directly assigned - # - # ==== Examples - # - # * Create a manual violation : POST /api/reviews?resource=MyFile&line=18&status=OPEN&rule_name=Performance%20Issue - # * Review an existing violation : POST /api/reviews?violation_id=1&status=OPEN&assignee=admin&comment=Please%20fix%20this - # * Flag an existing violation as false-positive : POST /api/reviews/?violation_id=2&status=RESOLVED&resolution=FALSE-POSITIVE&comment=No%20violation%20here - # * Resolve an existing violation : POST /api/reviews/?violation_id=3&status=RESOLVED&resolution=FIXED&assignee=admin&comment=This%20violation%20was%20fixed%20by%20me - # - def create - # Validate parameters - convert_markdown=(params[:output]=='HTML') - assignee = find_user(params[:assignee]) - status = params[:status] - resolution = params[:resolution] - comment = params[:comment] || request.raw_post - bad_request("Missing parameter 'status'") if status.blank? - bad_request("Missing parameter 'comment'") if comment.blank? - review = nil - - Review.transaction do - if params[:violation_id].present? - # Review an existing violation - violation = RuleFailure.find(params[:violation_id], :include => :rule) - access_denied unless has_rights_to_modify?(violation.resource) - bad_request("Violation is already reviewed") if violation.review - sanitize_violation(violation) - violation.create_review!(:assignee => assignee, :user => current_user, :manual_violation => false) - - else - # Manually create a violation and review it - bad_request("Missing parameter 'rule_name'") if params[:rule_name].blank? - bad_request("Missing parameter 'resource'") if params[:resource].blank? - resource = Project.by_key(params[:resource]) - access_denied unless resource && has_rights_to_modify?(resource) - bad_request("Resource does not exist") unless resource.last_snapshot - - rule = Rule.find_or_create_manual_rule(params[:rule_name], has_role?(:admin)) - access_denied unless rule - violation = rule.create_violation!(resource, params) - violation.create_review!(:assignee => assignee, :user => current_user, :manual_violation => true) - end - - # Set review status - review = violation.review - if status == Review::STATUS_OPEN - review.create_comment(:user => current_user, :text => comment) - elsif status == Review::STATUS_RESOLVED - if resolution == Review::RESOLUTION_FALSE_POSITIVE - review.set_false_positive(true, current_user, :text => comment) - elsif resolution == Review::RESOLUTION_FIXED - review.create_comment(:user => current_user, :text => comment) - review.resolve(current_user) - else - bad_request("Incorrect resolution") - end - else - bad_request("Incorrect status") - end - end - - # 5- And finally send back the review - render_reviews([review], convert_markdown) - end - - # - # --- Add comment --- - # Since 2.9 - # - # PUT /api/reviews/add_comment - # Required parameters: - # - 'id' : the review id - # - 'comment' : the text of the comment - # - # Example : - # - PUT "/api/reviews/add_comment/1?comment=New%20Comment!" - # - def add_comment - begin - review = get_review(params[:id]) - review.transaction do - comment = params[:comment] || request.raw_post - if review.closed? - raise "Closed review can not be commented." - end - raise "Comment must be provided." unless comment && !comment.blank? - review.create_comment(:user => current_user, :text => comment) - end - render_reviews([review], params[:output] == 'HTML') - rescue ApiException => e - render_error(e.msg, e.code) - rescue Exception => e - render_error(e.message, 400) - end - end - - # - # --- Reassign --- - # Since 2.9 - # - # PUT /api/reviews/reassign - # Required parameters: - # - 'id' : the review id - # - 'assignee' : new assignee - # - # Example : - # - PUT "/api/reviews/reassign/1?assignee=fabrice" - # - PUT "/api/reviews/reassign/1?assignee=" - # - def reassign - begin - review = get_review(params[:id]) - review.transaction do - assignee = params[:assignee] - if !review.open? && !review.reopened? - raise "Only open review can be reassigned." - end - if assignee.blank? - user = nil - else - user = find_user(assignee) - raise "Assignee not found." unless user - end - review.reassign(current_user, user) - end - render_reviews([review], params[:output] == 'HTML') - rescue ApiException => e - render_error(e.msg, e.code) - rescue Exception => e - render_error(e.message, 400) - end - end - - # - # --- Resolve --- - # Since 2.9 - # - # PUT /api/reviews/resolve - # Required parameters: - # - 'id' : the review id - # - 'resolution' : can be 'FIXED' or 'FALSE-POSITIVE' - # - 'comment' : the text of the comment - # - # Example : - # - PUT "/api/reviews/resolve/1?resolution=FALSE-POSITIVE&comment=No%20violation%20here" - # - PUT "/api/reviews/resolve/1?resolution=FIXED" - # - PUT "/api/reviews/resolve/1?resolution=FIXED&comment=This%20violation%20was%20fixed%20by%20me" - # - def resolve - begin - review = get_review(params[:id]) - review.transaction do - resolution = params[:resolution] - comment = params[:comment] || request.raw_post - if !review.open? && !review.reopened? - raise "Only open review can be resolved." - end - if resolution == Review::RESOLUTION_FALSE_POSITIVE - raise "Comment must be provided." unless comment && !comment.blank? - review.set_false_positive(true, current_user, :text => comment) - elsif resolution == Review::RESOLUTION_FIXED - review.create_comment(:user => current_user, :text => comment) unless comment.blank? - review.resolve(current_user) - else - raise "Incorrect resolution." - end - end - render_reviews([review], params[:output] == 'HTML') - rescue ApiException => e - render_error(e.msg, e.code) - rescue Exception => e - render_error(e.message, 400) - end - end - - # - # --- Reopen --- - # Since 2.9 - # - # PUT /api/reviews/reopen - # Required parameters: - # - 'id' : the review id - # - 'comment' : the text of the comment - # - # Example : - # - PUT "/api/reviews/reopen/1" - # - PUT "/api/reviews/reopen/1?comment=Not%20fixed" - # - def reopen - begin - review = get_review(params[:id]) - review.transaction do - comment = params[:comment] || request.raw_post - if !review.resolved? - raise "Only resolved review can be reopened." - end - if review.resolution == Review::RESOLUTION_FALSE_POSITIVE - raise "Comment must be provided." unless comment && !comment.blank? - review.set_false_positive(false, current_user, :text => comment) - else - review.reopen(current_user) - review.create_comment(:user => current_user, :text => comment) unless comment.blank? - end - end - render_reviews([review], params[:output] == 'HTML') - rescue ApiException => e - render_error(e.msg, e.code) - rescue Exception => e - render_error(e.message, 400) - end - end - - - private - - def get_review(id) - raise "No 'id' parameter has been provided." unless id - review = Review.find(id, :include => ['project']) - raise ApiException.new(401, 'Unauthorized') unless has_rights_to_modify?(review.project) - review - end - - def render_reviews(reviews, convert_markdown) - respond_to do |format| - format.json { render :json => jsonp(Review.reviews_to_json(reviews, convert_markdown)) } - format.xml { render :xml => Review.reviews_to_xml(reviews, convert_markdown) } - format.text { render :text => text_not_supported } - end - end - - def find_user(login) - unless login.blank? - users = User.find(:all, :conditions => ["login = ?", login]) - users[0] if users.size > 0 - end - end - - def has_rights_to_modify?(object) - current_user && has_role?(:user, object) - 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/controllers/api/violations_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb index 7c5a516a61d..fcde2452670 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb @@ -18,95 +18,68 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -require 'json' +class Api::ViolationsController < Api::ApiController -class Api::ViolationsController < Api::ResourceRestController + def index + conditions={} - def rest_call - snapshot = @resource.last_snapshot - - conditions=[] - values={} if params['scopes'] - conditions << 'snapshots.scope in (:scopes)' - values[:scopes]=params['scopes'].split(',') + rest_error('The parameter "scopes" is not supported since version 3.6.') end + if params['qualifiers'] - conditions << 'snapshots.qualifier in (:qualifiers)' - values[:qualifiers]=params['qualifiers'].split(',') + rest_error('The parameter "qualifiers" is not supported since version 3.6.') end + resource = params[:resource] depth=(params['depth'] ? params['depth'].to_i : 0) if depth==0 - conditions << 'snapshots.id=:sid' - values[:sid]=snapshot.id - + conditions[:components] = resource elsif depth>0 - # all the resource tree - conditions << 'snapshots.root_snapshot_id=:root_sid' - values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id) - - conditions << 'snapshots.path LIKE :path' - values[:path]="#{snapshot.path}#{snapshot.id}.%" - - conditions << 'snapshots.depth=:depth' - values[:depth] = snapshot.depth + depth - + rest_error('The parameter "depth" is not supported since version 3.6.') else # negative : all the resource tree - conditions << '(snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))' - values[:sid] = snapshot.id - values[:root_sid] = (snapshot.root_snapshot_id || snapshot.id) - values[:path]="#{snapshot.path}#{snapshot.id}.%" + conditions[:componentRoots] = resource end if params[:rules] - rule_ids=params[:rules].split(',').map do |key_or_id| - Rule.to_i(key_or_id) - end.compact - conditions << 'rule_failures.rule_id IN (:rule_ids)' - values[:rule_ids] = rule_ids + conditions[:rules] = params[:rules].split(',') end + if params[:priorities] - conditions << 'rule_failures.failure_level IN (:priorities)' - values[:priorities]=params[:priorities].split(',').map do |p| - Sonar::RulePriority.id(p) - end.compact + conditions[:severities] = params[:priorities].split(',') end - if params[:switched_off] == "true" - conditions << 'rule_failures.switched_off=:switched_off' - values[:switched_off] = true - else - conditions << '(rule_failures.switched_off IS NULL OR rule_failures.switched_off=:switched_off)' - values[:switched_off] = false + if params[:switched_off] == 'true' + conditions[:resolutions]='FALSE-POSITIVE' end - limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000) - violations = RuleFailure.all( - :conditions => [ conditions.join(' AND '), values], - :include => [:snapshot, {:snapshot => :project}, :rule, :review], - :order => 'rule_failures.failure_level DESC', - :limit => limit) - rest_render(violations) - end + limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000) + conditions[:pageSize]=limit - def rest_to_json(rule_failures) - include_review=(params['include_review']=='true') - convert_markdown=(params[:output]=='HTML') - JSON(rule_failures.collect{|rule_failure| rule_failure.to_json(include_review, convert_markdown)}) - end + results = Api.issues.find(conditions) - def rest_to_xml(rule_failures) - include_review=(params['include_review']=='true') - convert_markdown=(params[:output]=='HTML') - xml = Builder::XmlMarkup.new(:indent => 0) - xml.instruct! - xml.violations do - rule_failures.each do |rule_failure| - rule_failure.to_xml(xml, include_review, convert_markdown) + array = results.issues.map do |issue| + hash={:id => issue.key} + hash[:message] = issue.message if issue.message + hash[:line] = issue.line.to_i if issue.line + hash[:priority] = issue.severity if issue.severity + hash[:createdAt] = Api::Utils.format_datetime(issue.creationDate) if issue.creationDate + hash[:switchedOff]=true if issue.resolution=='FALSE-POSITIVE' + rule = results.rule(issue) + if rule + hash[:rule] = {:key => rule.ruleKey, :name => Internal.rules.ruleL10nName(rule)} + end + resource = results.component(issue) + if resource + hash[:resource] = {:key => resource.key, :name => resource.name, :qualifier => resource.qualifier} end + hash end - end + respond_to do |format| + format.json { render :json => jsonp(array) } + format.xml { render :xml => array.to_xml(:skip_types => true, :root => 'violations') } + end + end end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb index 703c85bd25d..5c8a11b78e7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb @@ -64,83 +64,6 @@ class DrilldownController < ApplicationController @display_viewers=display_metric_viewers?(@highlighted_resource||@resource, @highlighted_metric.key) end - def violations - @rule=Rule.by_key_or_id(params[:rule]) - - # variation measures - if params[:period].present? && params[:period].to_i>0 - @period=params[:period].to_i - metric_prefix = 'new_' - else - @period=nil - metric_prefix = '' - end - - @severity = params[:severity] || params[:priority] - @rule_severity = params[:rule_sev] || @severity - - if @rule && @rule_severity.blank? - # workaround for SONAR-3255 : guess the severity - @rule_severity=guess_rule_severity(@snapshot, @rule, metric_prefix) - end - - - if @rule_severity.present? - # Filter resources by severity - @metric = Metric::by_key("#{metric_prefix}#{@rule_severity.downcase}_violations") - else - @metric = Metric::by_key("#{metric_prefix}violations") - end - - # selected resources - if params[:rids] - @selected_rids= params[:rids] - elsif params[:resource] - highlighted_resource=Project.by_key(params[:resource]) - @selected_rids=(highlighted_resource ? [highlighted_resource.id] : []) - else - @selected_rids=[] - end - @selected_rids=@selected_rids.map { |r| r.to_i } - - - # options for Drilldown - options={:exclude_zero_value => true, :period => @period} - if @rule - params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id - options[:rule_id]=@rule.id - end - - # load data - @drilldown = Drilldown.new(@resource, @metric, @selected_rids, options) - - @highlighted_resource=@drilldown.highlighted_resource - if @highlighted_resource.nil? && @drilldown.columns.empty? - @highlighted_resource=@resource - end - - - # - # Initialize filter by rule - # - if @severity.present? - # Filter on severity -> filter rule measures by the selected metric - @rule_measures = @snapshot.rule_measures(@metric) - else - # No filter -> loads all the rules - metrics=[ - Metric.by_key("#{metric_prefix}blocker_violations"), - Metric.by_key("#{metric_prefix}critical_violations"), - Metric.by_key("#{metric_prefix}major_violations"), - Metric.by_key("#{metric_prefix}minor_violations"), - Metric.by_key("#{metric_prefix}info_violations") - ] - @rule_measures = @snapshot.rule_measures(metrics) - end - - @display_viewers=display_violation_viewers?(@drilldown.highlighted_snapshot || @snapshot) - end - def issues @rule=Rule.by_key_or_id(params[:rule]) @@ -163,9 +86,9 @@ class DrilldownController < ApplicationController if @rule_severity.present? # Filter resources by severity - @metric = Metric::by_key("#{metric_prefix}#{@rule_severity.downcase}_issues") + @metric = Metric::by_key("#{metric_prefix}#{@rule_severity.downcase}_violations") else - @metric = Metric::by_key("#{metric_prefix}issues") + @metric = Metric::by_key("#{metric_prefix}violations") end # selected resources @@ -203,11 +126,11 @@ class DrilldownController < ApplicationController else # No filter -> loads all the rules metrics=[ - Metric.by_key("#{metric_prefix}blocker_issues"), - Metric.by_key("#{metric_prefix}critical_issues"), - Metric.by_key("#{metric_prefix}major_issues"), - Metric.by_key("#{metric_prefix}minor_issues"), - Metric.by_key("#{metric_prefix}info_issues") + Metric.by_key("#{metric_prefix}blocker_violations"), + Metric.by_key("#{metric_prefix}critical_violations"), + Metric.by_key("#{metric_prefix}major_violations"), + Metric.by_key("#{metric_prefix}minor_violations"), + Metric.by_key("#{metric_prefix}info_violations") ] @rule_measures = @snapshot.rule_measures(metrics) end @@ -279,7 +202,7 @@ class DrilldownController < ApplicationController def guess_rule_severity_for_issues_metric(snapshot, rule, metric_prefix) Severity::KEYS.each do |severity| - if snapshot.rule_measure(Metric.by_key("#{metric_prefix}#{severity.downcase}_issues"), rule) + if snapshot.rule_measure(Metric.by_key("#{metric_prefix}#{severity.downcase}_violations"), rule) return severity end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb +++ /dev/null diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb deleted file mode 100644 index 8ee3fdc166d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb +++ /dev/null @@ -1,322 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class ProjectReviewsController < ApplicationController - - SECTION=Navigation::SECTION_RESOURCE - - verify :method => :post, - :only => [:assign, :flag_as_false_positive, :save_comment, :delete_comment, :change_status, - :link_to_action_plan, :unlink_from_action_plan], - :redirect_to => {:action => :error_not_post} - helper SourceHelper, UsersHelper - - # lists all the reviews of a project, filtered using the same parameters as for the review WS API - def index - @project=Project.by_key(params[:id]) - @project=Project.by_key(params[:projects]) unless @project - - if @project - access_denied unless has_role?(:user, @project) - - # 'id' is the id of the project, so it should be removed from the search params - found_reviews = Review.search(params.reject { |k, v| k=='id' }) - @reviews = select_authorized(:user, found_reviews, :project) - if found_reviews.size != @reviews.size - @security_exclusions = true - end - else - render :text => "<b>Listing reviews without a project reference is not possible</b>. Go to review search service instead." - end - end - - - # Used for the permalink, e.g. http://localhost:9000/project_reviews/view/1 - def view - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - if has_role?(:user, @review.project) - render 'project_reviews/_view', :locals => {:review => @review} - else - render :text => "<b>Cannot access this review</b> : access denied." - end - end - - - # - # - # ACTIONS FROM REVIEW SERVICE PAGE - # - # - - def show - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - if has_role?(:user, @resource) - render :partial => 'project_reviews/view' - else - render :text => "access denied" - end - end - - # GET - def assign_form - @review = Review.find(params[:id]) - render :partial => "assign_form" - end - - # POST - def assign - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot edit the review</b> : access denied." - return - end - - assignee = nil - if params[:me]=='true' - assignee = current_user - - elsif params[:assignee_login].present? - assignee = findUserByLogin(params[:assignee_login]) - end - - @review.reassign(current_user, assignee, params) - render :partial => 'project_reviews/view' - end - - # GET - def comment_form - @review = Review.find(params[:id]) - if !params[:comment_id].blank? && @review - @comment = @review.comments.find(params[:comment_id]) - end - render :partial => 'project_reviews/comment_form' - end - - # POST - def save_comment - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot create the comment</b> : access denied." - return - end - - unless params[:text].blank? - if params[:comment_id] - @review.edit_comment(current_user, params[:comment_id].to_i, params[:text]) - else - @review.create_comment(:user => current_user, :text => params[:text]) - end - end - - render :partial => "project_reviews/view" - end - - # GET - def false_positive_form - @review = Review.find(params[:id]) - render :partial => 'project_reviews/false_positive_form' - end - - # POST - def flag_as_false_positive - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot create the comment</b> : access denied." - return - end - - @review.set_false_positive(params[:false_positive]=='true', current_user, params) - render :partial => "project_reviews/view" - end - - # POST - def delete_comment - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot delete the comment</b> : access denied." - return - end - - if @review - @review.delete_comment(current_user, params[:comment_id].to_i) - end - render :partial => "project_reviews/view" - end - - def change_status_form - @review = Review.find(params[:id]) - render :partial => 'project_reviews/change_status_form' - end - - # POST - def change_status - @review = Review.find(params[:id], :include => ['project']) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot change the status</b> : access denied." - return - end - - if @review.resolved? - @review.reopen(current_user, params) - else - # for the moment, if a review is not open, it can only be "RESOLVED" - @review.resolve(current_user, params) - end - - render :partial => "project_reviews/view" - end - - # GET - def change_severity_form - render :partial => 'project_reviews/change_severity_form' - end - - # POST - def change_severity - @review=Review.find(params[:id], :include => 'project') - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot change severity</b> : access denied." - return - end - - @review.set_severity(params[:severity], current_user, params) - render :partial => "project_reviews/review" - end - - # GET - def action_plan_form - @review = Review.find(params[:id]) - @action_plans = ActionPlan.open_by_project_id(@review.project_id) - render :partial => 'project_reviews/action_plan_form' - end - - # POST - def link_to_action_plan - @review = Review.find(params[:id]) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot link to action plan</b> : access denied." - return - end - - action_plan = params[:action_plan_id].to_i==-1 ? nil : ActionPlan.find(params[:action_plan_id]) - @review.link_to_action_plan(action_plan, current_user, params) - - render :partial => "project_reviews/review" - end - - # POST - def unlink_from_action_plan - @review = Review.find(params[:id]) - @resource = @review.project - unless has_rights_to_modify?(@resource) - render :text => "<b>Cannot link to action plan</b> : access denied." - return - end - - @review.link_to_action_plan(nil, current_user, params) - - render :partial => "project_reviews/review" - end - - # GET - def screen - @review = Review.find(params[:id]) - bad_request('Unknown violation') unless @review - - command = params[:command] - bad_request('Missing command') if command.blank? - - @screen = java_facade.getReviewScreen(command) - bad_request('No associated screen') unless @screen - - render :partial => "project_reviews/screens/#{@screen.getKey()}" - end - - # POST - def execute - bad_request('Missing review id') unless params[:id] - @review = Review.find(params[:id], :include => ['project']) - - access_denied unless has_rights_to_modify?(@review.resource) - - bad_request('Missing command') if params[:command].blank? - - error_message = nil - begin - RuleFailure.execute_command(params[:command], @review.violation, current_user, params) - rescue Exception => e - error_message=Api::Utils.exception_message(e, :backtrace => false) - end - - ActiveRecord::Base.uncached() do - @review.clean_violation_cache - @review.reload - - # TODO remove this ugly workaround to bypass ActiveRecord cache.... - @review.violation.review=@review - end - render :partial => "project_reviews/review", :locals => {:error_message => error_message} - end - - - # - # - # ACTIONS FROM THE REVIEW WIDGETS - # - # - - # GET - def widget_reviews_list - @snapshot = Snapshot.find(params[:snapshot_id]) - unless @snapshot && has_role?(:user, @snapshot) - render :text => "<b>Cannot access the reviews of this project</b>: access denied." - return - end - - @dashboard_configuration=Api::DashboardConfiguration.new(nil, :period_index => params[:period], :snapshot => @snapshot) - render :partial => 'project/widgets/reviews/reviews_list' - end - - - ## -------------- PRIVATE -------------- ## - private - - def findUserByLogin(login) - User.find(:first, :conditions => ["login = ?", login]) - end - - def has_rights_to_modify?(object) - current_user && has_role?(:user, object) - end - - def error_not_post - render :text => "Create actions must use POST method." - end - -end 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 5501d2b547c..e46f5d0ba89 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 @@ -27,8 +27,6 @@ class ResourceController < ApplicationController helper :dashboard helper SourceHelper, UsersHelper - verify :method => :post, :only => [:create_violation] - def index if request.xhr? @resource = Project.by_key(params[:id]) @@ -43,12 +41,9 @@ class ResourceController < ApplicationController load_extensions() if @extension - if @extension.getId()=='violations' - render_violations() - render_partial_index() - elsif @extension.getId()=='issues' + if @extension.getId()=='issues' render_issues() - render :partial => 'index_issues' + render_partial_index() elsif (@extension.getId()=='coverage') render_coverage() render_partial_index() @@ -85,46 +80,6 @@ class ResourceController < ApplicationController :group_index => params[:group_index], :external => (resource.root_id != original_resource.root_id)} end - # Ajax request to display a form to create a review anywhere in source code - def show_create_violation_form - @line = params[:line].to_i - @rules = Rule.manual_rules - @html_id="#{params[:resource]}_#{@line}" - render :partial => 'resource/create_violation_form' - end - - def create_violation - resource = Project.by_key(params[:resource]) - access_denied unless resource && current_user - - rule_id_or_name = params[:rule] - if rule_id_or_name.blank? - access_denied if params[:new_rule].present? && !has_role?(:admin) - rule_id_or_name = params[:new_rule] - end - bad_request(message('code_viewer.create_violation.missing_rule')) if rule_id_or_name.blank? - bad_request(message('code_viewer.create_violation.missing_message')) if params[:message].blank? - bad_request(message('code_viewer.create_violation.missing_severity')) if params[:severity].blank? - - assignee=nil - if params[:assignee_login].present? - assignee = User.first(:conditions => ["login = ?", params[:assignee_login]]) - bad_request(message('code_viewer.create_violation.bad_assignee')) unless assignee - end - violation = nil - Review.transaction do - rule = Rule.find_or_create_manual_rule(rule_id_or_name, true) - violation = rule.create_violation!(resource, params) - violation.create_review!( - :assignee => assignee, - :user => current_user, - :status => Review::STATUS_OPEN, - :manual_violation => true) - end - - render :partial => 'resource/violation', :locals => {:violation => violation} - end - private def render_partial_index @@ -330,81 +285,6 @@ class ResourceController < ApplicationController @duplication_group_warning = message('duplications.dups_found_on_deleted_resource') if dups_found_on_deleted_resource end - - def render_violations - load_sources() - @display_violations=true - @global_violations=[] - @expandable=(@lines!=nil) - @filtered=!@expanded - rule_param=params[:rule] - - options={:snapshot_id => @snapshot.id} - - if rule_param.blank? && params[:metric] - metric = Metric.by_id(params[:metric]) - if metric && (metric.name=='active_reviews' || metric.name=='unassigned_reviews' || metric.name=='unplanned_reviews' || metric.name=='false_positive_reviews'|| metric.name=='unreviewed_violations' || metric.name=='new_unreviewed_violations') - rule_param = metric.name.gsub(/new_/, '') - - # hack to select the correct option in the rule filter select-box - params[:rule] = rule_param - end - end - - if !rule_param.blank? && rule_param!='all' - if rule_param=='false_positive_reviews' - options[:switched_off]=true - - elsif rule_param=='active_reviews' - options[:review_statuses]=[Review::STATUS_OPEN, Review::STATUS_REOPENED, nil] - - elsif rule_param=='unassigned_reviews' - options[:review_statuses]=[Review::STATUS_OPEN, Review::STATUS_REOPENED, nil] - options[:review_assignee_id]=nil - - elsif rule_param=='unplanned_reviews' - options[:review_statuses]=[Review::STATUS_OPEN, Review::STATUS_REOPENED, nil] - options[:planned]=false - - elsif rule_param=='unreviewed_violations' - options[:review_statuses]=[nil] - - elsif Sonar::RulePriority.id(rule_param) - options[:severity]=rule_param - - else - options[:rule_id]=rule_param - end - end - - - if @period && @period != 0 - date=@snapshot.period_datetime(@period) - if date - options[:created_after]=date.advance(:minutes => 1) - end - end - - violations = RuleFailure.search(options) - violations.each do |violation| - # sorted by severity => from blocker to info - if @lines && violation.line && violation.line>0 && violation.line<=@lines.size - @lines[violation.line-1].add_violation(violation) - else - @global_violations<<violation - end - end - - if !@expanded && @lines - filter_lines { |line| line.violations? } - end - - @review_screens_by_vid=nil - if current_user && has_role?(:user, @resource) - @review_screens_by_vid = RuleFailure.available_java_screens_for_violations(violations, @resource, current_user) - end - end - def render_issues load_sources() @display_issues = true @@ -466,11 +346,6 @@ class ResourceController < ApplicationController filter_lines { |line| line.issues? } end - # TODO - #@review_screens_by_vid=nil - #if current_user && has_role?(:user, @resource) - # @review_screens_by_vid = RuleFailure.available_java_screens_for_violations(violations, @resource, current_user) - #end end def render_source 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 deleted file mode 100644 index 040d52e17b0..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ /dev/null @@ -1,383 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class ReviewsController < ApplicationController - - verify :method => :post, - :only => [:violation_assign, :violation_flag_as_false_positive, :violation_change_severity, - :violation_save_comment, :violation_delete_comment, :violation_change_status, - :violation_link_to_action_plan, :violation_unlink_from_action_plan, :execute], - :redirect_to => {:action => :error_not_post} - helper SourceHelper, UsersHelper - - def index - init_params() - search_reviews() - end - - # Used for the "OLD" permalink "http://localhost:9000/reviews/view/1" - # => Since Sonar 2.13, permalinks are "http://localhost:9000/project_reviews/view/1" and are displayed in the context of the project - def view - redirect_to :controller => 'project_reviews', :action => 'view', :id => params[:id] - end - - # GET - def screen - @violation = RuleFailure.find params[:id] - bad_request('Unknown violation') unless @violation - - command = params[:command] - bad_request('Missing command') if command.blank? - - @screen = java_facade.getReviewScreen(command) - bad_request('No associated screen') unless @screen - - render :partial => "reviews/screens/#{@screen.getKey()}" - end - - # POST - def execute - bad_request('Missing violation id') unless params[:id] - violation = RuleFailure.find(:first, :include => [:rule, {:snapshot => :project}, {:review => :action_plans}], :conditions => {:id => params[:id].to_i}) - bad_request('Unknown violation') unless violation - access_denied unless has_rights_to_modify? violation.snapshot - - bad_request('Missing command') if params[:command].blank? - - sanitize_violation(violation) - unless violation.review - violation.create_review!(:user_id => current_user.id) - end - - # TODO remove parameters 'id' and 'command' from params - error_message = nil - begin - RuleFailure.execute_command(params[:command], violation, current_user, params) - rescue Exception => e - error_message=Api::Utils.exception_message(e, :backtrace => false) - end - - # reload data required for display - violation.reload - screens = violation.available_java_screens(current_user) - - render :partial => 'resource/violation', :locals => {:violation => violation, :review_screens => screens, :error_message => error_message} - end - - # - # - # ACTIONS FROM VIOLATIONS TAB OF RESOURCE VIEWER - # - # - - # GET - def display_violation - violation = RuleFailure.find(params[:id]) - screens = violation.available_java_screens(current_user) - render :partial => "resource/violation", :locals => {:violation => violation, :review_screens => screens} - end - - # GET - def violation_assign_form - @violation = RuleFailure.find(params[:id], :include => 'review') - render :partial => "violation_assign_form" - end - - # POST - def violation_assign - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot edit the review</b> : access denied." - return - end - sanitize_violation(violation) - - violation.build_review(:user_id => current_user.id) - assignee=nil - if params[:me]=='true' - assignee = current_user - - elsif params[:assignee_login].present? - assignee = findUserByLogin(params[:assignee_login]) - end - violation.review.reassign(current_user, assignee, params) - violation.save - - display_violation - end - - # GET - def violation_change_severity_form - render :partial => 'reviews/violation_change_severity_form' - end - - # POST - def violation_change_severity - violation=RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot change severity</b> : access denied." - return - end - sanitize_violation(violation) - - if violation.review.nil? - violation.build_review(:user_id => current_user.id) - end - violation.review.set_severity(params[:severity], current_user, params) - # refresh the violation that has been modified - violation.reload - - display_violation - end - - # GET - def violation_false_positive_form - @violation = RuleFailure.find(params[:id]) - render :partial => 'reviews/violation_false_positive_form' - end - - # POST - def violation_flag_as_false_positive - violation=RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot switch on the violation</b> : access denied." - return - end - sanitize_violation(violation) - - if violation.review.nil? - violation.build_review(:user_id => current_user.id) - end - violation.review.set_false_positive(params[:false_positive]=='true', current_user, params) - - # refresh the violation that has been modified when setting the review to false positive - violation.reload - - display_violation - end - - - # 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 => 'reviews/violation_comment_form' - end - - # POST - def violation_save_comment - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot create the comment</b> : access denied." - return - end - sanitize_violation(violation) - - unless violation.review - assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank? - violation.create_review!( - :assignee => assignee, - :user => current_user) - end - - unless params[:text].blank? - if params[:comment_id] - violation.review.edit_comment(current_user, params[:comment_id].to_i, params[:text]) - else - violation.review.create_comment(:user => current_user, :text => params[:text]) - end - end - - display_violation - end - - # POST - def violation_delete_comment - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot delete the comment</b> : access denied." - return - end - sanitize_violation(violation) - if violation.review - violation.review.delete_comment(current_user, params[:comment_id].to_i) - end - display_violation - end - - # GET - def violation_change_status_form - @violation = RuleFailure.find(params[:id], :include => 'review') - render :partial => 'reviews/violation_change_status_form' - end - - # POST - def violation_change_status - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot delete the comment</b> : access denied." - return - end - sanitize_violation(violation) - - if violation.review.nil? - violation.build_review(:user_id => current_user.id) - end - - if violation.review.resolved? - violation.review.reopen(current_user, params) - else - # for the moment, if a review is not open, it can only be "RESOLVED" - violation.review.resolve(current_user, params) - end - - display_violation - end - - # GET - def violation_action_plan_form - @violation = RuleFailure.find(params[:id], :include => ['review', 'snapshot']) - @action_plans = ActionPlan.open_by_project_id(@violation.snapshot.root_project_id) - render :partial => 'reviews/violation_action_plan_form' - end - - # POST - def violation_link_to_action_plan - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot link to action plan</b> : access denied." - return - end - sanitize_violation(violation) - - if violation.review.nil? - violation.build_review(:user_id => current_user.id) - end - action_plan = params[:action_plan_id].to_i==-1 ? nil : ActionPlan.find(params[:action_plan_id]) - violation.review.link_to_action_plan(action_plan, current_user, params) - - display_violation - end - - # POST - def violation_unlink_from_action_plan - violation = RuleFailure.find(params[:id], :include => 'snapshot') - unless has_rights_to_modify?(violation.snapshot) - render :text => "<b>Cannot link to action plan</b> : access denied." - return - end - violation.review.link_to_action_plan(nil, current_user, params) - - display_violation - end - - - ## -------------- PRIVATE -------------- ## - private - - def findUserByLogin(login) - User.find(:first, :conditions => ["login = ?", login]) - end - - def init_params - default_user = (current_user ? current_user.login : '') - @assignee_login = params[:assignee_login] || default_user - @author_login = params[:author_login] || '' - @severities = filter_any(params[:severities]) || [''] - @statuses = filter_any(params[:statuses]) || [Review::STATUS_OPEN, Review::STATUS_REOPENED] - @projects = filter_any(params[:projects]) || [''] - @false_positives = params[:false_positives] || 'without' - @id = params[:review_id] || '' - @sort = params[:sort] - @asc = params[:asc] == "true" - @from = Time.parse(params[:from]) if params[:from] - @to = Time.parse(params[:to]) if params[:to] - end - - def filter_any(array) - if array && array.size>1 && array.include?("") - array=[""] - end - array - end - - def search_reviews - options = {} - unless @statuses == [''] - options['statuses']=@statuses.join(',') - end - unless @projects == [''] - options['projects']=@projects.join(',') - end - unless @severities == [''] - options['severities']=@severities.join(',') - end - if @author_login - options['authors']=@author_login - end - if @assignee_login - options['assignees']=@assignee_login unless @assignee_login.blank? - end - if @false_positives - options['false_positives']=@false_positives - end - if @from - options['from']=@from - end - if @to - options['to']=@to - end - unless @id == '' - if Api::Utils.is_integer? @id - options['ids'] = @id - else - options['ids'] = '-1' - end - end - options['sort'] = @sort unless @sort.blank? - options['asc'] = @asc - options['limit']=500 - - found_reviews = Review.search(options) - @reviews = select_authorized(:user, found_reviews, :project) - if found_reviews.size != @reviews.size - @security_exclusions = true - end - end - - def has_rights_to_modify?(object) - current_user && has_role?(:user, object) - 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/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 25e3cf9e8d9..732cfb2edab 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 @@ -581,29 +581,6 @@ module ApplicationHelper html end - # - # Used on the reviews listing page (http://localhost:9000/project_reviews) - # Prints a label for the given parameter that is used to filter the review list. - # The label has: - # * a name (=the param name) with a tooltip (=the param value) - # * a 'x' action to remove this filter - # - # === Optional parameters - # * title: to overwrite the tooltip of the parameter - # - def review_filter_tag(param_name, params, options={}) - html = "<span class=\"review-filter\" title=\"" - html += options[:title] ? options[:title] : params[param_name] - html += "\">" - html += message('reviews.filtered_by.' + param_name) - html += "<a href=\"" - html += url_for params.reject { |key, value| key==param_name } - html += "\" title=\"" - html += message('reviews.remove_this_filter') - html += "\">X</a></span>" - end - - def select2_tag(name, ws_url, options={}) width=options[:width]||'250px' html_id=options[:html_id]||name diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb deleted file mode 100644 index 951f6fcca1e..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb +++ /dev/null @@ -1,22 +0,0 @@ - # - # Sonar, entreprise quality control tool. - # Copyright (C) 2008-2013 SonarSource - # mailto:contact AT sonarsource DOT com - # - # SonarQube 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. - # - # SonarQube 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 this program; if not, write to the Free Software Foundation, - # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - # -module DrilldownHelper - -end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/reviews_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/reviews_helper.rb deleted file mode 100644 index b0ffc05795e..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/reviews_helper.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -module ReviewsHelper - - def projects_for_select - projects=Project.find(:all, :select => 'id,name,long_name,scope,qualifier,root_id', :conditions => ['enabled=? AND scope=? AND qualifier IN (?)', true, 'PRJ', ['TRK', 'VW', 'SVW']], :order => 'name ASC') - select_authorized(:user, projects) - end - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb index eba5cd0f70e..be98a9e52d8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb @@ -135,34 +135,16 @@ module SourceHelper @id=id end - def add_violation(violation) - @violations||=[] - @violations<<violation - @visible=true - end - def add_issue(issue) @issues||=[] @issues<<issue @visible=true end - def violations? - @violations && @violations.size>0 - end - def issues? @issues && @issues.size>0 end - def violation_severity - if @violations && @violations.size>0 - @violations[0].failure_level - else - nil - end - end - def issue_severity if @issues && @issues.size>0 @issues[0].severity diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb deleted file mode 100644 index 52dc7075234..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb +++ /dev/null @@ -1,100 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class ActionPlan < ActiveRecord::Base - belongs_to :project - has_and_belongs_to_many :reviews - - validates_length_of :name, :within => 1..200 - validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true - validates_presence_of :user_login, :message => "can't be empty" - validates_presence_of :status, :message => "can't be empty" - validates_presence_of :project, :message => "can't be empty" - validate :unique_name_on_same_project - - STATUS_OPEN = 'OPEN' - STATUS_CLOSED = 'CLOSED' - - def self.open_by_project_id(project_id) - ActionPlan.find :all, :conditions => ['status=? AND project_id=?', STATUS_OPEN, project_id], :order => :name - end - - def self.find_by_key(key) - ActionPlan.first :conditions => ['kee=?', key] - end - - def key - kee - end - - def user - @user ||= - begin - user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil - end - end - - def closed? - status == STATUS_CLOSED - end - - def open? - status == STATUS_OPEN - end - - def progress - total_reviews = reviews.size - open_reviews = reviews.select { |r| r.open? || r.reopened? }.size - {:total => total_reviews, :open => open_reviews, :resolved => total_reviews-open_reviews} - end - - def has_open_reviews? - open_reviews.size > 0 - end - - def open_reviews - reviews.select { |r| r.open? || r.reopened? } - end - - def over_due? - deadline ? status==STATUS_OPEN && deadline.past? : false - end - - # since 3.6 - def self.to_hash(java_action_plan) - hash = {:key => java_action_plan.key(), :name => java_action_plan.name(), :status => java_action_plan.status()} - hash[:desc] = java_action_plan.description() if java_action_plan.description() && !java_action_plan.description().blank? - hash[:userLogin] = java_action_plan.userLogin() if java_action_plan.userLogin() - hash[:deadLine] = Api::Utils.format_datetime(java_action_plan.deadLine()) if java_action_plan.deadLine() - hash[:createdAt] = Api::Utils.format_datetime(java_action_plan.createdAt()) if java_action_plan.createdAt() - hash[:updatedAt] = Api::Utils.format_datetime(java_action_plan.updatedAt()) if java_action_plan.updatedAt() - hash - end - - private - - def unique_name_on_same_project - action_plan = ActionPlan.find(:first, :conditions => ['project_id=? AND name=?', project_id, name]) - if action_plan && ((id && action_plan.id!=id) || !id) - errors.add(:base, Api::Utils.message('action_plans.same_name_in_same_project')) - 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 deleted file mode 100644 index 0b6ef6a100f..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ /dev/null @@ -1,495 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -class Review < ActiveRecord::Base - belongs_to :user - belongs_to :assignee, :class_name => "User", :foreign_key => "assignee_id" - belongs_to :resource, :class_name => "Project", :foreign_key => "resource_id" - belongs_to :project, :class_name => "Project", :foreign_key => "project_id" - belongs_to :rule - has_many :review_comments, :order => "created_at", :dependent => :destroy - alias_attribute :comments, :review_comments - has_and_belongs_to_many :action_plans - - validates_presence_of :status, :message => "can't be empty" - validates_inclusion_of :severity, :in => Severity::KEYS - - before_save :assign_project - - STATUS_OPEN = 'OPEN' - STATUS_RESOLVED = 'RESOLVED' - STATUS_REOPENED = 'REOPENED' - STATUS_CLOSED = 'CLOSED' - # "IDLE" is a non-persisted status of an non-existing review = when a violation does have a review yet - # It is currently used by rule_failure.rb (#to_java_workflow_review) to pass a list of reviews to the - # review workflow, even for violations which don't have yet a review. - STATUS_IDLE = 'IDLE' - - RESOLUTION_FALSE_POSITIVE = 'FALSE-POSITIVE' - RESOLUTION_FIXED = 'FIXED' - - def on_project? - resource_id==project_id - end - - def rule - @rule ||= - begin - rule_failure ? rule_failure.rule : nil - end - end - - def violation - rule_failure - end - - def rule_failure - @rule_failure ||= - begin - # We need to manually run this DB request as the real relation Reviews-RuleFailures is 1:n but we want only 1 violation - # (more than 1 violation can have the same "permanent_id" when several analyses are run in a small time frame) - RuleFailure.find(:first, :conditions => {:permanent_id => rule_failure_permanent_id}, :order => 'id desc') - end - end - - def clean_violation_cache - @rule_failure=nil - end - - # - # - # REVIEW CORE METHODS - # - # - - # params of 'comment_values' are mandatory: - # - :user - # - :text - def create_comment(comment_values={}) - comment = comments.create!(comment_values) - touch - notification_manager.notifyChanged(id.to_i, comment.user.login.to_java, to_java_map, to_java_map("comment" => comment.text)) - end - - def edit_comment(current_user, comment_id, comment_text) - comment=comments.find(comment_id) - if comment - old_comment_text=comment.text - comment.text=comment_text - comment.save! - touch - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map("comment" => comment.text)) - end - end - - # TODO Godin: seems that this method not used anymore - def edit_last_comment(current_user, comment_text) - comment=comments.last - old_comment_text=comment.text - comment.text=comment_text - comment.save! - touch - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map("comment" => comment.text)) - end - - def delete_comment(current_user, comment_id) - comment=comments.find(comment_id) - comments.pop - if comment - old_comment_text=comment.text - comment.delete - touch - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map) - end - end - - def notification_manager - Java::OrgSonarServerUi::JRubyFacade.getInstance().getReviewsNotificationManager() - end - - def to_java_map(options = {}) - java.util.HashMap.new( - { - "project" => project.long_name.to_java, - "projectId" => project.id.to_s.to_java, - "resource" => resource.long_name.to_java, - "title" => title.to_java, - "creator" => user == nil ? nil : user.login.to_java, - "assignee" => assignee == nil ? nil : assignee.login.to_java, - "status" => status.to_java, - "resolution" => resolution.to_java, - "severity" => severity.to_java - }.merge(options)) - end - - def reassign(current_user, assignee, options={}) - if options[:text].present? - comments.create!(:user => current_user, :text => options[:text]) - end - old = self.to_java_map - self.assignee = assignee - self.save! - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) - end - - def reopen(current_user, options={}) - old = self.to_java_map - if options[:text].present? - comments.create!(:user => current_user, :text => options[:text]) - end - self.status = STATUS_REOPENED - self.resolution = nil - self.save! - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) - end - - def resolve(current_user, options={}) - old = self.to_java_map - if options[:text].present? - comments.create!(:user => current_user, :text => options[:text]) - end - self.status = STATUS_RESOLVED - self.resolution = RESOLUTION_FIXED - self.save! - notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) - end - - # Parameters: - # - :text - def set_false_positive(is_false_positive, user, options={}) - if violation.nil? - bad_request('This review does not relate to a violation') - end - violation.switched_off=is_false_positive - violation.save! - if options[:text].present? - comments.create!(:user => user, :text => options[:text]) - end - old = self.to_java_map - self.assignee = nil - self.status = is_false_positive ? STATUS_RESOLVED : STATUS_REOPENED - self.resolution = is_false_positive ? RESOLUTION_FALSE_POSITIVE : nil - self.save! - notification_manager.notifyChanged(id.to_i, user.login.to_java, old, to_java_map("comment" => options[:text])) - end - - def false_positive - resolution == RESOLUTION_FALSE_POSITIVE - end - - def can_change_false_positive_flag? - (status == STATUS_RESOLVED && resolution == RESOLUTION_FALSE_POSITIVE) || status == STATUS_OPEN || status == STATUS_REOPENED - end - - def set_severity(new_severity, user, options={}) - if options[:text].present? - comments.create!(:user => user, :text => options[:text]) - end - old = self.to_java_map - self.severity=new_severity - self.manual_severity=(new_severity!=violation.severity) - self.save! - notification_manager.notifyChanged(id.to_i, user.login.to_java, old, to_java_map("comment" => options[:text])) - end - - def link_to_action_plan(action_plan, user, options={}) - if options[:text].present? - comments.create!(:user => user, :text => options[:text]) - end - old = self.to_java_map - self.action_plans.clear - if action_plan - self.action_plans << action_plan - end - self.save! - notification_manager.notifyChanged(id.to_i, user.login.to_java, old, to_java_map("action_plans" => action_plan ? action_plan.name : '')) - end - - def resolved? - status == STATUS_RESOLVED - end - - def closed? - status == STATUS_CLOSED - end - - def reopened? - status == STATUS_REOPENED - end - - def open? - status == STATUS_OPEN - end - - def active? - status == STATUS_OPEN || status == STATUS_REOPENED - end - - def linked_to? (action_plan) - action_plans.include? action_plan - end - - def planned? - action_plans.size!=0 - end - - def assigned? - assignee_id != nil - end - - # used as long as we currently allow to link a review to only 1 action plan. - def action_plan - action_plans[0] - end - - # - # - # SEARCH METHODS - # - # - - def self.search(options={}) - conditions=[] - values={} - no_need_for_db_request = false - - if options['id'].present? - conditions << 'id=:id' - values[:id]=options['id'].to_i - elsif options['ids'].present? - ids=options['ids'].split(',') - conditions << 'id in (:ids)' - values[:ids]=ids.map { |id| id.to_i } - else - - # --- 'review_type' is deprecated since 2.9 --- - # Following code just for backward compatibility - review_type = options['review_type'] - if review_type - if review_type == RESOLUTION_FALSE_POSITIVE - conditions << "resolution='#{RESOLUTION_FALSE_POSITIVE}'" - else - conditions << "(resolution<>'#{RESOLUTION_FALSE_POSITIVE}' OR resolution IS NULL)" - end - end - # --- End of code for backward compatibility code --- - - # --- For UI - false_positives = options['false_positives'] - if false_positives == "only" - conditions << "resolution='#{RESOLUTION_FALSE_POSITIVE}'" - elsif false_positives == "without" - conditions << "(resolution<>'#{RESOLUTION_FALSE_POSITIVE}' OR resolution IS NULL)" - end - # --- End - - # --- For web-service - resolutions = options['resolutions'].split(',') if options['resolutions'] - if resolutions && resolutions.size>0 && !resolutions[0].blank? - conditions << 'resolution in (:resolutions)' - values[:resolutions] = resolutions - end - # --- End - - - projects=options['projects'].split(',') if options['projects'] - if projects && projects.size>0 && !projects[0].blank? - conditions << 'project_id in (:projects)' - projectIds = [] - projects.each do |project| - foundProject = Project.by_key(project) - projectIds << foundProject.id if foundProject - end - values[:projects]=projectIds - end - - resources=options['resources'].split(',') if options['resources'] - if resources && resources.size>0 && !resources[0].blank? - conditions << 'resource_id in (:resources)' - resourceIds = [] - resources.each do |resource| - foundResource = Project.by_key(resource) - resourceIds << foundResource.id if foundResource - end - values[:resources]=resourceIds - end - - statuses=options['statuses'].split(',') if options['statuses'] - if statuses && statuses.size>0 && !statuses[0].blank? - conditions << 'status in (:statuses)' - values[:statuses]=statuses - end - - severities=options['severities'].split(',') if options['severities'] - if severities && severities.size>0 && !severities[0].blank? - conditions << 'severity in (:severities)' - values[:severities]=severities - end - - authors=options['authors'].split(',') if options['authors'] - if authors && authors.size>0 && !authors[0].blank? - conditions << 'user_id in (:authors)' - values[:authors]=User.logins_to_ids(authors) - end - - assignees=options['assignees'].split(',') if options['assignees'] - if assignees - if assignees.size == 0 - # Unassigned reviews - conditions << 'assignee_id IS NULL' - else - # Assigned reviews - conditions << 'assignee_id in (:assignees)' - values[:assignees]=User.logins_to_ids(assignees) - end - end - - action_plan_id = options['action_plan_id'] - if action_plan_id - action_plan = ActionPlan.find action_plan_id.to_i, :include => 'reviews' - if action_plan && action_plan.reviews.size>0 - conditions << 'id in (:ids)' - values[:ids]=action_plan.reviews.map { |r| r.id } - else - # no action plan or action plan is empty => no need to look into the database - no_need_for_db_request = true - end - elsif options['unplanned'] - conditions << 'id not in (:ids)' - values[:ids]=find_by_sql('SELECT DISTINCT review_id as id from action_plans_reviews') - end - - from=options['from'] - if from - conditions << 'created_at >= :from' - values[:from] = from - end - - to=options['to'] - if from - conditions << 'created_at <= :to' - values[:to] = to - end - end - - sort_field=(options['sort'].blank? ? 'updated_at' : options['sort']) - asc=(options['asc'] ? 'ASC' : 'DESC') - sort_sql="reviews.#{sort_field} #{asc}" - sort_sql += ', reviews.updated_at DESC' unless sort_field=='updated_at' - - found_reviews = [] - found_reviews = Review.find(:all, :include => ['review_comments', 'project', 'assignee', 'resource', 'user'], :conditions => [conditions.join(' AND '), values], :order => sort_sql, :limit => options['limit']) unless no_need_for_db_request - found_reviews - end - - -# -# -# XML AND JSON UTILITY METHODS -# -# - - def self.reviews_to_xml(reviews, convert_markdown=false) - xml = Builder::XmlMarkup.new(:indent => 0) - xml.instruct! - xml.reviews do - reviews.each do |review| - review.to_xml(xml, convert_markdown) - end - end - end - - def to_xml(xml, convert_markdown=false) - xml.review do - xml.id(id.to_i) - xml.createdAt(Api::Utils.format_datetime(created_at)) - xml.updatedAt(Api::Utils.format_datetime(updated_at)) - xml.author(user.login) if user - xml.assignee(assignee.login) if assignee - xml.title(title) - xml.status(status) - xml.resolution(resolution) if resolution - xml.severity(severity) - xml.resource(resource.kee) if resource - xml.line(resource_line) if resource_line && resource_line>0 - xml.violationId(rule_failure_permanent_id) if rule_failure_permanent_id - xml.comments do - review_comments.each do |comment| - xml.comment do - xml.id(comment.id.to_i) - xml.author(comment.user.login) if comment.user - xml.updatedAt(Api::Utils.format_datetime(comment.updated_at)) - if convert_markdown - xml.text(comment.html_text) - else - xml.text(comment.plain_text) - end - end - end - end - end - end - - def self.reviews_to_json(reviews, convert_markdown=false) - JSON(reviews.collect { |review| review.to_json(convert_markdown) }) - end - - def to_json(convert_markdown=false) - json = {} - json['id'] = id.to_i - json['createdAt'] = Api::Utils.format_datetime(created_at) - json['updatedAt'] = Api::Utils.format_datetime(updated_at) - json['author'] = user.login if user - json['assignee'] = assignee.login if assignee - json['title'] = title if title - json['status'] = status - json['resolution'] = resolution if resolution - json['severity'] = severity - json['resource'] = resource.kee if resource - json['line'] = resource_line if resource_line && resource_line>0 - json['violationId'] = rule_failure_permanent_id if rule_failure_permanent_id - comments = [] - review_comments.each do |comment| - comment_map = { - 'id' => comment.id.to_i, - 'updatedAt' => Api::Utils.format_datetime(comment.updated_at), - 'text' => convert_markdown ? comment.html_text : comment.plain_text - } - comment_map['author'] = comment.user.login if comment.user - comments << comment_map - end - json['comments'] = comments - json - end - -# -# -# PRIVATE METHODS -# -# - private - - def assign_project - if self.project.nil? && self.resource - self.project=self.resource.root_project - end - end - - -end 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 deleted file mode 100644 index 5c264518143..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review_comment.rb +++ /dev/null @@ -1,51 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -class ReviewComment < ActiveRecord::Base - belongs_to :user - belongs_to :review - validates_presence_of :user => "can't be empty" - validate :comment_should_not_be_blank - - alias_attribute :text, :review_text - - def html_text - Api::Utils.markdown_to_html(review_text) - end - - def plain_text - Api::Utils.convert_string_to_unix_newlines(review_text) - end - - def excerpt - text = plain_text.gsub("\n", " ") - if text.size > 101 - text[0..100] + " ..." - else - text - end - end - - private - - def comment_should_not_be_blank - errors.add("Comment", " cannot be blank") if review_text.blank? - end - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb index 28d0b9ef08f..7b425f0cbe4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb @@ -33,7 +33,6 @@ class Rule < ActiveRecord::Base validates_presence_of :plugin_rule_key, :if => 'name.present?' has_many :rules_parameters, :inverse_of => :rule - has_many :rule_failures, :inverse_of => :rule has_many :active_rules, :inverse_of => :rule belongs_to :parent, :class_name => 'Rule', :foreign_key => 'parent_id' has_one :rule_note, :inverse_of => :rule @@ -193,21 +192,6 @@ class Rule < ActiveRecord::Base rule end - def create_violation!(resource, options={}) - line = options['line'] - checksum = nil - level = Sonar::RulePriority.id(options['severity']||Severity::MAJOR) - RuleFailure.create!( - :snapshot => resource.last_snapshot, - :rule => self, - :failure_level => level, - :message => options['message'], - :cost => (options['cost'] ? options['cost'].to_f : nil), - :switched_off => false, - :line => line, - :checksum => checksum) - end - def self.to_hash(java_rule) l10n_name = Internal.rules.ruleL10nName(java_rule) l10n_desc = Internal.rules.ruleL10nDescription(java_rule) 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 deleted file mode 100644 index 53d1d506cd8..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ /dev/null @@ -1,320 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2013 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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 -# License along with {library}; if not, write to the Free Software -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class RuleFailure < ActiveRecord::Base - - belongs_to :rule - belongs_to :snapshot - has_one :review, :primary_key => 'permanent_id', :foreign_key => 'rule_failure_permanent_id', :order => 'created_at' - after_save :update_permanent_id - validates_presence_of :rule, :snapshot - - # first line of message - def title - @title||= - begin - if message.blank? - rule.name - else - parts=Api::Utils.split_newlines(message) - parts.size==0 ? rule.name : parts[0] - end - end - end - - def plain_message - @plain_message ||= - begin - Api::Utils.convert_string_to_unix_newlines(message) - end - end - - def html_message - @html_message ||= - begin - message ? Api::Utils.split_newlines(ERB::Util.html_escape(message)).join('<br/>') : '' - end - end - - def severity - Sonar::RulePriority.to_s(failure_level) - end - - def resource - snapshot.resource - end - - def to_json(include_review=false, convert_markdown=false) - json = {} - json['id'] = id - json['message'] = plain_message if plain_message - json['line'] = line if line && line>=1 - json['priority'] = severity - json['switchedOff']=true if switched_off? - if created_at - json['createdAt'] = Api::Utils.format_datetime(created_at) - end - json['rule'] = { - :key => rule.key, - :name => rule.name - } - json['resource'] = { - :key => resource.key, - :name => resource.name, - :scope => resource.scope, - :qualifier => resource.qualifier, - :language => resource.language - } - json['review'] = review.to_json(convert_markdown) if include_review && review - json - end - - def to_xml(xml=Builder::XmlMarkup.new(:indent => 0), include_review=false, convert_markdown=false) - xml.violation do - xml.id(id) - xml.message(plain_message) if plain_message - xml.line(line) if line && line>=1 - xml.priority(severity) - xml.switchedOff(true) if switched_off? - if created_at - xml.createdAt(Api::Utils.format_datetime(created_at)) - end - xml.rule do - xml.key(rule.key) - xml.name(rule.name) - end - xml.resource do - xml.key(resource.key) - xml.name(resource.name) - xml.scope(resource.scope) - xml.qualifier(resource.qualifier) - xml.language(resource.language) - end - review.to_xml(xml, convert_markdown) if include_review && review - end - end - - def build_review(options={}) - if self.review.nil? - self.review=Review.new( - { - :status => Review::STATUS_OPEN, - :severity => severity, - :resource_line => line, - :resource => resource, - :title => title, - :rule => rule, - :manual_violation => false, - :manual_severity => false - }.merge(options)) - end - end - - def create_review!(options={}) - build_review(options) - self.review.save! - end - - # Options : - # - snapshot_id (integer) - # - resource_id (integer) - # - ancestor_resource_id (integer) - # - ancestor_snapshot (Snapshot) - # - created_after (datetime) - # - switched_off (boolean) - # - review_statuses (array of strings, can include nil) - # - review_assignee_id (integer, nil means no assignee) - # - severity - # - rule_id - # - planned (boolean) - # - # WARNING: association 'snapshot' is not loaded - # - def self.search(options={}) - conditions=[] - values=[] - includes=[:rule, {:review => :action_plans}] - - if options.has_key? :snapshot_id - conditions << 'rule_failures.snapshot_id = ?' - values << options[:snapshot_id].to_i - end - - if options.has_key? :resource_id - conditions << 'rule_failures.snapshot_id in (select id from snapshots where islast=? and status=? and project_id=?)' - values << true - values << 'P' - values << options[:resource_id].to_i - end - - if options.has_key? :ancestor_resource_id - ancestor = Snapshot.find(:first, :select => 'id,path', :conditions => {:islast => true, :status => 'P', :project_id => options[:ancestor_resource_id].to_i}) - options[:ancestor_snapshot]=ancestor - end - - if options.has_key? :ancestor_snapshot - ancestor_snapshot=options[:ancestor_snapshot] - if ancestor_snapshot - conditions << 'rule_failures.snapshot_id in (select id from snapshots where islast=? and status=? and (id=? or (root_snapshot_id=? and path like ?)))' - values << true - values << 'P' - values << ancestor_snapshot.id - values << ancestor_snapshot.id - values << "#{ancestor_snapshot.path}#{ancestor_snapshot.id}.%" - else - return [] - end - end - - if options.has_key? :rule_id - conditions << 'rule_failures.rule_id=?' - values << options[:rule_id].to_i - end - - if options.has_key? :created_after - conditions << 'rule_failures.created_at>?' - values << options[:created_after] - end - - if options[:switched_off] - conditions << 'rule_failures.switched_off=?' - values << true - else - conditions << '(rule_failures.switched_off is null or rule_failures.switched_off = ?)' - values << false - end - - if options.has_key? :review_statuses - statuses = options[:review_statuses] - unless statuses.empty? - if statuses.include? nil - if statuses.size==1 - # only nil : unreviewed violations - conditions << 'not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id)' - else - conditions << '(reviews.status in (?) or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id))' - values << options[:review_statuses].compact - end - else - conditions << 'reviews.status in (?)' - values << options[:review_statuses] - end - end - end - - if options.has_key? :review_assignee_id - review_assignee_id = options[:review_assignee_id] - if review_assignee_id - conditions << 'reviews.assignee_id=?' - values << review_assignee_id.to_i - else - conditions << '(reviews.assignee_id is null or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id))' - end - end - - if options.has_key? :severity - conditions << 'failure_level=?' - values << Sonar::RulePriority.id(options[:severity]) - end - - result = find(:all, :include => includes, :conditions => [conditions.join(' and ')] + values, :order => 'rule_failures.failure_level DESC') - - if options.has_key? :planned - # this condition can not be implemented with SQL - if options[:planned] - result = result.select { |violation| violation.review && violation.review.planned? } - else - result = result.reject { |violation| violation.review && violation.review.planned? } - end - end - - result - end - - - # - # Constraint : all the violations are in the same project - # - def self.available_java_screens_for_violations(violations, resource, user) - reviews = violations.map { |violation| to_java_workflow_review(violation) } - context = to_java_workflow_context(resource, user) - Java::OrgSonarServerUi::JRubyFacade.getInstance().listAvailableReviewsScreens(reviews, context) - end - - def available_java_screens(user) - if user - review = RuleFailure.to_java_workflow_review(self) - context = RuleFailure.to_java_workflow_context(snapshot.root_snapshot.project, user) - Java::OrgSonarServerUi::JRubyFacade.getInstance().listAvailableReviewScreens(review, context) - else - [] - end - end - - def self.execute_command(command_key, violation, user, parameters) - review = to_java_workflow_review(violation) - context = to_java_workflow_context(violation.resource, user) - Java::OrgSonarServerUi::JRubyFacade.getInstance().executeReviewCommand(command_key, review, context, parameters) - end - - def self.to_java_workflow_review(violation) - java_review=Java::OrgSonarApiWorkflowInternal::DefaultReview.new - java_review.setViolationId(violation.id) - java_review.setSeverity(violation.severity.to_s) - java_review.setRuleKey(violation.rule.plugin_rule_key) - java_review.setRuleRepositoryKey(violation.rule.repository_key) - java_review.setRuleName(violation.rule.name(false)) # rule name is not localized - java_review.setSwitchedOff(violation.switched_off||false) - java_review.setMessage(violation.message) - java_review.setLine(violation.line) - - review = violation.review - if review - java_review.setReviewId(review.id) - java_review.setStatus(review.status) - java_review.setResolution(review.resolution) - java_review.setManual(review.manual_violation) - java_review.setPropertiesAsString(review.data) - else - java_review.setStatus(Review::STATUS_IDLE) - end - java_review - end - - def self.to_java_workflow_context(resource, user) - java_context = Java::OrgSonarApiWorkflowInternal::DefaultWorkflowContext.new - java_context.setUserId(user.id) - java_context.setUserLogin(user.login) - java_context.setUserName(user.name) - java_context.setUserEmail(user.email) - java_context.setIsAdmin(user.has_role?(:admin)) - java_context.setProjectId(resource.root_project.id) - java_context - end - - private - def update_permanent_id - if self.permanent_id.nil? && self.id - self.permanent_id = self.id - save! - end - end - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index ec55b8a46d2..e76d74c54ee 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -34,7 +34,6 @@ class Snapshot < ActiveRecord::Base has_many :events, :dependent => :destroy, :order => 'event_date DESC' has_one :source, :class_name => 'SnapshotSource', :dependent => :destroy - has_many :violations, :class_name => 'RuleFailure' STATUS_UNPROCESSED = 'U' STATUS_PROCESSED = 'P' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity.html.erb index f03b06a1c01..4da1108d975 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity.html.erb @@ -2,7 +2,7 @@ <tr class="<%= css -%> <%= 'selected' if selected -%>"> <td><%= image_tag "priority/#{severity}.png" %></td> <td> - <%= link_to message("severity.#{severity}"), {:controller => :drilldown, :action => :violations, :id => @resource.id, :severity => (selected ? nil : severity), :period => @period} %> + <%= link_to message("severity.#{severity}"), {:controller => :drilldown, :action => :issues, :id => @resource.id, :severity => (selected ? nil : severity), :period => @period} %> </td> <td style="padding-left: 10px;" align="right" nowrap> <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity_issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity_issues.html.erb deleted file mode 100644 index 4da1108d975..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_severity_issues.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% selected=(severity==@severity) %> -<tr class="<%= css -%> <%= 'selected' if selected -%>"> - <td><%= image_tag "priority/#{severity}.png" %></td> - <td> - <%= link_to message("severity.#{severity}"), {:controller => :drilldown, :action => :issues, :id => @resource.id, :severity => (selected ? nil : severity), :period => @period} %> - </td> - <td style="padding-left: 10px;" align="right" nowrap> - <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%> - </td> - <td align="left"> - <% value = measure_or_variation_value(measure) %> - <%= barchart(:width => 60, :percent => (value ? (100 * value / max).to_i : 0), :color => (@period_index ? '#cc0000' : '#777')) if max>0 %> - </td> -</tr>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb index 5409d9914ce..aa7881ed58c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb @@ -27,17 +27,17 @@ value_column = (@period ? "variation_value_#{@period}" : 'value') max = 0 if @period - blocker_issues=@snapshot.measure('new_blocker_issues') - critical_issues=@snapshot.measure('new_critical_issues') - major_issues=@snapshot.measure('new_major_issues') - minor_issues=@snapshot.measure('new_minor_issues') - info_issues=@snapshot.measure('new_info_issues') + blocker_issues=@snapshot.measure('new_blocker_violations') + critical_issues=@snapshot.measure('new_critical_violations') + major_issues=@snapshot.measure('new_major_violations') + minor_issues=@snapshot.measure('new_minor_violations') + info_issues=@snapshot.measure('new_info_violations') else - blocker_issues=@snapshot.measure('blocker_issues') - critical_issues=@snapshot.measure('critical_issues') - major_issues=@snapshot.measure('major_issues') - minor_issues=@snapshot.measure('minor_issues') - info_issues=@snapshot.measure('info_issues') + blocker_issues=@snapshot.measure('blocker_violations') + critical_issues=@snapshot.measure('critical_violations') + major_issues=@snapshot.measure('major_violations') + minor_issues=@snapshot.measure('minor_violations') + info_issues=@snapshot.measure('info_violations') end [blocker_issues, critical_issues, major_issues, minor_issues, info_issues].each do |m| @@ -47,11 +47,11 @@ %> <h3><%= message('issues_drilldown.col.severity') -%></h3> <table class="spacedicon" style="border: 1px solid #ccc;"> - <%= render :partial => 'severity_issues', :locals => {:css => 'even', :severity => 'BLOCKER', :max => max, :measure => blocker_issues} %> - <%= render :partial => 'severity_issues', :locals => {:css => 'odd', :severity => 'CRITICAL', :max => max, :measure => critical_issues} %> - <%= render :partial => 'severity_issues', :locals => {:css => 'even', :severity => 'MAJOR', :max => max, :measure => major_issues} %> - <%= render :partial => 'severity_issues', :locals => {:css => 'odd', :severity => 'MINOR', :max => max, :measure => minor_issues} %> - <%= render :partial => 'severity_issues', :locals => {:css => 'even', :severity => 'INFO', :max => max, :measure => info_issues} %> + <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'BLOCKER', :max => max, :measure => blocker_issues} %> + <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'CRITICAL', :max => max, :measure => critical_issues} %> + <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'MAJOR', :max => max, :measure => major_issues} %> + <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'MINOR', :max => max, :measure => minor_issues} %> + <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'INFO', :max => max, :measure => info_issues} %> </table> </td> <td align="left" style="white-space: normal;" valign="top"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb deleted file mode 100644 index 636d3d73fca..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb +++ /dev/null @@ -1,186 +0,0 @@ -<%= render :partial => 'header' -%> - -<div class="line-block"> - <div id="snapshot_title" class="page_title"> - <h4> - <% - profile_measure=@snapshot.measure(Metric::PROFILE) - %> - <% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> - <% end %> - <% if @snapshot.project_snapshot.periods? %> - <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left"> - <%= dropdown_tag "period", period_select_option_tags(@snapshot, 'small'), { - :width => '200px', - }, {:id => 'select-comparison', :onchange => 'submit()'} -%> - </form> - <% end %> - </h4> - </div> -</div> - -<table class="width100 spacer-bottom" cellpadding="0" cellspacing="0" id="columns"> - <tr> - <td align="left" width="1%" nowrap class="spacer-right" valign="top"> - - <% - value_column = (@period ? "variation_value_#{@period}" : 'value') - max = 0 - if @period - blocker_violations=@snapshot.measure('new_blocker_violations') - critical_violations=@snapshot.measure('new_critical_violations') - major_violations=@snapshot.measure('new_major_violations') - minor_violations=@snapshot.measure('new_minor_violations') - info_violations=@snapshot.measure('new_info_violations') - else - blocker_violations=@snapshot.measure('blocker_violations') - critical_violations=@snapshot.measure('critical_violations') - major_violations=@snapshot.measure('major_violations') - minor_violations=@snapshot.measure('minor_violations') - info_violations=@snapshot.measure('info_violations') - end - - [blocker_violations, critical_violations, major_violations, minor_violations, info_violations].each do |m| - value = measure_or_variation_value(m) - max = value if value && value>max - end - %> - <h3><%= message('violations_drilldown.col.severity') -%></h3> - <table class="spacedicon" style="border: 1px solid #ccc;"> - <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'BLOCKER', :max => max, :measure => blocker_violations} %> - <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'CRITICAL', :max => max, :measure => critical_violations} %> - <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'MAJOR', :max => max, :measure => major_violations} %> - <%= render :partial => 'severity', :locals => {:css => 'odd', :severity => 'MINOR', :max => max, :measure => minor_violations} %> - <%= render :partial => 'severity', :locals => {:css => 'even', :severity => 'INFO', :max => max, :measure => info_violations} %> - </table> - </td> - <td align="left" style="white-space: normal;" valign="top"> - <h3><%= message('violations_drilldown.col.rule') -%></h3> - - <div class="scrollable"> - <table class="spacedicon" width="100%" id="col_rules"> - <% - max=0 - rule_index=0 - already_selected=false - @rule_measures.each do |m| - value = m.send(value_column) if m - max=value if value && value>max - end - @rule_measures.sort do |x, y| - val=y.rule_priority<=>x.rule_priority - if val==0 - x_value=x.send(value_column) - y_value=y.send(value_column) - y_value <=> x_value - else - val - end - end.each do |rule_measure| - value = rule_measure.send(value_column) - next if value.nil? || value==0 - rule=rule_measure.rule - clazz = cycle('even', 'odd', :name => 'rules') - selected = !already_selected && @rule && @rule.id==rule_measure.rule_id && (@rule_severity.nil? || @rule_severity==rule_measure.severity) - already_selected = true if selected - clazz = clazz + ' selected' if selected - rule_index+=1 - %> - <tr class="<%= clazz -%>"> - <td width="1%" nowrap> - <a id="<%= "rule#{rule_index}" -%>" title="<%= message('violations_drilldown.click_for_more_on_x', :params => [rule.plugin_name, rule.plugin_rule_key]) -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png"/></a> - </td> - <td> - <%= link_to(rule.name, {:controller => :drilldown, :action => :violations, :id => @resource.id, :rule => (selected ? nil : rule.key), :rule_sev => (selected ? nil : rule_measure.severity), :sid => nil, :severity => @severity, :period => @period, :rids => (selected ? nil : @selected_rids)}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") -%> - </td> - <td class="right" nowrap="nowrap"> - <span><%= @period ? format_variation(rule_measure, :period => @period, :style => 'light') : rule_measure.formatted_value -%></span> - </td> - <td class="left last"> - <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => (@period ? '#cc0000' : '#777')) if max>0 %> - </td> - </tr> - <% end %> - - <% if rule_index==0 %> - <tr class="even"> - <td><%= message('violations_drilldown.no_violations') -%></td> - </tr> - <% end %> - </table> - </div> - </td> - </tr> -</table> -<% - paths=[] - rids=[] - first_column=true - @drilldown.columns.each_with_index do |column, index| -%> - <% if first_column %> - <table class="spacer-bottom" style="width: 100%"> - <tr> - <% end %> - <td class="<%= 'spacer-left' unless first_column -%>" nowrap> - <div class="scrollable" id="col_<%= index -%>"> - <table class="spaced"> - <% - column.measures.each_with_index do |measure, row_index| - resource=column.resource(measure) - clazz = cycle('even', 'odd', :name => "col_#{index}") - selected = column.selected_snapshot && column.selected_snapshot.project_id==resource.id - if selected - clazz += ' selected' - paths << [h(resource.name), @selected_rids-[resource.id]] - end - %> - <tr class="<%= clazz -%>" id="row_<%= index -%>_<%= row_index -%>"> - <td nowrap> - <% if resource.source_code? %> - <a href="<%= url_for :controller => 'resource', :action => 'index', :id => resource.key, :period => params[:period], :metric => @metric ? @metric.id : nil, :rule => @rule ? @rule.id : @severity, :display_title => 'true' -%>" - onclick="window.open(this.href,'resource-<%= resource.key.parameterize -%>','height=800,width=900,scrollbars=1,resizable=1');return false;" - id="popup-<%= resource.key.parameterize -%>" - target="_blank"><%= image_tag 'new-window-16.gif', :alt => message('new_window') -%></a> - <% else %> - <%= link_to(image_tag('zoom.png'), {:id => resource.id}, {:class => 'nolink'}) %> - <% end %> - <%= qualifier_icon(resource) -%> - <% if resource.source_code? %> - <a href="#" onclick="$j('#col_<%= index -%> tr').removeClass('selected'); $j('#row_<%= index -%>_<%= row_index -%>').addClass('selected'); d(<%= resource.id -%>);" - alt="<%= h resource.name(true) -%>" title="<%= h resource.name(true) -%>"><%= h resource.name(false) %></a> - <% else %> - <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}) -%> - <% end %> - </td> - <td class="right" nowrap> - <%= @period ? format_variation(measure, :period => @period, :style => 'light') : measure.formatted_value -%> - </td> - </tr> - <% end %> - </table> - </div> - </td> - <% if column.switch? || index==@drilldown.columns.size-1 %> - </tr> - </table> - <% end - first_column = column.switch? - rids<<column.selected_snapshot.project_id if column.selected_snapshot - end - %> - -<script> - $$('#col_rules tr.selected').each(function (item) { - item.scrollIntoView(true); - }); - <% for i in 0...@drilldown.columns.size do %> - $$('#col_<%= i -%> tr.selected').each(function (item) { - item.scrollIntoView(true); - }); - <% end %> -</script> - -<div id="accordion-panel"/> - -<%= render :partial => 'footer' -%>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_new.html.erb deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_new.html.erb +++ /dev/null diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_progress.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_progress.html.erb deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_progress.html.erb +++ /dev/null diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb +++ /dev/null diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb index 27702b255cb..c618d86d29b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb @@ -1,6 +1,6 @@ <% displayed_resource = @resource || @project - display_only_root = @review || @issue + display_only_root = @issue %> <% if @breadcrumbs %> @@ -83,15 +83,6 @@ end end - # ======== Path for review ======== - if @review - %> - <li> - <%= link_to message('review') + ' #' + @review.id.to_s -%> - </li> - <% - end - # ======== Path for issue ======== if @issue %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 894240b78f2..86551503673 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -19,9 +19,6 @@ <a href="<%= ApplicationController.root_context -%>/measures"><%= message('layout.measures') -%></a> </li> <li> - <a href="<%= ApplicationController.root_context -%>/reviews/index"><%= message('reviews.page') -%></a> - </li> - <li> <a href="<%= ApplicationController.root_context -%>/issues/index"><%= message('issues.page') -%></a> </li> </ul> @@ -82,9 +79,6 @@ <li class="<%= 'active' if request.request_uri.include?('/components/index') -%>"> <a href="<%= ApplicationController.root_context -%>/components/index/<%= @project.id -%>"><%= message('components.page') -%></a> </li> - <li class="<%= 'active' if request.request_uri.include?('/drilldown/violations') -%>"> - <a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%><%= "?"+period_param if period_param -%>"><%= message('violations_drilldown.page') -%></a> - </li> <li class="<%= 'active' if request.request_uri.include?('/drilldown/issues') -%>"> <a href="<%= ApplicationController.root_context -%>/drilldown/issues/<%= @project.id -%><%= "?"+period_param if period_param -%>"><%= message('issues_drilldown.page') -%></a> </li> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb deleted file mode 100644 index 397fc5da372..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<% if @action_plans.empty? %> - - <span class="error"><%= message('reviews.an_action_plan_must_be_created_first') -%></span> - - <%= link_to_remote message('reviews.hide_this_message'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> - -<% else %> - -<form method="POST"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - - <%= message('reviews.action_plan_label') -%>: - <select name="action_plan_id" id="selectActionPlan"> - <% @action_plans.each do |plan| %> - <option value="<%= plan.id -%>" <%= 'selected' if @review.linked_to?(plan) -%>><%= h(plan.name) -%></option> - <% end %> - </select> - - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - <%= submit_to_remote "submit_btn", message('reviews.action_plan_submit'), :url => {:action => 'link_to_action_plan'}, :html => {:id => "submit_btn"}, :update => 'review' -%> - - - <% if @review.planned? %> - - <%= submit_to_remote "submit_btn", message('reviews.unlink_action_plan_submit'), :url => {:action => 'unlink_from_action_plan'}, :html => {:id => "submit_btn"}, :update => 'review' -%> - <% end %> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> -</form> - -<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_assign_form.html.erb deleted file mode 100644 index 67a66a1c78c..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_assign_form.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -<% - assignee_check_script = "if ($('autocompleteText-assignee_login').value != '' && $('assignee_login').value == '') { alert($('autocompleteText-assignee_login').value + '" + message('reviews.user_does_not_exist') + "'); return false;}" -%> - -<form method="post" - onsubmit="<%= assignee_check_script -%> new Ajax.Updater('review', '<%= url_for :action => 'assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> - <%= hidden_field_tag :id, params[:id] -%> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <%= user_autocomplete_field "assignee_login", "" -%> - <%= submit_to_remote "submit_btn", message('reviews.assign_submit'), - :url => {:action => 'assign'}, - :update => "review", - :before => assignee_check_script -%> - - <%= image_tag 'sep12.png' -%> - - <%= button_to_remote message('reviews.assign_to_me_submit'), - { - :url => {:action => 'assign', :id => params[:id], :me => true}, - :update => "review" - }, - :disabled => (@review.assignee_id==current_user.id) -%> - - - <%= link_to_remote message('cancel'), - :url => {:action => 'show', :id => params[:id]}, - :update => "review" %> - <script> - $('autocompleteText-assignee_login').focus(); - </script> -</form>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_severity_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_severity_form.html.erb deleted file mode 100644 index 12c378d1b1b..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_severity_form.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<form method="POST"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - - <%= message('reviews.new_severity_label') -%> - <select name="severity" class="withIcons" id="selectSeverity"> - <% Severity::KEYS.each do |severity| %> - <option class="sev_<%= severity -%>" value="<%= severity -%>" <%= 'selected' if severity==Severity::MAJOR -%>><%= message("severity.#{severity}") -%></option> - <% end %> - </select> - - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - <%= submit_to_remote "submit_btn", message('reviews.change_severity_submit'), :url => {:action => 'change_severity'}, :html => {:id => "submit_btn"}, :update => 'review' -%> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_status_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_status_form.html.erb deleted file mode 100644 index 5f988c028dc..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_change_status_form.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<form method="POST"> - <input type="hidden" name="id" value="<%= @review.id -%>"/> - - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - <%= submit_to_remote "submit_btn", - message(@review.resolved? ? 'reviews.reopen_submit' : 'reviews.resolved_submit'), - :url => {:action => 'change_status'}, - :html => {:id => "submit_btn"}, - :update => 'review' -%> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_comment_form.html.erb deleted file mode 100644 index aeafb78549d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_comment_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<% - button=(@comment ? message('reviews.update_comment_submit') : message('reviews.comment_submit')) -%> -<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="4" name="text" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"><%= @comment.text if @comment -%></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <%= submit_to_remote "submit_btn", button, :url => {:action => 'save_comment'}, :html => {:id => "submit_btn", :disabled => "true"}, :update => 'review' -%> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_false_positive_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_false_positive_form.html.erb deleted file mode 100644 index 0fa542e5a95..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_false_positive_form.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<% - if @review.violation.switched_off? - title = message('reviews.why_not_false_positive') - button = message('reviews.unflag_as_false_positive') - else - title = message('reviews.why_false_positive') - button = message('reviews.flag_as_false_positive') - end -%> -<form method="POST"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - <input type="hidden" name="false_positive" value="<%= @review.violation.switched_off? ? 'false' : 'true' -%>"/> - - <h3><%= title -%></h3> - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - <%= submit_to_remote "submit_btn", button, :url => {:action => 'flag_as_false_positive'}, :html => {:id => "submit_btn"}, :update => 'review' -%> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb deleted file mode 100644 index cb87490a9f9..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb +++ /dev/null @@ -1,222 +0,0 @@ -<div id="rev_<%= @review.id -%>"> - <div class="reviewTitle"> - <h2><%= message('reviews.review_number', :params => h(@review.id.to_s)) -%> - <%= h(@review.title) -%></h2> - </div> - - <% if defined?(error_message) && error_message %> - <div id="review_error" class="error"><%= h error_message -%> <a href="#" onclick="$('review_error').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div> - <% end %> - - <% - if current_user && !@review.closed? && @review.rule_failure - violation_switched_off = @review.rule_failure.switched_off? - %> - <div class="marginbottom10" id="actionButtons"> - <% unless @review.resolved? %> - <%= button_to_remote message('reviews.assign'), - :url => {:controller => "project_reviews", :action => "assign_form", :id => @review.id}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();" -%> - - <% end %> - - <% - if !violation_switched_off - %> - <%= button_to_remote (@review.resolved? ? message('reviews.reopen') : message('reviews.resolved')), - :url => {:controller => "project_reviews", :action => "change_status_form", :id => @review.id}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();$('actionText').focus();" -%> - - - <% end %> - <% if @review.can_change_false_positive_flag? %> - <%= button_to_remote (violation_switched_off ? message('reviews.unflag_as_false_positive') : message('reviews.flag_as_false_positive')), - :url => {:controller => "project_reviews", :action => "false_positive_form", :id => @review.id, :false_positive => !violation_switched_off}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();$('actionText').focus();" -%> - <% end %> - - <% unless @review.resolved? %> - <%= button_to_remote message('reviews.change_severity'), - :url => {:controller => "project_reviews", :action => "change_severity_form", :id => @review.id}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%> - - <%= button_to_remote message('reviews.link_to_action_plan'), - :url => {:controller => "project_reviews", :action => "action_plan_form", :id => @review.id}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%> - <% - end - %> - <% - if @review.violation - screens = @review.violation.available_java_screens(current_user) - screens.each do |screen| - %> - <%= button_to_remote message("reviews.command.#{screen.getCommandKey()}.button"), - :url => {:controller => "project_reviews", :action => "screen", :id => @review.id, :command => screen.getCommandKey()}, - :update => "actionForm", - :complete => "$('actionButtons').remove();$('actionForm').show();$('actionText').focus();" -%> - <% - end - end - %> - </div> - <% end %> - - <div class="discussionComment" id="actionForm" style="border: 1px solid #DDD;display:none"></div> - - <table class="reviewDetails marginbottom10"> - <tr> - <td class="key"> - <%= message('status') -%>: - </td> - <td class="val"> - <%= image_tag "status/#{@review.status}.png" -%> <span class="reviewStatus<%= @review.status -%>"><%= message("reviews.status.#{@review.status}") -%></span> - <% if @review.resolution.present? %> - (<span class="reviewResolution<%= @review.resolution -%>"><%= message("reviews.resolution.#{@review.resolution}") -%></span>) - <% end %> - </td> - <td class="key"> - <%= message('severity') -%>: - </td> - <td class="val"> - <%= image_tag "priority/#{@review.severity}.png" -%> <%= message("severity.#{@review.severity}") -%> - </td> - </tr> - <tr> - <td class="key"> - <%= message('assignee') -%>: - </td> - <td class="val"> - <%= @review.assignee ? h(@review.assignee.name) : '-' -%> - </td> - <td class="key"> - <%= message('author') -%>: - </td> - <td class="val"> - <%= @review.user ? h(@review.user.name) : '-' -%> - </td> - </tr> - <tr> - <td class="key"> - <%= message('created') -%>: - </td> - <td class="val"> - <%= l(@review.created_at) -%> - </td> - <td class="key"> - <%= message('updated') -%>: - </td> - <td class="val"> - <%= l(@review.updated_at) -%> - </td> - </tr> - <% if @review.planned? %> - <tr> - <td class="key"> - <%= message('reviews.planned_for_label') -%>: - </td> - <td class="val" colspan="3"> - <%= h(@review.action_plan.name) -%> - </td> - </tr> - <% end %> - <% if @review.rule %> - <tr> - <td class="key"> - <%= message('rule') -%>: - </td> - <td class="val" colspan="3"> - <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => @review.rule.key, :layout => 'false' -%>"><%= h(@review.rule.name) -%></a> - </td> - </tr> - <% end %> - <tr> - <td class="key"> - <%= message('file') -%>: - </td> - <td class="val" colspan="3"> - <%= qualifier_icon(@review.resource) -%> - <% if !@review.on_project? %> <%= @review.project.long_name -%> <%= image_tag 'sep12.png' -%> - <% end %> - <% if @review.rule_failure && @review.rule_failure.snapshot %> - <%= link_to_resource(@review.resource, @review.resource.long_name, {:tab => :violations, :rule => @review.false_positive ? "false_positive_reviews" : ""}) %> - <% else %> - <%= @review.resource.long_name -%> - <% end %> - </td> - </tr> - </table> - - <% if @review.rule_failure && @review.resource_line && @review.rule_failure.snapshot && has_role?(:codeviewer, @review.project) %> - <div class="marginbottom10"> - <%= snapshot_html_source(@review.rule_failure.snapshot, {:line_range => (@review.resource_line-5)..(@review.resource_line+5), :highlighted_lines => [@review.resource_line]}) -%> - </div> - <% end %> - - <% if @review.rule_failure || !@review.comments.empty? %> - <div class="discussion marginbottom10"> - <% if @review.rule_failure %> - <div class="discussionComment first"> - <%= h(@review.rule_failure.message) -%> - </div> - <% end %> - <% - @review.comments.each_with_index do |comment, comment_index| - is_last_comment=(comment_index==@review.comments.size-1) - %> - <div class="discussionComment"> - <h4> - <%= image_tag("reviews/comment.png") -%> <b><%= comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(comment.created_at) -%>) - <% if is_last_comment && current_user && !@review.closed? %> - <span class="actions" id="editActions"> - - <%= image_tag("sep12.png") -%> - - <% - if current_user.id == comment.user_id - %> - <%= link_to_remote message('edit'), - :url => {:controller => "project_reviews", :action => "comment_form", :comment_id => comment.id, :id => @review.id}, - :update => "lastComment", - :complete => "$('commentAction').remove();$('editActions').hide();$('commentText').focus();", - :html => {:class => 'link-action'} -%> - - <%= link_to_remote message('delete'), - :url => {:controller => "project_reviews", :action => "delete_comment", :comment_id => comment.id, :id => @review.id}, - :update => "review", - :confirm => message('reviews.do_you_want_to_delete_comment'), - :html => {:class => 'link-action'} -%> - <% - end - %> - </span> - <% end %> - </h4> - <% if is_last_comment %> - <div id="lastComment"> - <%= comment.html_text -%> - </div> - <% else %> - <%= comment.html_text -%> - <% end %> - </div> - <% end %> - </div> - <% end %> - - <% if current_user && !@review.closed? %> - <%= button_to_remote message('reviews.comment'), - { - :url => {:controller => "project_reviews", :action => "comment_form", :id => @review.id}, - :update => "commentForm", - :complete => "$('commentAction').remove();$('commentForm').show();$('commentText').focus();" - }, - :id => 'commentAction' -%> - - <div class="discussionComment" id="commentForm" style="border: 1px solid #DDD;display:none"></div> - <% end %> -</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb deleted file mode 100644 index b274fc3672f..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_view.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<div id="review"> - <% - # hack in case 'error_message' is nil (this should disappear when refactoring the '_view' and '_review' partials) - error_message = error_message - %> - <%= render :partial => 'project_reviews/review', :locals => {:workflow => @review, :error_message => error_message} -%> -</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/index.html.erb deleted file mode 100644 index 0b3d3f249ba..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/index.html.erb +++ /dev/null @@ -1,74 +0,0 @@ -<% content_for :script do %> - <script> - - function launchSearch(columnName) { - var urlParts = document.URL.split('?'); - - var url = urlParts.shift() + '?'; - - if (urlParts[0]) { - urlParts[0].split('&').forEach( function(s) { - if (s != '' & s.indexOf('asc=') == -1 && s.indexOf('sort=') == -1 ) { - url += '&' + s; - } - }); - - if (url.indexOf('?') > 0) { - url += '&sort=' + columnName; - } else { - url += '?sort=' + columnName; - } - - if (document.URL.indexOf('&asc=true') == -1) { - url += '&asc=true'; - } - } - - window.location = url; - } - </script> -<% end %> - -<div style="font-size: 85%; margin-bottom: 10px"> -» <a href="#" onclick="javascript:history.back(-1);return false;"><%= message('back') -%></a> -</div> - -<div id="reviews-search"> - <h1><%= message('reviews') -%></h1> - - <input type="hidden" name="asc" id="asc" value="<%= params[:asc] ? params[:asc] : 'true' -%>"/> - - <div class="review-filters"> - <%= message('reviews.filtered_by') -%>: - <% if params[:statuses] %> - <%= review_filter_tag 'statuses', params -%> - <% end %> - <% if params[:resolutions] %> - <%= review_filter_tag 'resolutions', params -%> - <% end %> - <% if params[:severities] %> - <%= review_filter_tag 'severities', params -%> - <% end %> - <% if params[:authors] %> - <%= review_filter_tag 'authors', params -%> - <% end %> - <% if params[:assignees] %> - <%= review_filter_tag 'assignees', params, {:title => params[:assignees].size()==0 ? message('none') : params[:assignees]} -%> - <% end %> - <% if params[:action_plan_id] %> - <%= review_filter_tag 'action_plan_id', params, {:title => ActionPlan.find(params[:action_plan_id]).name} -%> - <% end %> - <% if params[:unplanned] %> - <%= review_filter_tag 'unplanned', params -%> - <% end %> - <% if params[:from] %> - <%= review_filter_tag 'from', params, {:title => l(DateTime.parse(params[:from]))} -%> - <% end %> - <% if params[:to] %> - <%= review_filter_tag 'to', params, {:title => l(DateTime.parse(params[:to]))} -%> - <% end %> - </div> - - <%= render :partial => "reviews/list" -%> - -</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/screens/_comment.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/screens/_comment.html.erb deleted file mode 100644 index f363b4f11ca..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/screens/_comment.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<form method="POST"> - <input type="hidden" name="id" value="<%= @review.id -%>"/> - <input type="hidden" name="command" value="<%= @screen.getCommandKey() -%>"/> - - <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea> - <%= submit_to_remote "submit_btn", - message("reviews.command.#{@screen.getCommandKey()}.submit"), - :url => {:action => 'execute'}, - :html => {:id => "submit_btn"}, - :before => "$('loading').show();", - :update => 'review' -%> - - <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => @review.id}, :update => 'review' -%> - - <span id="loading" style="display: none;"><%= image_tag 'loading.gif' -%></span> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_issues.html.erb index 28b68d2b06a..3165fd0d280 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_issues.html.erb @@ -2,64 +2,64 @@ <% if @period && measure('new_issues') %> <table> <tr> - <td><span class="big"><%= format_variation('new_issues', :default => 0, :period => @period, :style => 'none') -%></span> <%= message('new_issues').downcase -%></td> + <td><span class="big"><%= format_variation('new_violations', :default => 0, :period => @period, :style => 'none') -%></span> <%= message('new_issues').downcase -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/BLOCKER.png' -%></td> <td class="name"><%= message('blocker') -%>:</td> - <td class="value"><%= format_variation('new_blocker_issues', :default => 0, :period => @period, :style => 'none') -%></td> + <td class="value"><%= format_variation('new_blocker_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/CRITICAL.png' -%></td> <td class="name"><%= message('critical') -%>:</td> - <td class="value"><%= format_variation('new_critical_issues', :default => 0, :period => @period, :style => 'none') -%></td> + <td class="value"><%= format_variation('new_critical_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MAJOR.png' -%></td> <td class="name"><%= message('major') -%>:</td> - <td class="value"><%= format_variation('new_major_issues', :default => 0, :period => @period, :style => 'none') -%></td> + <td class="value"><%= format_variation('new_major_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MINOR.png' -%></td> <td class="name"><%= message('minor') -%>:</td> - <td class="value"><%= format_variation('new_minor_issues', :default => 0, :period => @period, :style => 'none') -%></td> + <td class="value"><%= format_variation('new_minor_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/INFO.png' -%></td> <td class="name"><%= message('info') -%>:</td> - <td class="value"><%= format_variation('new_info_issues', :default => 0, :period => @period, :style => 'none') -%></td> + <td class="value"><%= format_variation('new_info_violations', :default => 0, :period => @period, :style => 'none') -%></td> </tr> </table> <% else %> <table class="sourceHeader"> <tr> - <td nowrap><span class="big"><%= format_measure('issues', :default => 0) -%></span> <%= message('issues').downcase -%></td> + <td nowrap><span class="big"><%= format_measure('violations', :default => 0) -%></span> <%= message('issues').downcase -%></td> <td class="sep"> </td> <td nowrap><%= image_tag 'priority/BLOCKER.png' -%></td> <td class="name"><%= message('blocker') -%>:</td> - <td class="value"><%= format_measure('blocker_issues', :default => 0) -%></td> + <td class="value"><%= format_measure('blocker_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/CRITICAL.png' -%></td> <td class="name"><%= message('critical') -%>:</td> - <td class="value"><%= format_measure('critical_issues', :default => 0) -%></td> + <td class="value"><%= format_measure('critical_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MAJOR.png' -%></td> <td class="name"><%= message('major') -%>:</td> - <td class="value"><%= format_measure('major_issues', :default => 0) -%></td> + <td class="value"><%= format_measure('major_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MINOR.png' -%></td> <td class="name"><%= message('minor') -%>:</td> - <td class="value"><%= format_measure('minor_issues', :default => 0) -%></td> + <td class="value"><%= format_measure('minor_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/INFO.png' -%></td> <td class="name"><%= message('info') -%>:</td> - <td class="value"><%= format_measure('info_issues', :default => 0) -%></td> + <td class="value"><%= format_measure('info_violations', :default => 0) -%></td> </tr> </table> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb deleted file mode 100644 index 47e1a9982fd..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb +++ /dev/null @@ -1,70 +0,0 @@ -<div class="violations_header tab_header"> - <% if @period && measure('new_violations') %> - <table> - <tr> - <td><span class="big"><%= format_variation('new_violations', :default => 0, :period => @period, :style => 'none') -%></span> <%= message('new_violations').downcase -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/BLOCKER.png' -%></td> - <td class="name"><%= message('blocker') -%>:</td> - <td class="value"><%= format_variation('new_blocker_violations', :default => 0, :period => @period, :style => 'none') -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/CRITICAL.png' -%></td> - <td class="name"><%= message('critical') -%>:</td> - <td class="value"><%= format_variation('new_critical_violations', :default => 0, :period => @period, :style => 'none') -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/MAJOR.png' -%></td> - <td class="name"><%= message('major') -%>:</td> - <td class="value"><%= format_variation('new_major_violations', :default => 0, :period => @period, :style => 'none') -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/MINOR.png' -%></td> - <td class="name"><%= message('minor') -%>:</td> - <td class="value"><%= format_variation('new_minor_violations', :default => 0, :period => @period, :style => 'none') -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/INFO.png' -%></td> - <td class="name"><%= message('info') -%>:</td> - <td class="value"><%= format_variation('new_info_violations', :default => 0, :period => @period, :style => 'none') -%></td> - </tr> - </table> - - <% else %> - <table class="sourceHeader"> - <tr> - <td nowrap><span class="big"><%= format_measure('violations', :default => 0) -%></span> <%= message('violations').downcase -%></td> - - <td class="sep"> </td> - <td nowrap><%= image_tag 'priority/BLOCKER.png' -%></td> - <td class="name"><%= message('blocker') -%>:</td> - <td class="value"><%= format_measure('blocker_violations', :default => 0) -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/CRITICAL.png' -%></td> - <td class="name"><%= message('critical') -%>:</td> - <td class="value"><%= format_measure('critical_violations', :default => 0) -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/MAJOR.png' -%></td> - <td class="name"><%= message('major') -%>:</td> - <td class="value"><%= format_measure('major_violations', :default => 0) -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/MINOR.png' -%></td> - <td class="name"><%= message('minor') -%>:</td> - <td class="value"><%= format_measure('minor_violations', :default => 0) -%></td> - - <td class="sep"> </td> - <td><%= image_tag 'priority/INFO.png' -%></td> - <td class="name"><%= message('info') -%>:</td> - <td class="value"><%= format_measure('info_violations', :default => 0) -%></td> - </tr> - </table> - <% end %> - - <%= render :partial => 'options' -%> - -</div> - diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index.html.erb index 7837b010449..f72c402b88a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index.html.erb @@ -1,25 +1,20 @@ -<div> +<% accordionId = rand(10000) %> +<div id="accordion<%= accordionId -%>"> <div class="accordion-item-header"> <%= render :partial => 'tabs' -%> </div> <div class="accordion-item-body"> <%= render :partial => "resource/header_#{@extension.getId()}" -%> - <% if @display_violations && @global_violations && @global_violations.size>0 -%> - <table class="global_violations" cellpadding="0" cellspacing="0" border="0"> - <% @global_violations.each do |violation| %> - <tr> - <td> - <%= render :partial => 'violation', :locals => {:violation => violation, \ - :review_screens => @review_screens_by_vid ? @review_screens_by_vid.get(violation.id) : []} -%> - </td> - </tr> + <% if @display_issues && @global_issues && @global_issues.size>0 -%> + <div class="code-global-issues"> + <% @global_issues.each do |issue| %> + <%= render :partial => 'issue/issue', :locals => {:issue => issue} -%></td> <% end %> - </table> + </div> <% end %> <% if @lines && @lines.size>0 %> - <%= render :partial => "shared/source_display", :locals => { :display_manual_violation_form => @display_manual_violation_form, \ :scm_available => @scm_available, \ :display_coverage => @display_coverage, \ @@ -32,7 +27,6 @@ :review_screens_by_vid => @review_screens_by_vid, \ :filtered => @filtered} %> - <% end %> <% if @duplication_groups %> @@ -41,5 +35,7 @@ </div> </div> - +<script> + $j('#accordion<%= accordionId -%> .open-modal').modal(); +</script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index_issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index_issues.html.erb deleted file mode 100644 index 2b5028c551a..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_index_issues.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<% accordionId = rand(10000) %> -<div id="accordion<%= accordionId -%>"> - <div class="accordion-item-header"> - <%= render :partial => 'tabs' -%> - </div> - <div class="accordion-item-body"> - <%= render :partial => "resource/header_#{@extension.getId()}" -%> - - <% if @display_issues && @global_issues && @global_issues.size>0 -%> - <div class="code-global-issues"> - <% @global_issues.each do |issue| %> - <%= render :partial => 'issue/issue', :locals => {:issue => issue} -%></td> - <% end %> - </div> - <% end %> - - <% if @lines && @lines.size>0 %> - <%= render :partial => "shared/source_display", :locals => { :display_manual_violation_form => @display_manual_violation_form, \ - :scm_available => @scm_available, \ - :display_coverage => @display_coverage, \ - :lines => @lines, \ - :expanded => @expanded, \ - :display_violations => @display_violations, \ - :display_issues => @display_issues, \ - :resource => @resource, \ - :snapshot => @snapshot, \ - :review_screens_by_vid => @review_screens_by_vid, \ - :filtered => @filtered} - %> - <% end %> - - <% if @duplication_groups %> - <%= render :partial => 'duplications' -%> - <% end %> - - </div> -</div> -<script> - $j('#accordion<%= accordionId -%> .open-modal').modal(); -</script> - diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter_issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter_issues.html.erb index a29d796f894..e26bc026875 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter_issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter_issues.html.erb @@ -1,29 +1,29 @@ <% if @period - blocker_issues = @snapshot.measure('new_blocker_issues') - critical_issues = @snapshot.measure('new_critical_issues') - major_issues = @snapshot.measure('new_major_issues') - minor_issues = @snapshot.measure('new_minor_issues') - info_issues = @snapshot.measure('new_info_issues') + blocker_issues = @snapshot.measure('new_blocker_violations') + critical_issues = @snapshot.measure('new_critical_violations') + major_issues = @snapshot.measure('new_major_violations') + minor_issues = @snapshot.measure('new_minor_violations') + info_issues = @snapshot.measure('new_info_violations') metrics = [ - Metric.by_key("new_blocker_issues"), - Metric.by_key("new_critical_issues"), - Metric.by_key("new_major_issues"), - Metric.by_key("new_minor_issues"), - Metric.by_key("new_info_issues") + Metric.by_key('new_blocker_violations'), + Metric.by_key('new_critical_violations'), + Metric.by_key('new_major_violations'), + Metric.by_key('new_minor_violations'), + Metric.by_key('new_info_violations') ] else - blocker_issues = @snapshot.measure('blocker_issues') - critical_issues = @snapshot.measure('critical_issues') - major_issues = @snapshot.measure('major_issues') - minor_issues = @snapshot.measure('minor_issues') - info_issues = @snapshot.measure('info_issues') + blocker_issues = @snapshot.measure('blocker_violations') + critical_issues = @snapshot.measure('critical_violations') + major_issues = @snapshot.measure('major_violations') + minor_issues = @snapshot.measure('minor_violations') + info_issues = @snapshot.measure('info_violations') metrics = [ - Metric.by_key("blocker_issues"), - Metric.by_key("critical_issues"), - Metric.by_key("major_issues"), - Metric.by_key("minor_issues"), - Metric.by_key("info_issues") + Metric.by_key('blocker_violations'), + Metric.by_key('critical_violations'), + Metric.by_key('major_violations'), + Metric.by_key('minor_violations'), + Metric.by_key('info_violations') ] 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 deleted file mode 100644 index 9d1c0345a92..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb +++ /dev/null @@ -1,155 +0,0 @@ -<div id="vId<%= violation.id -%>"> - <div class="violation"> - <div class="vtitle"> - <% if violation.review %> - <div class="review_permalink"> - <span class="review_permalink"><%= link_to "Review #"+violation.review.id.to_s, :controller => "project_reviews", :action => "view", :id => violation.review.id -%></span> - </div> - <% end %> - - <% if violation.review && violation.review.manual_severity && violation.review.severity!=violation.severity %> - <img src="<%= ApplicationController.root_context -%>/images/priority/<%= violation.review.severity -%>.png"> - <% else %> - <img src="<%= ApplicationController.root_context -%>/images/priority/<%= violation.failure_level -%>.png"> - <% end %> - - <span class="rulename"> - <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a> - </span> - - <%= image_tag 'sep12.png' -%> - - - <% if violation.created_at %> - <span><%= distance_of_time_in_words_to_now(violation.created_at) -%></span> - - <% end %> - <% if violation.switched_off? %> - <%= image_tag 'sep12.png' -%> - - <span class="falsePositive"><%= message('false_positive') -%></span> - - <% end %> - <% if violation.review && violation.review.resolved? %> - <%= image_tag 'sep12.png' -%> - - <span class="reviewResolved"><%= message('reviews.status.RESOLVED') -%></span> - - <% end %> - <% if violation.review && violation.review.assignee_id %> - <%= image_tag 'sep12.png' -%> - - <%= message('assigned_to') -%> <%= h(violation.review.assignee.name) -%> - - <% end %> - <% if violation.review && violation.review.planned? %> - <%= image_tag 'sep12.png' -%> - - <%= message('reviews.planned_for_x', :params => h(violation.review.action_plan.name)) -%> - - <% end %> - - </div> - - <div class="discussionComment first"> - <div id="vMsg<%= violation.id -%>"> - <%= violation.html_message || ' ' -%> - </div> - </div> - - <% - if violation.review - violation.review.comments.each_with_index do |review_comment, comment_index| - is_last_comment=(comment_index==violation.review.comments.size-1) - %> - <div class="discussionComment"> - <h4><%= image_tag("reviews/comment.png") -%> <b><%= review_comment.user.name -%></b> - (<%= distance_of_time_in_words_to_now(review_comment.created_at) -%>) - <% if is_last_comment && current_user %> - <span class="actions" id="commentActions<%= violation.id -%>"> - - <% - if current_user.id == review_comment.user_id - %> - <%= image_tag 'sep12.png' -%> - - <%= link_to_remote message('reviews.edit'), - :url => {:controller => "reviews", :action => "violation_comment_form", :comment_id => review_comment.id, :id => violation.id}, - :update => "lastComment" + violation.id.to_s, - :complete => "$('vActions#{violation.id}').hide();$('commentActions#{violation.id}').hide();$('commentText#{violation.id}').focus();", - :html => {:class => 'link-action'} -%> - - <%= link_to_remote message('reviews.delete'), - :url => {:controller => "reviews", :action => "violation_delete_comment", :comment_id => review_comment.id, :id => violation.id}, - :update => "vId" + violation.id.to_s, - :confirm => message('reviews.do_you_want_to_delete_comment'), - :html => {:class => 'link-action'} -%> - <% - end - %> - </span> - <% end %> - </h4> - <% if is_last_comment %> - <div id="lastComment<%= violation.id -%>"> - <%= review_comment.html_text -%> - </div> - <% else %> - <%= review_comment.html_text -%> - <% end %> - </div> - <% - end - %> - <div class="discussionComment" id="replyForm<%= violation.id -%>" style="display:none"></div> - <% - end - %> - - <% if current_user %> - <div class="vActions" id="vActions<%= violation.id -%>"> - <% if defined?(error_message) && error_message %> - <div id="review_error_<%= violation.id -%>" class="error"><%= h error_message -%> <a href="#" onclick="$('review_error_<%= violation.id -%>').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div> - <% end %> - - <%= link_to_function message('reviews.comment'), "sCF(#{violation.id})", :name => 'bComment', :class => 'link-action spacer-right' -%> - - <% unless violation.review && violation.review.resolved? %> - <%= link_to_function message('reviews.assign'), "sAF(#{violation.id})", :name => 'bAssign', :class => 'link-action spacer-right' -%> - <% end %> - - <% if violation.review.nil? || violation.review.can_change_false_positive_flag? %> - <%= link_to_function message(violation.switched_off? ? 'reviews.unflag_as_false_positive' : 'reviews.flag_as_false_positive'), - "sFPF(#{violation.id})", :name => 'bFalsePositive', :class => 'link-action spacer-right' -%> - <% end %> - - <% unless violation.switched_off? && violation.review && violation.review.resolved? %> - <div class="dropdown"> - <a href="#" class="link-action link-more" onclick="showDropdownMenu('more<%= violation.id -%>');return false;"><%= message('more_actions') -%></a> - <ul style="display: none" class="dropdown-menu" id="more<%= violation.id -%>"> - <% if !violation.switched_off? %> - <li><%= link_to_function (violation.review && violation.review.resolved? ? message('reviews.reopen') : message('reviews.resolved')), - "sCStF(#{violation.id})", :name => (violation.review && violation.review.resolved? ? 'bReopen' : 'bResolved') -%></li> - <% end %> - <% unless violation.review && violation.review.resolved? %> - <li><%= link_to_function message('reviews.change_severity'), "sCSF(#{violation.id})", :name => 'bChangeSeverity' -%></li> - <li><%= link_to_function message('reviews.link_to_action_plan'), "sAPF(#{violation.id})", :name => 'bLinkActionPlan' -%></li> - <% end %> - <% - if defined? review_screens - review_screens.each do |screen| - %> - <li><%= link_to_function message("reviews.command.#{screen.getCommandKey()}.button"), "sS(#{violation.id}, '#{screen.getCommandKey()}')", :name => "bCommand#{screen.getCommandKey()}" -%></li> - <% - end - end - %> - </ul> - </div> - <% end %> - </div> - <% end %> - <div class="discussionComment" id="reviewForm<%= violation.id -%>" style="display:none"></div> - </div> - -</div>
\ 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 47c62b544bd..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_list.html.erb +++ /dev/null @@ -1,83 +0,0 @@ - <% - if @reviews && !@reviews.empty? - %> - <table id="reviews-list" class="data width100"> - <thead> - <tr> - <th width="1%" nowrap> - <a href="#" onClick="launchSearch('status')"><%= message('status_abbreviated') -%></a> - <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'status' -%> - </th> - <th width="1%" nowrap> - <a href="#" onClick="launchSearch('id')"><%= message('identifier_abbreviated') -%></a> - <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'id' -%> - </th> - <th width="1%" nowrap> - <a href="#" onClick="launchSearch('severity')"><%= message('severity_abbreviated') -%></a> - <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'severity' -%> - </th> - <th> - <a href="#" onClick="launchSearch('title')"><%= message('title') -%></a> - <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'title' -%> - </th> - <th width="1%"><%= message('project') -%></th> - <th><%= message('assignee') -%></th> - <th> - <a href="#" onClick="launchSearch('updated_at')"><%= message('age') -%></a> - <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'updated_at' -%> - </th> - </tr> - </thead> - <tfoot> - <tr> - <td colspan="6"> - <%= paginate(@reviews) -%> - </td> - </tr> - </tfoot> - <tbody> - <% - @reviews.each do |review| - comment = review.comments.last - %> - <tr class="<%= cycle('even', 'odd') -%>"> - <td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png" title="<%= message(review.status.downcase).capitalize -%>"/></td> - <td> - <%= link_to h(review.id), :controller => "project_reviews", :action => "view", :id => review.id -%> - </td> - <td><img src="<%= ApplicationController.root_context -%>/images/priority/<%= review.severity -%>.png" title="<%= message(review.severity.downcase).capitalize -%>"/></td> - <td> - <%= link_to h(review.title), :controller => "project_reviews", :action => "view", :id => review.id -%> - <% if comment %> - <div class="comment-excerpt"> - <img src="<%= ApplicationController.root_context -%>/images/reviews/comment.png"/> - <b><%= comment.user.name -%> :</b> - <%= comment.excerpt -%> - <% end %> - </div> - </td> - <td> - <span class="nowrap"><%= h review.project.name -%></span> - <br/> - <span class="note"><%= h(review.resource.name) if review.resource -%></span></td> - <td><%= review.assignee ? h(review.assignee.name) : '-' -%></td> - <td><%= distance_of_time_in_words_to_now(review.updated_at) -%></td> - </tr> - <% - end - %> - </tbody> - </table> - <% - elsif @reviews - %> - <p><%= message('no_results') -%></p> - <% - end - %> - - <% if @security_exclusions %> - <br/> - - <p class="notes"><%= message('results_not_display_due_to_security') -%></p> - <% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb deleted file mode 100644 index 511c9cbc207..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -<% if @action_plans.empty? %> - - <span class="error"><%= message('reviews.an_action_plan_must_be_created_first') -%></span> - - <%= link_to_function message('reviews.hide_this_message'), "cancelViolationAction(#{params[:id]})" -%> - -<% else %> - -<form method="POST" action="violation_link_to_action_plan"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - - <%= message('reviews.action_plan_label') -%>: - <select name="action_plan_id" id="selectActionPlan<%= params[:id] -%>"> - <% @action_plans.each do |plan| %> - <option value="<%= plan.id -%>" <%= 'selected' if @violation.review && @violation.review.linked_to?(plan) -%>><%= h(plan.name) -%></option> - <% end %> - </select> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= params[:id] -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <%= submit_to_remote "submit_btn"+params[:id], message('reviews.action_plan_submit'), :url => {:action => 'violation_link_to_action_plan'}, :html => {:id => "submit_btn"+params[:id]}, :update => 'vId'+params[:id] -%> - - <% if @violation.review && @violation.review.planned? %> - - <%= submit_to_remote "submit_btn"+params[:id], message('reviews.unlink_action_plan_submit'), :url => {:action => 'violation_unlink_from_action_plan'}, :html => {:id => "submit_btn"+params[:id]}, :update => 'vId'+params[:id] -%> - <% end %> - - - <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> -</form> - -<% end %>
\ No newline at end of file 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 deleted file mode 100644 index 2609c659881..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<% - assignee_check_script = "if ($('autocompleteText-assignee_login').value != '' && $('assignee_login').value == '') { alert($('autocompleteText-assignee_login').value + '" + message('reviews.user_does_not_exist') + "'); return false;}" -%> - -<form method="post" - onsubmit="<%= assignee_check_script -%> new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> - <%= hidden_field_tag :id, params[:id] -%> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= params[:id] -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <%= user_autocomplete_field "assignee_login", "" -%> - - <%= submit_to_remote "submit_btn", message('reviews.assign_submit'), - :url => {:action => 'violation_assign'}, - :update => "vId" + params[:id], - :before => assignee_check_script -%> - - <%= image_tag 'sep12.png' -%> - - <%= submit_to_remote "submit_me_btn", message('reviews.assign_to_me_submit'), - :url => {:action => 'violation_assign', :id => params[:id], :me => true}, - :update => "vId" + params[:id], - :html => {:disabled => (@violation.review && @violation.review.assignee_id==current_user.id)} -%> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> - <script> - $('autocompleteText-assignee_login').focus() - </script> -</form>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_severity_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_severity_form.html.erb deleted file mode 100644 index fc45d84af21..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_severity_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<form method="POST" action="violation_change_severity"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - - <%= message('reviews.new_severity_label') -%> - <select name="severity" class="withIcons" id="selectSeverity<%= params[:id] -%>"> - <% Severity::KEYS.each do |severity| %> - <option class="sev_<%= severity -%>" value="<%= severity -%>" <%= 'selected' if severity==Severity::MAJOR -%>><%= message("severity.#{severity}") -%></option> - <% end %> - </select> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= params[:id] -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - <input type="button" value="<%= h message('reviews.change_severity_submit') -%>" onclick="new Ajax.Updater('vId<%= params[:id] -%>', '<%= ApplicationController.root_context -%>/reviews/violation_change_severity', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});" name="submit_severity" id="submit_btn<%= params[:id] -%>"> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_status_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_status_form.html.erb deleted file mode 100644 index 79359eeedea..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_change_status_form.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<form method="POST" - onsubmit="new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_change_status' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= params[:id] -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <div> - <%= submit_to_remote "submit_btn"+params[:id], - @violation.review && @violation.review.resolved? ? message('reviews.reopen_submit') : message('reviews.resolved_submit'), - :url => {:action => 'violation_change_status'}, - :html => {:id => "submit_btn"+params[:id]}, - :update => 'vId'+params[:id] -%> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> - </div> -</form> 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 deleted file mode 100644 index 152fa5baccc..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<% - button_label=(@comment ? message('reviews.update_comment_submit') : message('reviews.comment_submit')) -%> -<form method="POST" - onsubmit="new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_save_comment' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> - <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<%= params[:id] -%>" - onkeyup="if (this.value=='') $('submit_btn<%= params[:id] -%>').disabled='true'; else $('submit_btn<%= params[:id] -%>').disabled='';" - rows="4" name="text" style="width: 100%"><%= @comment.text if @comment -%></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - - <div> - <%= submit_to_remote "submit_btn"+params[:id], - button_label, - :url => {:action => 'violation_save_comment'}, - :html => {:id => "submit_btn"+params[:id], :disabled => "true"}, - :before => "$('loading-#{params[:id]}').show();", - :update => 'vId'+params[:id] -%> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> - - <span id="loading-<%= params[:id] -%>" style="display: none;"><%= image_tag 'loading.gif' -%></span> - </div> -</form> 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 deleted file mode 100644 index 5d9e06f03da..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -<% - if @violation.switched_off? - title = message('reviews.why_not_false_positive') - button = message('reviews.unflag_as_false_positive_submit') - else - title = message('reviews.why_false_positive') - button = message('reviews.flag_as_false_positive_submit') - end -%> -<form method="POST" action="violation_flag_as_false_positive"> - <input type="hidden" name="id" value="<%= params[:id] -%>"/> - <input type="hidden" name="false_positive" value="<%= @violation.switched_off? ? 'false' : 'true' -%>"/> - - <h3><%= title -%></h3> - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= params[:id] -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - <%= submit_to_remote "submit_btn"+params[:id], button, :url => {:action => 'violation_flag_as_false_positive'}, :html => {:id => "submit_btn"+params[:id]}, :update => 'vId'+params[:id] -%> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{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 deleted file mode 100644 index d5a371cf08e..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb +++ /dev/null @@ -1,120 +0,0 @@ -<% content_for :style do %> - <style> - #search-form select { - width: 100%; - box-sizing: border-box; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - } - </style> -<% end %> -<% content_for :script do %> - <script> - - function reviewIdFieldModified(field) { - if (field.value != '') { - $('statuses').value = ''; - $('severities').value = ''; - $('projects').value = ''; - $('author_login').value = ''; - $('autocompleteText-author_login').value = ''; - $('assignee_login').value = ''; - $('autocompleteText-assignee_login').value = ''; - $('false_positives').value = 'with'; - } - } - function launchSearch(columnName) { - $('sort').value = columnName; - if ($('asc').value == "true") { - $('asc').value = "false"; - } else { - $('asc').value = "true"; - } - document.forms[0].submit(); - } - - </script> -<% end %> - -<div id="reviews-search"> - <div class="page-split-left"> - <form id="search-form" method="GET" action="<%= ApplicationController.root_context -%>/reviews/index"> - <ul class="sidebar gray-sidebar"> - <li> - <%= message('identifier_abbreviated') -%>: - <br/> - <%= text_field_tag "review_id", @id, :size => 10, :onkeyup => "reviewIdFieldModified(this)" -%> - </li> - <li> - <%= message('status') -%>: - <br/> - <select size="5" name="statuses[]" multiple="multiple" id="statuses" class="withIcons"> - <option <%= 'selected' if @statuses.include?('') -%> value=""><%= message('any') -%></option> - <option value="<%= Review::STATUS_OPEN -%>" class="status_open" <%= 'selected' if @statuses.include?(Review::STATUS_OPEN) -%>><%= message('reviews.status.OPEN') -%></option> - <option value="<%= Review::STATUS_REOPENED -%>" class="status_reopened" <%= 'selected' if @statuses.include?(Review::STATUS_REOPENED) -%>><%= message('reviews.status.REOPENED') -%></option> - <option value="<%= Review::STATUS_RESOLVED -%>" class="status_resolved" <%= 'selected' if @statuses.include?(Review::STATUS_RESOLVED) -%>><%= message('reviews.status.RESOLVED') -%></option> - <option value="<%= Review::STATUS_CLOSED -%>" class="status_closed" <%= 'selected' if @statuses.include?(Review::STATUS_CLOSED) -%>><%= message('reviews.status.CLOSED') -%></option> - </select> - </li> - <li> - <%= message('severity') -%>: - <br/> - <select size="6" name="severities[]" multiple="multiple" id="severities" class="withIcons"> - <option <%= 'selected' if @severities.include?('') -%> value=""><%= message('any') -%></option> - <option value="<%= Severity::BLOCKER -%>" class="sev_BLOCKER" <%= 'selected' if @severities.include?(Severity::BLOCKER) -%>><%= message('blocker') -%></option> - <option value="<%= Severity::CRITICAL -%>" class="sev_CRITICAL" <%= 'selected' if @severities.include?(Severity::CRITICAL) -%>><%= message('critical') -%></option> - <option value="<%= Severity::MAJOR -%>" class="sev_MAJOR" <%= 'selected' if @severities.include?(Severity::MAJOR) -%>><%= message('major') -%></option> - <option value="<%= Severity::MINOR -%>" class="sev_MINOR" <%= 'selected' if @severities.include?(Severity::MINOR) -%>><%= message('minor') -%></option> - <option value="<%= Severity::INFO -%>" class="sev_INFO" <%= 'selected' if @severities.include?(Severity::INFO) -%>><%= message('info') -%></option> - </select> - </li> - <li> - <%= message('project') -%>: - <br/> - <select size="6" name="projects[]" multiple="multiple" id="projects"> - <option <%= 'selected' if @projects.include?('') -%> value=""><%= message('any') -%></option> - <% projects_for_select.each do |project| - name=project.name(true) - %> - <option value="<%= project.id -%>" title="<%= h(name) -%>" <%= 'selected' if @projects.include?(project.id.to_s) -%>><%= h(truncate(name, :length => 20)) -%></option> - <% end %> - </select> - </li> - <li> - <%= message('created_by') -%>: - <br/> - <%= user_autocomplete_field "author_login", @author_login -%> - </li> - <li> - <%= message('assigned_to') -%>: - <br/> - <%= user_autocomplete_field "assignee_login", @assignee_login -%> - </li> - <li> - <select name="false_positives" id="false_positives" onchange="if(this.value=='only' || this.value=='with') {$('assignee_login').value = ''; $('autocompleteText-assignee_login').value = ''; $('statuses').value = '';};"> - <option <%= 'selected' if @false_positives=='without' -%> value="without"><%= message('reviews.without_false_positives') -%></option> - <option <%= 'selected' if @false_positives=='only' -%> value="only"><%= message('reviews.only_false_positives') -%></option> - </select> - </li> - <li> - <input type="hidden" name="sort" id="sort" value="<%= @sort -%>"/> - <input type="hidden" name="asc" id="asc" value="<%= @asc -%>"/> - <br/> - <%= submit_tag message('search_verb'), :id => 'submit_search' %> - </li> - </ul> - </form> - </div> - <div class="page-split-right"> - <div id="content"> - <% if @false_positives=='only' %> - <span class="falsePositive"><%= message('reviews.showing_false_positives_only') -%></span> - <% end %> - <%= render :partial => "list" -%> - </div> - </div> -</div> - -<script> - $j('#review_id').focus(); -</script>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/screens/_comment.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/screens/_comment.html.erb deleted file mode 100644 index 2c026c9f61f..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/screens/_comment.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<form method="POST" - onsubmit="new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'execute' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> - <input type="hidden" name="id" value="<%= @violation.id -%>"/> - <input type="hidden" name="command" value="<%= @screen.getCommandKey() -%>"/> - - <table class="width100"> - <tr> - <td style="vertical-align:top"> - <textarea id="commentText<%= @violation.id -%>" rows="4" name="text" style="width: 100%"></textarea> - </td> - <td class="sep"></td> - <td style="vertical-align:top;width: 90px"> - <%= render :partial => 'markdown/tips' -%> - </td> - </tr> - </table> - - - <div> - <%= submit_to_remote "submit_btn#{@violation.id}", - message("reviews.command.#{@screen.getCommandKey()}.submit"), - :url => {:action => 'execute'}, - :html => {:id => "submit_btn#{@violation.id}"}, - :before => "$('loading-#{@violation.id}').show();", - :update => "vId#{@violation.id}" -%> - - <%= link_to_function message('cancel'), "cancelViolationAction(#{@violation.id})" -%> - - <span id="loading-<%= @violation.id -%>" style="display: none;"><%= image_tag 'loading.gif' -%></span> - </div> -</form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_display.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_display.erb index 4ecc707f829..93811169004 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_display.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_display.erb @@ -65,8 +65,6 @@ elsif line.hits status=(line.hits>0 ? '' : 'ko') end - elsif display_violations && line.violations? - status="ko" elsif display_issues && line.issues? status="ko" elsif line.has_focus @@ -78,7 +76,7 @@ <tr class="row pos<%= index+1 -%>"> <% if display_manual_violation_form %> - <%= render :partial => "shared/source_violation_form", :locals => { :resource_id => resource.id, \ + <%= render :partial => "shared/source_issue_form", :locals => { :resource_id => resource.id, \ :index => index, \ :gray_colspan => gray_colspan, \ :white_colspan => white_colspan} %> @@ -111,13 +109,6 @@ </tr> - <% if display_violations && line.violations? %> - <%= render :partial => "shared/source_violations", :locals => {:line => line, \ - :display_manual_violation_form => display_manual_violation_form, \ - :scm_available => scm_available, \ - :review_screens_by_vid => review_screens_by_vid} %> - <% end %> - <% if display_issues && line.issues? %> <%= render :partial => "shared/source_issues", :locals => { :line => line, \ :display_manual_violation_form => display_manual_violation_form, \ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_violation_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_issue_form.html.erb index f94f5bdf557..f94f5bdf557 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_violation_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_issue_form.html.erb diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_violations.html.erb deleted file mode 100644 index 4303b414221..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_violations.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<tr> - <% if display_manual_violation_form %> - <td class="gray"></td> - <% end - if scm_available %> - <td class="scm"></td> - <% end %> - <td class="lid"></td> - <td class="violations"> - <% line.violations.each_with_index do |violation, index| %> - <%= render :partial => 'violation', :locals => {:violation => violation, :review_screens => review_screens_by_vid ? review_screens_by_vid.get(violation.id) : []} -%> - <% if index < line.violations.size-1 %> - - <% end %> - <% end %> - </td> -</tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb index 01707eb4f4a..4f89c36487c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb +++ b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb @@ -9,12 +9,6 @@ ActionController::Routing::Routes.draw do |map| api.resources :projects, :only => [:index, :destroy], :requirements => { :id => /.*/ } api.resources :favourites, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ } api.resources :manual_measures, :only => [:index, :create, :destroy], :requirements => { :id => /.*/ } - api.resources :reviews, :only => [:index, :show, :create], :member => { - :add_comment => :put, - :reassign => :put, - :resolve => :put, - :reopen => :put - } end map.connect 'api/metrics', :controller => 'api/metrics', :action => 'index', :conditions => { :method => :get } @@ -25,7 +19,6 @@ ActionController::Routing::Routes.draw do |map| map.connect 'api/server/:action', :controller => 'api/server' map.connect 'api/resoures', :controller => 'api/resources', :action => 'index' map.connect 'api/sources', :controller => 'api/sources', :action => 'index' - map.connect 'api/violations', :controller => 'api/violations', :action => 'index' map.resources 'rules', :path_prefix => 'api', :controller => 'api/rules' map.resources 'properties', :path_prefix => 'api', :controller => 'api/properties', :requirements => { :id => /.*/ } diff --git a/sonar-server/src/main/webapp/javascripts/resource.js b/sonar-server/src/main/webapp/javascripts/resource.js index 46818a37187..07ef48116a6 100644 --- a/sonar-server/src/main/webapp/javascripts/resource.js +++ b/sonar-server/src/main/webapp/javascripts/resource.js @@ -22,258 +22,6 @@ function loadGWT(gwtId, resourceId, resourceKey, resourceName, resourceScope, re modules[gwtId](); } -// cancel action : hide form and refresh violation -function cancelViolationAction(violation_id) { - new Ajax.Updater( - 'vId' + violation_id, - baseUrl + '/reviews/display_violation/' + violation_id, - { - asynchronous:true, - evalScripts:true - }); - return false; -} - -function hideMoreViolationActions(violation_id) { - var popup = $('more' + violation_id); - if (popup != null) { - popup.hide(); - } -} - -function sCF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_comment_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('commentText' + violation_id).focus(); - } - }); - return false; -} - -// show review screen -function sS(violation_id, command_key) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/screen/' + violation_id + '?command=' + command_key, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('commentText' + violation_id).focus(); - } - }); - return false; -} - -// show the form to change severity -function sCSF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_change_severity_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('selectSeverity' + violation_id).focus(); - } - }); - return false; -} - -// show the form to change status -function sCStF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_change_status_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('commentText' + violation_id).focus(); - } - }); - return false; -} - -// show the form to flag as false-positive -function sFPF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_false_positive_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('commentText' + violation_id).focus(); - } - }); - return false; -} - -// show the form to assign violation -function sAF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_assign_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('assignee_login').focus(); - } - }); - return false; -} - -// show the form to link a review to an action plan -function sAPF(violation_id) { - hideMoreViolationActions(violation_id); - new Ajax.Updater('reviewForm' + violation_id, - baseUrl + '/reviews/violation_action_plan_form/' + violation_id, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('vActions' + violation_id).remove(); - $('reviewForm' + violation_id).show(); - $('action_plan').focus(); - } - }); - return false; -} - -// show the form to create violation -function sVF(elt, resource, line, gray_colspan, white_colspan) { - row = $j('#createViolationForm' + line); - if (!row.length) { - expandAccordionItem(elt); - var element = $j(elt).closest('.pos' + line); - $j.get(baseUrl + '/resource/show_create_violation_form?resource='+ resource + '&line='+ line + '&gray_colspan='+ gray_colspan + '&white_colspan='+ white_colspan, function (html) { - element.after(html); - }).error(function () { - alert("Server error. Please contact your administrator."); - }); - } - return false; -} - -// hide review form -function hVF(elt, line) { - var row = $j(elt).closest('#createViolationRow'+ line); - if (row.length) { - row.remove(); - } - return false; -} - -/* - Functions used in issues code viewer - */ - -// show the form for transition -function displayIssueTransitionForm(issueKey, transitionKey) { - hideMoreIssueActions(issueKey); - new Ajax.Updater('issue-form' + issueKey, - baseUrl + '/issue/issue_transition_form?issue=' + issueKey + '&transition='+ transitionKey, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('issue-actions' + issueKey).remove(); - $('issue-form' + issueKey).show(); - $('issue-comment' + issueKey).focus(); - } - }); - return false; -} - -// show the form to assign issue -function displayIssueAssignForm(issueKey) { - hideMoreIssueActions(issueKey); - new Ajax.Updater('issue-form' + issueKey, - baseUrl + '/issue/issue_assign_form/?issue=' +issueKey, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('issue-actions' + issueKey).remove(); - $('issue-form' + issueKey).show(); - $('issue_assignee_login').focus(); - } - }); - return false; -} - -// show the form to change severity -function displayIssueChangeSeverityForm(issueKey) { - hideMoreIssueActions(issueKey); - new Ajax.Updater('issue-form' + issueKey, - baseUrl + '/issue/issue_change_severity_form/?issue=' + issueKey, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('issue-actions' + issueKey).remove(); - $('issue-form' + issueKey).show(); - $('issue-severity' + issueKey).focus(); - } - }); - return false; -} - -// show the form to link a issue to an action plan -function displayIssuePlanForm(issueKey) { - hideMoreIssueActions(issueKey); - new Ajax.Updater('issue-form' + issueKey, - baseUrl + '/issue/issue_plan_form/?issue=' + issueKey, - { - asynchronous:true, - evalScripts:true, - onComplete:function (request) { - $('issue-actions' + issueKey).remove(); - $('issue-form' + issueKey).show(); - $('issue-plan').focus(); - } - }); - return false; -} - -// cancel action : hide form and refresh issue -function cancelIssueAction(issueKey) { - new Ajax.Updater( - 'issue-key' + issueKey, - baseUrl + '/issue/display_issue?issue=' + issueKey, - { - asynchronous:true, - evalScripts:true - }); - return false; -} - -function hideMoreIssueActions(issueKey) { - var popup = $('more' + issueKey); - if (popup != null) { - popup.hide(); - } -} - /* Functions used in tests viewer */ diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 1d0db20f278..b708c1c9bc2 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -737,82 +737,11 @@ ul.operations li img { font-size: 12px; } -.sources2 td.reviewForm { - width: 100%; - padding: 10px; -} - - - - - - - - - - - - - -div.vtitle { - background-color: #E4ECF3; - margin: 0; - padding: 5px 10px; - line-height: 16px; - color: #777; - border-bottom: 1px solid #DDDDDD; -} - -div.vtitle img { - vertical-align: text-bottom; -} - -div.vActions { - padding: 5px 10px; - border-top: 1px solid #DDD; - background-color: #EFEFEF; - line-height: 16px; -} - -span.falsePositive, span.reviewResolutionFALSE-POSITIVE { - background-color: #FFF6BF; - padding-left: 5px; - padding-right: 5px; -} - -span.reviewResolved, span.reviewStatusRESOLVED { - background-color: #4B9FD5; - color: #FFF; - padding-left: 5px; - padding-right: 5px; -} - -span.reviewReopened, span.reviewStatusREOPENED { - background-color: #FDC596; - padding-left: 5px; - padding-right: 5px; -} - span.rulename, span.rulename a { color: #444; font-weight: bold; } -div.review_permalink { - float: right; - color: #333; - font-weight: bold; - margin: 0; - padding: 0 10px; - text-shadow: 1px 1px 0 #FFFFFF; -} - -span.review_permalink a { - color: #777; - font-size: 11px; - padding: 0 0 0 20px; -} - span.rulename a:hover { text-decoration: underline; } @@ -1055,49 +984,6 @@ span.rulename a:hover { padding: 10px; } -/* REVIEWS */ -div.reviewTitle { - background-color: #E4ECF3; - color: #4B9FD5; - line-height: 2.2em; - margin: 0; - margin-bottom: 10px; - padding: 0 10px; - border: 1px solid #4B9FD5; -} - -div.reviewTitle h2 { - color: #4183C4; - font-weight: bold; - font-size: 100%; - text-shadow: 0 1px 0 #FFFFFF; -} - -div.reviewTitle span.actions { - font-size: 12px; -} - -table.reviewDetails { - width: 100%; - border: 0; -} - -table.reviewDetails td { - vertical-align: top; - text-align: left; - padding: 5px 10px; -} - -table.reviewDetails td.key { - white-space: nowrap; - min-width: 1%; - color: #777; -} - -table.reviewDetails td img { - vertical-align: bottom; -} - .discussion { width: 100%; border: 1px solid #DDDDDD; @@ -1143,26 +1029,6 @@ div.comment-excerpt { font-size: 90%; } -div.review-filters { - font-size: 93%; - margin: 10px; -} - -span.review-filter { - background-color: #CAE3F2; - padding-left: 5px; - padding-right: 5px; - margin-left: 5px; -} - -span.review-filter a { - color: #777777; - font-size: 80%; - margin-left: 6px; - text-decoration: none; - text-shadow: 1px 1px 0 #FFFFFF; -} - /* ACTION PLANS */ table.actionPlans { margin-top: 10px; |