]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7934 Reuse /dashboard url for project overview 1115/head
authorStas Vilchik <vilchiks@gmail.com>
Fri, 22 Jul 2016 15:36:18 +0000 (17:36 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 25 Jul 2016 11:47:25 +0000 (13:47 +0200)
it/it-tests/src/test/resources/measure/ProjectOverviewTest/test_project_overview_after_first_analysis.html
server/sonar-web/src/main/js/helpers/urls.js
server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/overview_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/overview.html.erb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb [deleted file]

index 071c91eb3bd83144557274762fe0c5e7782289e6..5c91afb2ac550f81583dee57ce6303c22be307e5 100644 (file)
@@ -16,7 +16,7 @@
   <tbody>
   <tr>
     <td>open</td>
-    <td>/overview?id=project-for-overview</td>
+    <td>/dashboard?id=project-for-overview</td>
     <td></td>
   </tr>
   <tr>
index 19bd44e6add2c1f9d1556ccd12ac09d6ce3b927e..561413c59d9772adb13aaf9c99195b57e18c5244 100644 (file)
@@ -49,32 +49,6 @@ export function getComponentDrilldownUrl (componentKey, metric) {
   return `${window.baseUrl}/component_measures/metric/${metric}?id=${encodeURIComponent(componentKey)}`;
 }
 
-/**
- * Generate URL for a component's dashboard
- * @param {string} componentKey
- * @param {string} dashboardKey
- * @param {string} [period]
- * @returns {string}
- */
-export function getComponentDashboardUrl (componentKey, dashboardKey, period) {
-  let url = window.baseUrl + '/dashboard?id=' + encodeURIComponent(componentKey) +
-      '&did=' + encodeURIComponent(dashboardKey);
-  if (period) {
-    url += '&period=' + period;
-  }
-  return url;
-}
-
-/**
- * Generate URL for a fixed component's dashboard (overview)
- * @param {string} componentKey
- * @param {string} dashboardKey
- * @returns {string}
- */
-export function getComponentFixedDashboardUrl (componentKey, dashboardKey) {
-  return window.baseUrl + '/overview' + dashboardKey + '?id=' + encodeURIComponent(componentKey);
-}
-
 /**
  * Generate URL for a component's permissions page
  * @param {string} componentKey
index 185b5a6ef63236176d3e3726bcb35d4b8b03b751..4aaf6ff239ee46d4f70c2f02c9a90e11887435e0 100644 (file)
@@ -23,7 +23,7 @@ import classNames from 'classnames';
 import React from 'react';
 import LinksMixin from '../links-mixin';
 import { translate } from '../../../helpers/l10n';
-import { getComponentFixedDashboardUrl } from '../../../helpers/urls';
+import { getComponentUrl } from '../../../helpers/urls';
 
 const SETTINGS_URLS = [
   '/project/settings',
@@ -63,11 +63,11 @@ export default React.createClass({
 
   isFixedDashboardActive() {
     const path = window.location.pathname;
-    return path.indexOf(window.baseUrl + '/overview') === 0 || path.indexOf(window.baseUrl + '/governance') === 0;
+    return path.indexOf(window.baseUrl + '/dashboard') === 0 || path.indexOf(window.baseUrl + '/governance') === 0;
   },
 
-  renderOverviewLink() {
-    const url = getComponentFixedDashboardUrl(this.props.component.key, '');
+  renderDashboardLink() {
+    const url = getComponentUrl(this.props.component.key);
     const name = <i className="icon-home"/>;
     const className = classNames({ active: this.isFixedDashboardActive() });
     return (
@@ -250,7 +250,7 @@ export default React.createClass({
   render() {
     return (
         <ul className="nav navbar-nav nav-tabs">
-          {this.renderOverviewLink()}
+          {this.renderDashboardLink()}
           {this.renderComponentIssuesLink()}
           {this.renderComponentMeasuresLink()}
           {this.renderCodeLink()}
index 8a4f8635fb4575d140d9ee312820db31d8786667..08f98b294f1cadcd1054e1172c3e43b764241332 100644 (file)
@@ -50,7 +50,8 @@ class DashboardController < ApplicationController
         if Project.root_qualifiers.include?('VW') && (@resource.qualifier == 'VW' || @resource.qualifier == 'SVW')
           return redirect_to(url_for({:controller => 'governance'}) + '?id=' + url_encode(params[:id]))
         else
-          return redirect_to(url_for({:controller => 'overview'}) + '?id=' + url_encode(params[:id]))
+          @snapshot = @resource.last_snapshot
+          render :action => 'overview'
         end
       end
     else
index 21428698a0025ea5dced2c9cd32c7a2bfceb39be..c61841356929f67cdcf3ac210342cd4e6187ca0a 100644 (file)
@@ -23,9 +23,7 @@ class OverviewController < ApplicationController
   SECTION=Navigation::SECTION_RESOURCE
 
   def index
-    if Project.root_qualifiers.include?('VW') && (@resource.qualifier == 'VW' || @resource.qualifier == 'SVW')
-      return redirect_to(url_for({:controller => 'governance'}) + '?id=' + url_encode(params[:id]))
-    end
+    redirect_to "#{ApplicationController.root_context}/dashboard/?id=#{url_encode(params[:id])}"
   end
 
 end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/overview.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/overview.html.erb
new file mode 100644 (file)
index 0000000..aecf851
--- /dev/null
@@ -0,0 +1,84 @@
+<%
+   links_size = @resource.project_links.size
+
+   profiles = []
+   if @snapshot
+     qprofiles_measure = @snapshot.measure(Metric::QUALITY_PROFILES)
+     if qprofiles_measure && !qprofiles_measure.data.blank?
+       profiles = JSON.parse qprofiles_measure.data
+     end
+   end
+   profiles_size = profiles.size
+
+   is_gate_default = false
+   gate = nil
+   root = @resource.root_project
+   gate_id = Property.value('sonar.qualitygate', root.id, nil)
+   unless gate_id
+     gate_id=Property.value('sonar.qualitygate', nil, nil)
+     is_gate_default = false || gate_id
+   end
+   if gate_id
+     gate = Internal.quality_gates.get(gate_id.to_i)
+   end
+%>
+
+<%
+   if @snapshot
+     m = @snapshot.measure(Metric::QUALITY_GATE_DETAILS)
+     alert_status = @snapshot.measure(Metric::ALERT_STATUS)
+     if m && !m.data.blank?
+       details = JSON.parse m.data
+       m.alert_status = details['level']
+       raw_conditions = details['conditions']
+       conditions = []
+       raw_conditions.each do |condition|
+         if !metric(condition['metric']).nil?
+           conditions << condition
+         end
+       end
+     end
+   end
+%>
+
+<% content_for :extra_script do %>
+  <script>
+    (function () {
+      var component = {
+        id: '<%= escape_javascript @resource.uuid %>',
+        key: '<%= escape_javascript @resource.key %>',
+        description: '<%= escape_javascript @resource.description %>',
+        links: [
+          <% @resource.project_links.sort.each_with_index do |link, index| %>
+          {
+            name: '<%= escape_javascript link.name -%>',
+            type: '<%= escape_javascript link.link_type -%>',
+            href: '<%= escape_javascript link.href -%>'
+          }<% if index < links_size - 1 %>, <% end -%>
+          <% end %>
+        ],
+        profiles: [
+          <% profiles.each_with_index do |profile, index| %>
+          {
+            name: '<%= escape_javascript profile['name'] -%>',
+            key: '<%= escape_javascript profile['key']-%>',
+            language: '<%= escape_javascript Api::Utils.language_name(profile['language']) -%>'
+          }<% if index < profiles_size - 1 %>, <% end -%>
+          <% end %>
+        ],
+        <% if gate %>
+        gate: {
+          name: '<%= escape_javascript gate.getName() -%>',
+          key: <%= escape_javascript gate_id -%>,
+          isDefault: <%= is_gate_default -%>
+        }
+        <% end %>
+      };
+
+      window.sonarqube.overview = {
+        component: component
+      };
+    })();
+  </script>
+  <script src="<%= ApplicationController.root_context -%>/js/bundles/overview.js?v=<%= sonar_version -%>"></script>
+<% end %>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb
deleted file mode 100644 (file)
index aecf851..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<%
-   links_size = @resource.project_links.size
-
-   profiles = []
-   if @snapshot
-     qprofiles_measure = @snapshot.measure(Metric::QUALITY_PROFILES)
-     if qprofiles_measure && !qprofiles_measure.data.blank?
-       profiles = JSON.parse qprofiles_measure.data
-     end
-   end
-   profiles_size = profiles.size
-
-   is_gate_default = false
-   gate = nil
-   root = @resource.root_project
-   gate_id = Property.value('sonar.qualitygate', root.id, nil)
-   unless gate_id
-     gate_id=Property.value('sonar.qualitygate', nil, nil)
-     is_gate_default = false || gate_id
-   end
-   if gate_id
-     gate = Internal.quality_gates.get(gate_id.to_i)
-   end
-%>
-
-<%
-   if @snapshot
-     m = @snapshot.measure(Metric::QUALITY_GATE_DETAILS)
-     alert_status = @snapshot.measure(Metric::ALERT_STATUS)
-     if m && !m.data.blank?
-       details = JSON.parse m.data
-       m.alert_status = details['level']
-       raw_conditions = details['conditions']
-       conditions = []
-       raw_conditions.each do |condition|
-         if !metric(condition['metric']).nil?
-           conditions << condition
-         end
-       end
-     end
-   end
-%>
-
-<% content_for :extra_script do %>
-  <script>
-    (function () {
-      var component = {
-        id: '<%= escape_javascript @resource.uuid %>',
-        key: '<%= escape_javascript @resource.key %>',
-        description: '<%= escape_javascript @resource.description %>',
-        links: [
-          <% @resource.project_links.sort.each_with_index do |link, index| %>
-          {
-            name: '<%= escape_javascript link.name -%>',
-            type: '<%= escape_javascript link.link_type -%>',
-            href: '<%= escape_javascript link.href -%>'
-          }<% if index < links_size - 1 %>, <% end -%>
-          <% end %>
-        ],
-        profiles: [
-          <% profiles.each_with_index do |profile, index| %>
-          {
-            name: '<%= escape_javascript profile['name'] -%>',
-            key: '<%= escape_javascript profile['key']-%>',
-            language: '<%= escape_javascript Api::Utils.language_name(profile['language']) -%>'
-          }<% if index < profiles_size - 1 %>, <% end -%>
-          <% end %>
-        ],
-        <% if gate %>
-        gate: {
-          name: '<%= escape_javascript gate.getName() -%>',
-          key: <%= escape_javascript gate_id -%>,
-          isDefault: <%= is_gate_default -%>
-        }
-        <% end %>
-      };
-
-      window.sonarqube.overview = {
-        component: component
-      };
-    })();
-  </script>
-  <script src="<%= ApplicationController.root_context -%>/js/bundles/overview.js?v=<%= sonar_version -%>"></script>
-<% end %>