@Test
public void dashboard_extension() {
seleniumSuite("dashboard_extension",
- "/componentDashboard/DashboardTest/dashboard_extension/dashboard-should-be-registered.html",
- "/componentDashboard/DashboardTest/dashboard_extension/test-location-of-widgets.html",
-
// SSF-19
"/componentDashboard/DashboardTest/dashboard_extension/xss.html");
}
- @Test
- public void configure_dashboard() {
- seleniumSuite("configure_dashboard",
- "/componentDashboard/DashboardTest/configure_dashboard/main_dashboard.html",
- "/componentDashboard/DashboardTest/configure_dashboard/filter_widgets.html",
- "/componentDashboard/DashboardTest/configure_dashboard/keep_filter_after_adding_widget.html");
- }
-
- @Test
- public void configure_widget() {
- seleniumSuite("configure_widget",
- "/componentDashboard/DashboardTest/configure_widget/add_project_widget_with_mandatory_properties.html");
- }
-
@Test
public void global_dashboard() {
seleniumSuite("global_dashboard",
).build()).runOn(orchestrator);
}
- /**
- * SONAR-4700
- */
- @Test
- public void not_display_periods_selection_dropdown_on_first_analysis() {
- orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);
- orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "empty");
- runProjectAnalysis(orchestrator, "shared/xoo-sample");
-
- // Use old way to execute Selenium because 'assertSelectOptions' action is not supported by SeleneseTest
- orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("not-display-periods-selection-dropdown-on-first-analysis",
- "/measureHistory/DifferentialPeriodsTest/not-display-periods-selection-dropdown-on-dashboard.html"
- ).build());
-
- runProjectAnalysis(orchestrator, "shared/xoo-sample");
- orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("display-periods-selection-dropdown-after-first-analysis",
- "/measureHistory/DifferentialPeriodsTest/display-periods-selection-dropdown-on-dashboard.html"
- ).build());
- }
-
/**
* SONAR-7237
*/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/sessions/logout</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/sessions/login</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>login</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>password</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>commit</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>link=Configure widgets</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>css=#widget-filters li.selected</td>
- <td>Any</td>
-</tr>
-<tr>
- <td>assertVisible</td>
- <td>def_hotspotmetric</td>
- <td></td>
-</tr>
-<tr>
- <td>assertVisible</td>
- <td>def_complexity</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>id=widget-filter-Hotspots</td>
- <td></td>
-</tr>
-<tr>
- <td>assertVisible</td>
- <td>def_hotspotmetric</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementNotPresent</td>
- <td>def_complexity</td>
- <td></td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/sessions/logout</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/sessions/login</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>login</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>password</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>commit</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>link=Configure widgets</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVisible</td>
- <td>id=add-widget-complexity</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>id=widget-filter-Hotspots</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementNotPresent</td>
- <td>id=add-widget-complexity</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>add-widget-hotspot_metric</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>css=#widget-filters li.selected</td>
- <td>glob:*Hotspots*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPresent</td>
- <td>dashboard</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPresent</td>
- <td>dashboard-column-1</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementPresent</td>
- <td>dashboard-column-2</td>
- <td></td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>add_project_widget_with_mandatory_properties</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">add_project_widget_with_mandatory_properties</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/sessions/new</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>id=login</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>id=password</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>name=commit</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>link=Configure widgets</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>id=add-widget-widget-with-mandatory-properties</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard-column-1</td>
- <td>*Widget with Mandatory Properties*</td>
-</tr>
-<tr>
- <td>type</td>
- <td>id=mandatoryString</td>
- <td>hello</td>
-</tr>
-<tr>
- <td>type</td>
- <td>id=mandatoryInt</td>
- <td>123</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>name=commit</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard-column-1</td>
- <td>*Widget with Mandatory Properties*</td>
-</tr>
-<tr>
- <td>assertNotVisible</td>
- <td>name=commit</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard-column-1</td>
- <td>*mandatoryString*hello*mandatoryInt*123*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>dashboard-should-be-registered</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">dashboard-should-be-registered</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index/sample?name=Fake</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>link=Fake</td>
- <td></td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">should-display-widgets-according-to-required-measures</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>
- /dashboard/index/sample:src/main/xoo/sample?name=RequiredMeasuresWidgetsDashboard
- </td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*WidgetMandatoryAndOneOfSatisfied*WidgetMandatorySatisfied*WidgetNoConstraints*WidgetOneOfSatisfied*</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index/sample?name=Fake</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementPresent</td>
- <td>dashboard-column-1</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementPresent</td>
- <td>dashboard-column-2</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementNotPresent</td>
- <td>dashboard-column-3</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementPresent</td>
- <td>css=#dashboard-column-1 .description</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementPresent</td>
- <td>css=#dashboard-column-2 .documentation_comments</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementNotPresent</td>
- <td>css=.complexity</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>display-added-files</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">should_display_added_files_in_differential_drilldown</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Time changes*</td>
-</tr>
-<tr>
- <td>assertSelectOptions</td>
- <td>select-comparison</td>
- <td>*since previous analysis*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>display-added-files</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">should_display_added_files_in_differential_drilldown</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index?id=sample&name=Custom</td>
- <td></td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>dashboard</td>
- <td>*Time changes*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>should-display-timemachine-dashboard</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">should-display-timemachine-dashboard</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/dashboard/index/sample?name=TimeMachine</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Complexity: 3*Technical Debt: 0*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Sep 01 2012*0.7*Nov 30 2012*0.9*Dec 31 2012*1.0-SNAPSHOT*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Lines of Code*Lines*Statements*Files*Classes*Functions*Accessors*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Comments*Comment lines*Public documented API*Public undocumented API*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Duplicated lines (%)*Duplicated lines*Duplicated blocks*Duplicated files*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Issues*Blocker issues*Critical issues*Major issues*Minor issues*Technical Debt*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Complexity*Complexity /function*Complexity /class*Complexity /file*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>dashboard</td>
- <td>*Coverage*Line coverage*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
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',
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"/>;
);
},
- 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')}
- <i className="icon-dropdown"/>
- </a>
- <ul className="dropdown-menu">
- {dashboards}
- </ul>
- </li>;
- },
-
renderCodeLink() {
if (this.isDeveloper()) {
return null;
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;
},
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>
+ );
}
});
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]
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}
@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
@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
@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