From f000dcc41b8171cfbf5576efa81311efecfbd16c Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 7 Apr 2016 10:46:28 +0200 Subject: [PATCH] SONAR-7402 do not display differential values --- .../should_display_measures_page.html | 4 +- .../details/MeasureDetailsHeader.js | 15 +++---- .../home/MeasureListValue.js | 44 +++++++++++++++++++ .../component-measures/home/MeasuresList.js | 21 ++------- 4 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js diff --git a/it/it-tests/src/test/resources/measure/ProjectMeasuresPageTest/should_display_measures_page.html b/it/it-tests/src/test/resources/measure/ProjectMeasuresPageTest/should_display_measures_page.html index 52c94cb562f..4c5a77a9545 100644 --- a/it/it-tests/src/test/resources/measure/ProjectMeasuresPageTest/should_display_measures_page.html +++ b/it/it-tests/src/test/resources/measure/ProjectMeasuresPageTest/should_display_measures_page.html @@ -25,8 +25,8 @@ assertText - id=measure-code_smells-leak - *+0* + id=measure-new_code_smells-leak + *0* click 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 (

@@ -39,19 +37,18 @@ export default function MeasureDetailsHeader ({ measure, metric, secondaryMeasur
- {measure.value != null && ( -
- -
- )} - {displayLeak && ( + {isDiffMetric(metric) ? (
{formatLeak(measure.leak, metric)}
+ ) : ( +
+ +
)} {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 ( +
+ {formatMeasure(measure.leak, measure.metric.key)} +
+ ); + } + + return ( +
+ +
+ ); +}; + +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 (
    {measures.map((measure, index) => ( @@ -42,20 +41,8 @@ const MeasuresList = ({ measures, hasLeak, component, spaces }) => { {measure.metric.name}
-
- {measure.value != null && ( - - - - )} -
- {hasLeak && measure.leak != null && measure.metric.type !== 'RATING' && ( -
- - {formatLeak(measure.leak, measure.metric)} - -
- )} + + ))} -- 2.39.5