aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/component-measures
diff options
context:
space:
mode:
authorJenkins CI <ci@sonarsource.com>2016-04-20 08:01:02 +0200
committerJenkins CI <ci@sonarsource.com>2016-04-20 08:01:02 +0200
commit362dc21e8ddf12243daf57099746b37dfad9d4ec (patch)
tree022256a88b874483bb3c9bb8e96eda1009235681 /server/sonar-web/src/main/js/apps/component-measures
parent5aee70243909bfb14772f3c24ccc707e6ce47ea1 (diff)
parentc2412a35e2fed2ffba40825d335d72b0c66ee818 (diff)
downloadsonarqube-362dc21e8ddf12243daf57099746b37dfad9d4ec.tar.gz
sonarqube-362dc21e8ddf12243daf57099746b37dfad9d4ec.zip
Automatic merge from branch-5.5
* origin/branch-5.5: SONAR-7550 Update Java plugin to 3.13.1 apply feedback for measures page (#905) change capitalization of new metrics (#906) Background tasks logs are available for project admin add web context on the measures page Add comment on query to keep authorized users for a project and a role
Diffstat (limited to 'server/sonar-web/src/main/js/apps/component-measures')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js44
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js17
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/home/Home.js13
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/home/actions.js9
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/styles.css1
7 files changed, 71 insertions, 20 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/app.js b/server/sonar-web/src/main/js/apps/component-measures/app.js
index 264b835b95e..230a10f092a 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/app.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/app.js
@@ -43,7 +43,7 @@ window.sonarqube.appStarted.then(options => {
const el = document.querySelector(options.el);
const history = useRouterHistory(createHistory)({
- basename: '/component_measures'
+ basename: window.baseUrl + '/component_measures'
});
const store = configureStore({
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js
new file mode 100644
index 00000000000..ae760d3a0a5
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.js
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import React from 'react';
+import moment from 'moment';
+
+import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
+import { getPeriodLabel, getPeriodDate } from '../../../helpers/periods';
+import { translateWithParameters } from '../../../helpers/l10n';
+
+const LeakPeriodLegend = ({ period }) => {
+ const date = getPeriodDate(period);
+ const label = getPeriodLabel(period);
+ const fromNow = moment(date).fromNow();
+ const tooltip = fromNow + ', ' + moment(date).format('LL');
+
+ return (
+ <TooltipsContainer>
+ <div className="measures-domains-leak-header">
+ <div title={tooltip} data-toggle="tooltip">
+ {translateWithParameters('overview.leak_period_x', label)}
+ </div>
+ </div>
+ </TooltipsContainer>
+ );
+};
+
+export default LeakPeriodLegend;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js
index d91eb5d2fbb..dcdeb048921 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetails.js
@@ -23,7 +23,7 @@ import { Link, IndexLink } from 'react-router';
import Spinner from './../components/Spinner';
import MeasureDetailsHeader from './MeasureDetailsHeader';
import MeasureDrilldown from './drilldown/MeasureDrilldown';
-import { getPeriod, getPeriodDate, getPeriodLabel } from '../../../helpers/periods';
+import { getPeriod, getPeriodDate } from '../../../helpers/periods';
import { translate, translateWithParameters } from '../../../helpers/l10n';
export default class MeasureDetails extends React.Component {
@@ -65,7 +65,6 @@ export default class MeasureDetails extends React.Component {
const { tab } = this.props.params;
const periodIndex = this.props.location.query.period || 1;
const period = getPeriod(periods, Number(periodIndex));
- const periodLabel = getPeriodLabel(period);
const periodDate = getPeriodDate(period);
return (
@@ -89,7 +88,7 @@ export default class MeasureDetails extends React.Component {
measure={measure}
metric={metric}
secondaryMeasure={secondaryMeasure}
- leakPeriodLabel={periodLabel}/>
+ leakPeriod={period}/>
{measure && (
<MeasureDrilldown
diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js
index 6cd66b88a81..bc0d5a5f31b 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js
@@ -21,28 +21,29 @@ import React from 'react';
import Measure from './../components/Measure';
import LanguageDistribution from './../components/LanguageDistribution';
+import LeakPeriodLegend from '../components/LeakPeriodLegend';
import { ComplexityDistribution } from '../../overview/components/complexity-distribution';
import { isDiffMetric, formatLeak } from '../utils';
-import { translateWithParameters } from '../../../helpers/l10n';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
-export default function MeasureDetailsHeader ({ measure, metric, secondaryMeasure, leakPeriodLabel }) {
- const leakPeriodTooltip = translateWithParameters('overview.leak_period_x', leakPeriodLabel);
-
+export default function MeasureDetailsHeader ({ measure, metric, secondaryMeasure, leakPeriod }) {
return (
<header className="measure-details-header">
<h2 className="measure-details-metric">
{metric.name}
</h2>
+ {isDiffMetric(metric) && (
+ <div className="pull-right">
+ <LeakPeriodLegend period={leakPeriod}/>
+ </div>
+ )}
+
<TooltipsContainer options={{ html: false }}>
<div className="measure-details-value">
{isDiffMetric(metric) ? (
- <div
- className="measure-details-value-leak"
- title={leakPeriodTooltip}
- data-toggle="tooltip">
+ <div className="measure-details-value-leak">
{formatLeak(measure.leak, metric)}
</div>
) : (
diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/Home.js b/server/sonar-web/src/main/js/apps/component-measures/home/Home.js
index 084d75fc0c9..a68619568c1 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/home/Home.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/home/Home.js
@@ -20,8 +20,9 @@
import React from 'react';
import { Link, IndexLink } from 'react-router';
-import { getLeakPeriodLabel } from '../../../helpers/periods';
-import { translate, translateWithParameters } from '../../../helpers/l10n';
+import LeakPeriodLegend from '../components/LeakPeriodLegend';
+import { getLeakPeriod } from '../../../helpers/periods';
+import { translate } from '../../../helpers/l10n';
export default class Home extends React.Component {
componentDidMount () {
@@ -41,7 +42,7 @@ export default class Home extends React.Component {
return null;
}
- const leakPeriodLabel = getLeakPeriodLabel(periods);
+ const leakPeriod = getLeakPeriod(periods);
return (
<section id="component-measures-home" className="page page-container page-limited">
@@ -67,10 +68,8 @@ export default class Home extends React.Component {
</ul>
</nav>
- {leakPeriodLabel != null && (
- <div className="measures-domains-leak-header">
- {translateWithParameters('overview.leak_period_x', leakPeriodLabel)}
- </div>
+ {leakPeriod != null && (
+ <LeakPeriodLegend period={leakPeriod}/>
)}
</header>
diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/actions.js b/server/sonar-web/src/main/js/apps/component-measures/home/actions.js
index 542e2207cb4..31a9309c900 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/home/actions.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/home/actions.js
@@ -28,6 +28,13 @@ export function receiveMeasures (measures, periods) {
return { type: RECEIVE_MEASURES, measures, periods };
}
+function banQualityGate (component, measures) {
+ if (['VW', 'SVW'].includes(component.qualifier)) {
+ return measures;
+ }
+ return measures.filter(measure => measure.metric !== 'alert_status');
+}
+
export function fetchMeasures () {
return (dispatch, getState) => {
dispatch(startFetching());
@@ -40,7 +47,7 @@ export function fetchMeasures () {
getMeasuresAndMeta(component.key, metricKeys, { additionalFields: 'periods' }).then(r => {
const leakPeriod = getLeakPeriod(r.periods);
- const measures = r.component.measures
+ const measures = banQualityGate(component, r.component.measures)
.map(measure => {
const metric = metrics.find(metric => metric.key === measure.metric);
const leak = getLeakValue(measure);
diff --git a/server/sonar-web/src/main/js/apps/component-measures/styles.css b/server/sonar-web/src/main/js/apps/component-measures/styles.css
index b0adf4f3527..092f62a8fba 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/styles.css
+++ b/server/sonar-web/src/main/js/apps/component-measures/styles.css
@@ -131,6 +131,7 @@
}
.measure-details-metric {
+ display: inline-block;
margin-bottom: 10px;
}