From 0e16e7b3c59a1feb9068d648169d50f4b6a323fb Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 8 Sep 2016 13:58:18 +0200 Subject: [PATCH] SONAR-8070 Drop of "Comparison" feature --- .../java/it/measureHistory/HistoryUiTest.java | 9 - .../should-compare-project-versions.html | 34 --- .../js/main/nav/global/global-nav-menu.js | 13 +- .../main/js/main/nav/global/search-view.js | 3 +- .../app/controllers/comparison_controller.rb | 104 -------- .../app/views/comparison/_versions.html.erb | 8 - .../app/views/comparison/index.html.erb | 252 ------------------ .../resources/org/sonar/l10n/core.properties | 2 - 8 files changed, 4 insertions(+), 421 deletions(-) delete mode 100644 it/it-tests/src/test/resources/measureHistory/HistoryUiTest/comparison/should-compare-project-versions.html delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/_versions.html.erb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb diff --git a/it/it-tests/src/test/java/it/measureHistory/HistoryUiTest.java b/it/it-tests/src/test/java/it/measureHistory/HistoryUiTest.java index 5c6b44c2f1c..5496efd6ac9 100644 --- a/it/it-tests/src/test/java/it/measureHistory/HistoryUiTest.java +++ b/it/it-tests/src/test/java/it/measureHistory/HistoryUiTest.java @@ -72,13 +72,4 @@ public class HistoryUiTest { ).build()); } - /** - * SONAR-2911 - */ - @Test - public void test_comparison_page_between_project_versions() { - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("comparison-page", - "/measureHistory/HistoryUiTest/comparison/should-compare-project-versions.html" - ).build()).runOn(orchestrator); - } } diff --git a/it/it-tests/src/test/resources/measureHistory/HistoryUiTest/comparison/should-compare-project-versions.html b/it/it-tests/src/test/resources/measureHistory/HistoryUiTest/comparison/should-compare-project-versions.html deleted file mode 100644 index 5bad1f996c6..00000000000 --- a/it/it-tests/src/test/resources/measureHistory/HistoryUiTest/comparison/should-compare-project-versions.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - should-compare-project-versions - - - - - - - - - - - - - - - - - - - - - - - - - -
open/comparison/index?resource=sample&locale=en-gb
waitForTextcomparison-page*Sample*0.9-SNAPSHOT*19 Oct 2014*Sample*1.0-SNAPSHOT*13 Nov 2014*
waitForTextcomparison-page*Lines of Code*24*40*
waitForTextcomparison-page*Lines of Code*Complexity*Comments (%)*Duplicated Lines (%)*Issues*Coverage*
- - diff --git a/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js b/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js index cf945ffb4b8..05aadf80412 100644 --- a/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js +++ b/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js @@ -123,15 +123,6 @@ export default React.createClass({ ); }, - renderComparisonLink () { - const url = window.baseUrl + '/comparison'; - return ( -
  • - {translate('comparison_global.page')} -
  • - ); - }, - renderGlobalPageLink (globalPage, index) { const url = window.baseUrl + globalPage.url; return ( @@ -142,6 +133,9 @@ export default React.createClass({ }, renderMore () { + if (this.props.globalPages.length == 0) { + return null; + } const globalPages = this.props.globalPages.map(this.renderGlobalPageLink); return (
  • @@ -150,7 +144,6 @@ export default React.createClass({
      - {this.renderComparisonLink()} {globalPages}
  • diff --git a/server/sonar-web/src/main/js/main/nav/global/search-view.js b/server/sonar-web/src/main/js/main/nav/global/search-view.js index e88f381201c..e061eb90a9a 100644 --- a/server/sonar-web/src/main/js/main/nav/global/search-view.js +++ b/server/sonar-web/src/main/js/main/nav/global/search-view.js @@ -230,8 +230,7 @@ export default Marionette.LayoutView.extend({ { name: translate('layout.measures'), url: window.baseUrl + '/measures/search?qualifiers[]=TRK' }, { name: translate('coding_rules.page'), url: window.baseUrl + '/coding_rules' }, { name: translate('quality_profiles.page'), url: window.baseUrl + '/profiles' }, - { name: translate('quality_gates.page'), url: window.baseUrl + '/quality_gates' }, - { name: translate('comparison_global.page'), url: window.baseUrl + '/comparison' } + { name: translate('quality_gates.page'), url: window.baseUrl + '/quality_gates' } ]; const customItems = []; if (window.SS.isUserAdmin) { diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb deleted file mode 100644 index c63e11970c1..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb +++ /dev/null @@ -1,104 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 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 ComparisonController < ApplicationController - - SECTION=Navigation::SECTION_HOME - - def index - snapshots = [] - resource_key = params[:resource] - if resource_key && !resource_key.blank? - # the request comes from a project: let's select its 5 latest versions - project = Project.by_key(resource_key) - return render_not_found('Project not found') unless project - - snapshots = project.events.select { |event| event.snapshot && event.category==EventCategory::KEY_VERSION }[0..5].reverse.map {|e| e.snapshot} - # if last snapshot is not in the list, add it at the end (=> might be the case for views or developers which do not have events) - last_snapshot = project.last_analysis - unless snapshots.last == last_snapshot - snapshots.shift - snapshots.push(last_snapshot) - end - else - # the request comes from the comparison page: let's compare the given snapshots - suuids = get_params_as_array(:suuids) - unless suuids.empty? - selected_snapshots = Snapshot.all(:conditions => ['uuid in (?)', suuids]) - # next loop is required to keep the order that was decided by the user and which comes from the "suuids" parameter - suuids.each do |uuid| - selected_snapshots.each do |s| - snapshots << s if uuid==s.uuid.to_s - end - end - end - end - @snapshots = select_authorized(:user, snapshots).map { |snapshot| ComponentSnapshot.new(snapshot, snapshot.resource) } - - metrics = get_params_as_array(:metrics) - if metrics.empty? - metrics = [ - 'ncloc', - 'complexity', - 'comment_lines_density', - 'duplicated_lines_density', - 'violations', - 'coverage' - ] - end - @metrics = Metric.by_keys(metrics) - - @metric_to_choose = Metric.all.select {|m| m.display? && !m.on_new_code? && !@metrics.include?(m)}.sort_by(&:short_name) - end - - def versions - id = params[:id] - suuids = get_params_as_array(:suuids) - - unless id.blank? - project = Project.by_key(id) - - # we look for the events that are versions and that are not linked to snapshots already displayed on the page - @versions = project.events.select { |event| event.category==EventCategory::KEY_VERSION && !suuids.include?(event.analysis_uuid.to_s) } - - # check if the latest snapshot if suggested or not (and if not, suggest it as "LATEST" => this is used for views or developers which do not have events) - latest_snapshot_uuid = project.last_analysis.uuid - current_and_suggested_suuids = suuids + @versions.map {|e| e.analysis_uuid.to_s} - unless current_and_suggested_suuids.include?(latest_snapshot_uuid.to_s) - @versions.unshift Event.new(:name => Api::Utils.message('comparison.version.latest'), :analysis_uuid => latest_snapshot_uuid) - end - end - - render :partial => 'versions' - end - - - private - - def get_params_as_array(name) - list = params[name] - if list.blank? - [] - else - list.split(',') - end - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/_versions.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/_versions.html.erb deleted file mode 100644 index 7a5d7c80be5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/_versions.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% if @versions %> - - - <% @versions.each do |version| %> - - <% end %> - -<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb deleted file mode 100644 index d2d8e286db1..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb +++ /dev/null @@ -1,252 +0,0 @@ -<% content_for :style do %> - -<% end %> -<% content_for :script do %> - -<% end %> - - -
    - -
    - - - -
    -
    - <%= metric_select_tag 'new_metric', @metric_to_choose, { - :allow_empty => true, - :select2_options => {'placeholder' => "'" + message('comparison.add_metric') + "'"} - } -%> - -
    - -
    - <%= resource_select_tag 'new_resource', { - :resource_type_property => 'comparable', - :width => '250px', - :select2_options => {'placeholder' => "'" + message('comparison.add_project') + "'"} - } -%> - -
    - - - - - -
    - - - - - - - <% - last_index = @snapshots.size-1 - @snapshots.each_with_index do |s, index| - %> - - <% end %> - - - - - <% - last_index = @snapshots.size-1 - @snapshots.each_with_index do |s, index| - event = s.event(EventCategory::KEY_VERSION) - %> - - <% end %> - - - - - - <% - last_index = @metrics.size-1 - @metrics.each_with_index do |m, index| - %> - - - - <% @snapshots.each do |s| %> - - <% end %> - - - - <% end %> - -
    - - - - - - -
    - <% if index > 0 %> - - <% else %> - - <% end %> - -
    - -
    -
    - <% if index < last_index %> - - <% else %> - - <% end %> -
    -
    - - <%= h s.component.name(true) -%> -
    - <%= event ? h(event.name) : message('comparison.version.latest') -%> -
    - <%= human_short_date s.created_at -%> -
    -
    - - - - - -
    <%= m.short_name -%> - <% if index > 0 %> - - <% end %> - <% if index < last_index %> - - <% end %> - -
    -
    - <%= format_measure s.measure(m) -%> -
    -
    -
    diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index cf79be08d30..d41ef6ed74f 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -548,11 +548,9 @@ issues_drilldown.page=Issues Drilldown source.page=Source timemachine.page=Time Machine comparison.page=Compare -comparison_global.page=Compare Projects view_projects.page=Projects - #------------------------------------------------------------------------------ # # ASYNC PROCESS -- 2.39.5