--- /dev/null
+/*
+ * 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;
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 {
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 (
measure={measure}
metric={metric}
secondaryMeasure={secondaryMeasure}
- leakPeriodLabel={periodLabel}/>
+ leakPeriod={period}/>
{measure && (
<MeasureDrilldown
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>
) : (
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 () {
return null;
}
- const leakPeriodLabel = getLeakPeriodLabel(periods);
+ const leakPeriod = getLeakPeriod(periods);
return (
<section id="component-measures-home" className="page page-container page-limited">
</ul>
</nav>
- {leakPeriodLabel != null && (
- <div className="measures-domains-leak-header">
- {translateWithParameters('overview.leak_period_x', leakPeriodLabel)}
- </div>
+ {leakPeriod != null && (
+ <LeakPeriodLegend period={leakPeriod}/>
)}
</header>
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());
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);
}
.measure-details-metric {
+ display: inline-block;
margin-bottom: 10px;
}