]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7402 do not display differential values
authorStas Vilchik <vilchiks@gmail.com>
Thu, 7 Apr 2016 08:46:28 +0000 (10:46 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 7 Apr 2016 11:33:29 +0000 (13:33 +0200)
it/it-tests/src/test/resources/measure/ProjectMeasuresPageTest/should_display_measures_page.html
server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsHeader.js
server/sonar-web/src/main/js/apps/component-measures/home/MeasureListValue.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/component-measures/home/MeasuresList.js

index 52c94cb562f9afc510c73cab9b9f8162c7296ecb..4c5a77a95450dc065aacff4d853f59424e9c760c 100644 (file)
@@ -25,8 +25,8 @@
 </tr>
 <tr>
        <td>assertText</td>
-       <td>id=measure-code_smells-leak</td>
-       <td>*+0*</td>
+       <td>id=measure-new_code_smells-leak</td>
+       <td>*0*</td>
 </tr>
 <tr>
        <td>click</td>
index 3020d94a01707a3f8d9e569570dff9343c79f2b5..6cd66b88a81e5356700350c8b00d3fe3d532374d 100644 (file)
@@ -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 (file)
index 0000000..f53460a
--- /dev/null
@@ -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;
index 672503056a51a46ce1011852a741c5fe8af786c1..399923a915b785ba2f8aaf72eeb50530d668d909 100644 (file)
@@ -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>
         ))}