diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-04-07 10:46:28 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-04-07 13:33:29 +0200 |
commit | f000dcc41b8171cfbf5576efa81311efecfbd16c (patch) | |
tree | b942f9c4f6063964fd7371503095f96e09df2e4b /server/sonar-web/src/main/js | |
parent | a2be8c1b0c660f10b2e86ac046af3cfaea61214d (diff) | |
download | sonarqube-f000dcc41b8171cfbf5576efa81311efecfbd16c.tar.gz sonarqube-f000dcc41b8171cfbf5576efa81311efecfbd16c.zip |
SONAR-7402 do not display differential values
Diffstat (limited to 'server/sonar-web/src/main/js')
3 files changed, 54 insertions, 26 deletions
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 3020d94a017..6cd66b88a81 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 @@ -22,15 +22,13 @@ import React from 'react'; import Measure from './../components/Measure'; import LanguageDistribution from './../components/LanguageDistribution'; import { ComplexityDistribution } from '../../overview/components/complexity-distribution'; -import { formatLeak } from '../utils'; +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); - const displayLeak = measure.leak != null && metric.type !== 'RATING' && metric.type !== 'LEVEL'; - return ( <header className="measure-details-header"> <h2 className="measure-details-metric"> @@ -39,19 +37,18 @@ export default function MeasureDetailsHeader ({ measure, metric, secondaryMeasur <TooltipsContainer options={{ html: false }}> <div className="measure-details-value"> - {measure.value != null && ( - <div className="measure-details-value-absolute"> - <Measure measure={measure} metric={metric}/> - </div> - )} - {displayLeak && ( + {isDiffMetric(metric) ? ( <div className="measure-details-value-leak" title={leakPeriodTooltip} data-toggle="tooltip"> {formatLeak(measure.leak, metric)} </div> + ) : ( + <div className="measure-details-value-absolute"> + <Measure measure={measure} metric={metric}/> + </div> )} {secondaryMeasure && secondaryMeasure.metric === 'ncloc_language_distribution' && ( diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js b/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js new file mode 100644 index 00000000000..f53460afbd1 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.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 Measure from '../components/Measure'; +import { isDiffMetric } from '../utils'; +import { formatMeasure } from '../../../helpers/measures'; + +const MeasureListValue = ({ measure }) => { + const { metric } = measure; + + if (isDiffMetric(metric)) { + return ( + <div id={`measure-${measure.metric.key}-leak`} className="domain-measures-value domain-measures-leak"> + {formatMeasure(measure.leak, measure.metric.key)} + </div> + ); + } + + return ( + <div id={`measure-${measure.metric.key}-value`} className="domain-measures-value"> + <Measure measure={measure}/> + </div> + ); +}; + +export default MeasureListValue; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js b/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js index 672503056a5..399923a915b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js @@ -21,14 +21,13 @@ import React from 'react'; import { Link } from 'react-router'; import classNames from 'classnames'; -import Measure from '../components/Measure'; -import { formatLeak } from '../utils'; +import MeasureListValue from './MeasureListValue'; const shouldPutSpace = (spaces, measure, index) => { return index !== 0 && spaces.includes(measure.metric.key); }; -const MeasuresList = ({ measures, hasLeak, component, spaces }) => { +const MeasuresList = ({ measures, component, spaces }) => { return ( <ul className="domain-measures"> {measures.map((measure, index) => ( @@ -42,20 +41,8 @@ const MeasuresList = ({ measures, hasLeak, component, spaces }) => { {measure.metric.name} </span> </div> - <div className="domain-measures-value"> - {measure.value != null && ( - <span id={`measure-${measure.metric.key}-value`}> - <Measure measure={measure}/> - </span> - )} - </div> - {hasLeak && measure.leak != null && measure.metric.type !== 'RATING' && ( - <div className="domain-measures-value domain-measures-leak"> - <span id={`measure-${measure.metric.key}-leak`}> - {formatLeak(measure.leak, measure.metric)} - </span> - </div> - )} + + <MeasureListValue measure={measure}/> </Link> </li> ))} |