aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-07-22 16:00:24 +0200
committerStas Vilchik <vilchiks@gmail.com>2016-07-25 13:47:25 +0200
commit2e5714882049f344a6c9a295eccba35152553170 (patch)
treea3e367bc6e6bec2ade99858f773dc8381434f200 /server/sonar-web
parent2e0c8fc8d35b3baf8b116baf51d08ddee3b72fd8 (diff)
downloadsonarqube-2e5714882049f344a6c9a295eccba35152553170.tar.gz
sonarqube-2e5714882049f344a6c9a295eccba35152553170.zip
SONAR-7915 Drop project level dashboards
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js91
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb89
2 files changed, 41 insertions, 139 deletions
diff --git a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
index 3028759fe08..185b5a6ef63 100644
--- a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
+++ b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
@@ -22,11 +22,8 @@ import _ from 'underscore';
import classNames from 'classnames';
import React from 'react';
import LinksMixin from '../links-mixin';
-import { translate, getLocalizedDashboardName } from '../../../helpers/l10n';
-import {
- getComponentDashboardUrl,
- getComponentFixedDashboardUrl
-} from '../../../helpers/urls';
+import { translate } from '../../../helpers/l10n';
+import { getComponentFixedDashboardUrl } from '../../../helpers/urls';
const SETTINGS_URLS = [
'/project/settings',
@@ -69,23 +66,6 @@ export default React.createClass({
return path.indexOf(window.baseUrl + '/overview') === 0 || path.indexOf(window.baseUrl + '/governance') === 0;
},
- isCustomDashboardActive(customDashboard) {
- const path = window.location.pathname;
- const params = qs.parse(window.location.search.substr(1));
- return path.indexOf(window.baseUrl + '/dashboard') === 0 && params.did === `${customDashboard.key}`;
- },
-
- isCustomDashboardsActive () {
- const dashboards = this.props.component.dashboards;
- return _.any(dashboards, this.isCustomDashboardActive) ||
- this.isDefaultDeveloperDashboardActive();
- },
-
- isDefaultDeveloperDashboardActive() {
- const path = window.location.pathname;
- return this.isDeveloper() && path.indexOf(window.baseUrl + '/dashboard') === 0;
- },
-
renderOverviewLink() {
const url = getComponentFixedDashboardUrl(this.props.component.key, '');
const name = <i className="icon-home"/>;
@@ -97,30 +77,6 @@ export default React.createClass({
);
},
- renderCustomDashboard(customDashboard) {
- const key = 'custom-dashboard-' + customDashboard.key;
- const url = getComponentDashboardUrl(this.props.component.key, customDashboard.key, this.getPeriod());
- const name = getLocalizedDashboardName(customDashboard.name);
- const className = classNames({ active: this.isCustomDashboardActive(customDashboard) });
- return <li key={key} className={className}>
- <a href={url}>{name}</a>
- </li>;
- },
-
- renderCustomDashboards() {
- const dashboards = this.props.component.dashboards.map(this.renderCustomDashboard);
- const className = classNames('dropdown', { active: this.isCustomDashboardsActive() });
- return <li className={className}>
- <a className="dropdown-toggle" data-toggle="dropdown" href="#">
- {translate('layout.dashboards')}&nbsp;
- <i className="icon-dropdown"/>
- </a>
- <ul className="dropdown-menu">
- {dashboards}
- </ul>
- </li>;
- },
-
renderCodeLink() {
if (this.isDeveloper()) {
return null;
@@ -265,17 +221,14 @@ export default React.createClass({
renderExtensions() {
const extensions = this.props.conf.extensions || [];
- return extensions.map(e => {
- return this.renderLink(e.url, e.name, e.url);
- });
+ return extensions.map(e => this.renderLink(e.url, e.name, e.url));
},
renderTools() {
const extensions = this.props.component.extensions || [];
const withoutGovernance = extensions.filter(ext => ext.name !== 'Governance');
- const tools = withoutGovernance.map(extension => {
- return this.renderLink(extension.url, extension.name);
- });
+ const tools = withoutGovernance
+ .map(extension => this.renderLink(extension.url, extension.name));
if (!tools.length) {
return null;
@@ -295,29 +248,15 @@ export default React.createClass({
},
render() {
- if (this.isDeveloper()) {
- return (
- <ul className="nav navbar-nav nav-tabs">
- {this.renderCustomDashboards()}
- {this.renderComponentIssuesLink()}
- {this.renderComponentMeasuresLink()}
- {this.renderCodeLink()}
- {this.renderTools()}
- {this.renderAdministration()}
- </ul>
- );
- } else {
- return (
- <ul className="nav navbar-nav nav-tabs">
- {this.renderOverviewLink()}
- {this.renderComponentIssuesLink()}
- {this.renderComponentMeasuresLink()}
- {this.renderCodeLink()}
- {this.renderCustomDashboards()}
- {this.renderTools()}
- {this.renderAdministration()}
- </ul>
- );
- }
+ return (
+ <ul className="nav navbar-nav nav-tabs">
+ {this.renderOverviewLink()}
+ {this.renderComponentIssuesLink()}
+ {this.renderComponentMeasuresLink()}
+ {this.renderCodeLink()}
+ {this.renderTools()}
+ {this.renderAdministration()}
+ </ul>
+ );
}
});
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
index b33e5c9ecd6..8a4f8635fb4 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
@@ -25,46 +25,41 @@ class DashboardController < ApplicationController
before_filter :login_required, :except => [:index]
def index
- load_resource()
- if !@resource || @resource.display_dashboard?
- if params[:id]
- unless @resource
- return project_not_found
- end
- unless @snapshot
- return project_not_analyzed
- end
- end
+ if params[:id]
+ @resource = Project.by_key(params[:id])
+ return project_not_found unless @resource
+ @resource = @resource.permanent_resource
- # redirect to the project overview
- if params[:id] && !params[:did] && !params[:name] && @resource.qualifier != 'DEV'
- # if governance plugin is installed and we are opening a view
- 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]))
- end
- end
+ access_denied unless has_role?(:user, @resource)
- load_dashboard()
- load_authorized_widget_definitions()
+ # for backward compatibility with old widgets
+ @project = @resource
+
+ # if file
+ if !@resource.display_dashboard?
+ @snapshot = @resource.last_snapshot
+ return project_not_analyzed unless @snapshot
+ @hide_sidebar = true
+ @file = @resource
+ @project = @resource.root_project
+ @metric=params[:metric]
+ render :action => 'no_dashboard'
else
- if !@resource || !@snapshot
- redirect_if_bad_component()
+ # it is a project dashboard
+ # if governance plugin is installed and we are opening a view
+ 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
- # display the layout of the parent without the sidebar, usually the directory, but display the file viewers
- @hide_sidebar = true
- @file = @resource
- @project = @resource.root_project
- @metric=params[:metric]
- render :action => 'no_dashboard'
+ return redirect_to(url_for({:controller => 'overview'}) + '?id=' + url_encode(params[:id]))
+ end
end
+ else
+ load_dashboard()
+ load_authorized_widget_definitions()
end
end
def configure
- load_resource()
- redirect_if_bad_component()
load_dashboard()
@category=params[:category]
@@ -159,8 +154,6 @@ class DashboardController < ApplicationController
def widget_definitions
@category=params[:category]
- load_resource()
- # redirect_if_bad_component()
load_dashboard()
load_widget_definitions(@category)
render :partial => 'widget_definitions', :locals => {:category => @category}
@@ -177,8 +170,6 @@ class DashboardController < ApplicationController
@dashboard=Dashboard.first(:conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id])
elsif params[:name]
@dashboard=Dashboard.first(:conditions => ['name=? AND user_id=?', params[:name], current_user.id])
- elsif params[:id]
- active=ActiveDashboard.user_dashboards(current_user, false).first
else
active=ActiveDashboard.user_dashboards(current_user, true).first
end
@@ -190,8 +181,6 @@ class DashboardController < ApplicationController
@dashboard=Dashboard.first(:conditions => ['id=? AND shared=?', params[:did].to_i, true])
elsif params[:name]
@dashboard=Dashboard.first(:conditions => ['name=? AND shared=?', params[:name], true])
- elsif params[:id]
- active=ActiveDashboard.user_dashboards(nil, false).first
else
active=ActiveDashboard.user_dashboards(nil, true).first
end
@@ -206,32 +195,6 @@ class DashboardController < ApplicationController
@dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period], :snapshot => @snapshot) if @dashboard && @snapshot
end
- def load_resource
- if params[:id]
- @resource = Project.by_key(params[:id])
- return unless @resource
- @resource=@resource.permanent_resource
-
- @snapshot=@resource.last_snapshot
- return unless @snapshot
-
- access_denied unless has_role?(:user, @resource)
-
- @project=@resource # for backward compatibility with old widgets
- end
- end
-
- def redirect_if_bad_component
- if params[:id]
- unless @resource
- return project_not_found
- end
- unless @snapshot
- project_not_analyzed
- end
- end
- end
-
def project_not_found
flash[:error] = message('dashboard.project_not_found')
redirect_to :action => :index