]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9599 change issues measures on the projects page
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 28 Sep 2017 14:17:18 +0000 (16:17 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 2 Oct 2017 13:12:06 +0000 (15:12 +0200)
13 files changed:
server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.tsx
server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx
server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx
server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardLeakMeasures-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx
server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx
server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/MaintainabilityFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/ReliabilityFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SecurityFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/styles.css
server/sonar-web/src/main/js/apps/projects/utils.ts

index 47652952ec26c7972215f3c7762c1665814fb57d..a08b77c99975b7feead1566e17d1251fa466eca0 100644 (file)
@@ -119,7 +119,7 @@ export default function ProjectCardLeakMeasures({ measures }: Props) {
         </div>
       </div>
 
-      <div className="project-card-measure smaller-card pull-right" data-key="new_lines">
+      <div className="project-card-measure smaller-card project-card-ncloc" data-key="new_lines">
         <div className="project-card-measure-inner">
           <div className="project-card-measure-number">
             <Measure
index d0ef2f047cead292deaef4ef620dff69e657d76b..cdb325a02dde4a35eda2a2a416be5fe26338f63e 100644 (file)
@@ -25,6 +25,9 @@ import CoverageRating from '../../../components/ui/CoverageRating';
 import DuplicationsRating from '../../../components/ui/DuplicationsRating';
 import SizeRating from '../../../components/ui/SizeRating';
 import { translate } from '../../../helpers/l10n';
+import BugIcon from '../../../components/icons-components/BugIcon';
+import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon';
+import VulnerabilityIcon from '../../../components/icons-components/VulnerabilityIcon';
 
 interface Props {
   measures: { [key: string]: string | undefined };
@@ -40,28 +43,56 @@ export default function ProjectCardOverallMeasures({ measures }: Props) {
       <div className="project-card-measure smaller-card" data-key="reliability_rating">
         <div className="project-card-measure-inner">
           <div className="project-card-measure-number">
+            <Measure
+              className="spacer-right"
+              measure={{
+                metric: { key: 'bugs', type: 'SHORT_INT' },
+                value: measures['bugs']
+              }}
+            />
             <Rating value={measures['reliability_rating']} />
           </div>
-          <div className="project-card-measure-label">{translate('metric_domain.Reliability')}</div>
+          <div className="project-card-measure-label-with-icon">
+            <BugIcon className="little-spacer-right vertical-bottom" />
+            {translate('metric.bugs.name')}
+          </div>
         </div>
       </div>
 
-      <div className="project-card-measure smaller-card" data-key="security_rating">
+      <div className="project-card-measure" data-key="security_rating">
         <div className="project-card-measure-inner">
           <div className="project-card-measure-number">
+            <Measure
+              className="spacer-right"
+              measure={{
+                metric: { key: 'vulnerabilities', type: 'SHORT_INT' },
+                value: measures['vulnerabilities']
+              }}
+            />
             <Rating value={measures['security_rating']} />
           </div>
-          <div className="project-card-measure-label">{translate('metric_domain.Security')}</div>
+          <div className="project-card-measure-label-with-icon">
+            <VulnerabilityIcon className="little-spacer-right vertical-bottom" />
+            {translate('metric.vulnerabilities.name')}
+          </div>
         </div>
       </div>
 
       <div className="project-card-measure" data-key="sqale_rating">
         <div className="project-card-measure-inner">
           <div className="project-card-measure-number">
+            <Measure
+              className="spacer-right"
+              measure={{
+                metric: { key: 'code_smells', type: 'SHORT_INT' },
+                value: measures['code_smells']
+              }}
+            />
             <Rating value={measures['sqale_rating']} />
           </div>
-          <div className="project-card-measure-label">
-            {translate('metric_domain.Maintainability')}
+          <div className="project-card-measure-label-with-icon">
+            <CodeSmellIcon className="little-spacer-right vertical-bottom" />
+            {translate('metric.code_smells.name')}
           </div>
         </div>
       </div>
@@ -107,7 +138,7 @@ export default function ProjectCardOverallMeasures({ measures }: Props) {
       </div>
 
       {measures['ncloc'] != null && (
-        <div className="project-card-measure pull-right" data-key="ncloc">
+        <div className="project-card-measure project-card-ncloc" data-key="ncloc">
           <div className="project-card-measure-inner pull-right">
             <div className="project-card-measure-number">
               <span className="spacer-right">
index ef032d7568faa7f06f93ab50590aed08596d1530..6ac1cc680cba28c4dd40be31586241ed6e6785df 100644 (file)
@@ -24,12 +24,15 @@ import ProjectCardOverallMeasures from '../ProjectCardOverallMeasures';
 it('should render correctly with all data', () => {
   const measures = {
     alert_status: 'ERROR',
+    bugs: '17',
+    code_smells: '132',
     coverage: '88.3',
     duplicated_lines_density: '9.8',
     ncloc: '2053',
     reliability_rating: '1.0',
     security_rating: '1.0',
-    sqale_rating: '1.0'
+    sqale_rating: '1.0',
+    vulnerabilities: '0'
   };
   const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
   expect(wrapper).toMatchSnapshot();
@@ -38,11 +41,14 @@ it('should render correctly with all data', () => {
 it('should not render coverage', () => {
   const measures = {
     alert_status: 'ERROR',
+    bugs: '17',
+    code_smells: '132',
     duplicated_lines_density: '9.8',
     ncloc: '2053',
     reliability_rating: '1.0',
     security_rating: '1.0',
-    sqale_rating: '1.0'
+    sqale_rating: '1.0',
+    vulnerabilities: '0'
   };
   const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
   expect(wrapper.find('[data-key="coverage"]')).toMatchSnapshot();
@@ -51,11 +57,14 @@ it('should not render coverage', () => {
 it('should not render duplications', () => {
   const measures = {
     alert_status: 'ERROR',
+    bugs: '17',
+    code_smells: '132',
     coverage: '88.3',
     ncloc: '2053',
     reliability_rating: '1.0',
     security_rating: '1.0',
-    sqale_rating: '1.0'
+    sqale_rating: '1.0',
+    vulnerabilities: '0'
   };
   const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
   expect(wrapper.find('[data-key="duplicated_lines_density"]')).toMatchSnapshot();
@@ -64,11 +73,14 @@ it('should not render duplications', () => {
 it('should not render ncloc', () => {
   const measures = {
     alert_status: 'ERROR',
+    bugs: '17',
+    code_smells: '132',
     coverage: '88.3',
     duplicated_lines_density: '9.8',
     reliability_rating: '1.0',
     security_rating: '1.0',
-    sqale_rating: '1.0'
+    sqale_rating: '1.0',
+    vulnerabilities: '0'
   };
   const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
   expect(wrapper.find('[data-key="ncloc"]').length).toBe(0);
@@ -77,12 +89,15 @@ it('should not render ncloc', () => {
 it('should render ncloc correctly', () => {
   const measures = {
     alert_status: 'ERROR',
+    bugs: '17',
+    code_smells: '132',
     coverage: '88.3',
     ncloc: '16549887',
     duplicated_lines_density: '9.8',
     reliability_rating: '1.0',
     security_rating: '1.0',
-    sqale_rating: '1.0'
+    sqale_rating: '1.0',
+    vulnerabilities: '0'
   };
   const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
   expect(wrapper.find('[data-key="ncloc"]')).toMatchSnapshot();
index 9d82c53b036ff745293aae2855e1ec37ce3355c8..0ccdace41b14095d4c805a5ed98719fe3136b77f 100644 (file)
@@ -171,7 +171,7 @@ exports[`should render correctly with all data 1`] = `
     </div>
   </div>
   <div
-    className="project-card-measure smaller-card pull-right"
+    className="project-card-measure smaller-card project-card-ncloc"
     data-key="new_lines"
   >
     <div
@@ -373,7 +373,7 @@ exports[`should render no data style new coverage, new duplications and new line
     </div>
   </div>
   <div
-    className="project-card-measure smaller-card pull-right"
+    className="project-card-measure smaller-card project-card-ncloc"
     data-key="new_lines"
   >
     <div
index 341a634b69a3838173964f5cbf7be3a8f73e99c8..c9e88821373006d69583eec9ad4df7433fe61729 100644 (file)
@@ -78,19 +78,34 @@ exports[`should render correctly with all data 1`] = `
       <div
         className="project-card-measure-number"
       >
+        <Measure
+          className="spacer-right"
+          measure={
+            Object {
+              "metric": Object {
+                "key": "bugs",
+                "type": "SHORT_INT",
+              },
+              "value": "17",
+            }
+          }
+        />
         <Rating
           value="1.0"
         />
       </div>
       <div
-        className="project-card-measure-label"
+        className="project-card-measure-label-with-icon"
       >
-        metric_domain.Reliability
+        <BugIcon
+          className="little-spacer-right vertical-bottom"
+        />
+        metric.bugs.name
       </div>
     </div>
   </div>
   <div
-    className="project-card-measure smaller-card"
+    className="project-card-measure"
     data-key="security_rating"
   >
     <div
@@ -99,14 +114,29 @@ exports[`should render correctly with all data 1`] = `
       <div
         className="project-card-measure-number"
       >
+        <Measure
+          className="spacer-right"
+          measure={
+            Object {
+              "metric": Object {
+                "key": "vulnerabilities",
+                "type": "SHORT_INT",
+              },
+              "value": "0",
+            }
+          }
+        />
         <Rating
           value="1.0"
         />
       </div>
       <div
-        className="project-card-measure-label"
+        className="project-card-measure-label-with-icon"
       >
-        metric_domain.Security
+        <VulnerabilityIcon
+          className="little-spacer-right vertical-bottom"
+        />
+        metric.vulnerabilities.name
       </div>
     </div>
   </div>
@@ -120,14 +150,29 @@ exports[`should render correctly with all data 1`] = `
       <div
         className="project-card-measure-number"
       >
+        <Measure
+          className="spacer-right"
+          measure={
+            Object {
+              "metric": Object {
+                "key": "code_smells",
+                "type": "SHORT_INT",
+              },
+              "value": "132",
+            }
+          }
+        />
         <Rating
           value="1.0"
         />
       </div>
       <div
-        className="project-card-measure-label"
+        className="project-card-measure-label-with-icon"
       >
-        metric_domain.Maintainability
+        <CodeSmellIcon
+          className="little-spacer-right vertical-bottom"
+        />
+        metric.code_smells.name
       </div>
     </div>
   </div>
@@ -204,7 +249,7 @@ exports[`should render correctly with all data 1`] = `
     </div>
   </div>
   <div
-    className="project-card-measure pull-right"
+    className="project-card-measure project-card-ncloc"
     data-key="ncloc"
   >
     <div
@@ -244,7 +289,7 @@ exports[`should render correctly with all data 1`] = `
 
 exports[`should render ncloc correctly 1`] = `
 <div
-  className="project-card-measure pull-right"
+  className="project-card-measure project-card-ncloc"
   data-key="ncloc"
 >
   <div
index d4f71d0f4c67642095916e3098057329ccc94fdd..0e3a09d8d9cfd8bf52e3ddf1dc56eb5d2aa06420 100644 (file)
@@ -20,6 +20,8 @@
 import * as React from 'react';
 import IssuesFilter from './IssuesFilter';
 import { Facet } from '../types';
+import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon';
+import { translate } from '../../../helpers/l10n';
 
 interface Props {
   className?: string;
@@ -33,5 +35,19 @@ interface Props {
 }
 
 export default function MaintainabilityFilter(props: Props) {
-  return <IssuesFilter {...props} name="Maintainability" property="maintainability" />;
+  return (
+    <IssuesFilter
+      {...props}
+      headerDetail={
+        <span className="note little-spacer-left">
+          {'('}
+          <CodeSmellIcon className="little-spacer-right" />
+          {translate('metric.code_smells.name')}
+          {' )'}
+        </span>
+      }
+      name="Maintainability"
+      property="maintainability"
+    />
+  );
 }
index 77ab08dc006c119f93decf121f624a89fe45e36f..56f71586862373aeaa6e80ce6ab7201e8f3c9cb8 100644 (file)
@@ -20,6 +20,8 @@
 import * as React from 'react';
 import IssuesFilter from './IssuesFilter';
 import { Facet } from '../types';
+import BugIcon from '../../../components/icons-components/BugIcon';
+import { translate } from '../../../helpers/l10n';
 
 interface Props {
   className?: string;
@@ -33,5 +35,19 @@ interface Props {
 }
 
 export default function ReliabilityFilter(props: Props) {
-  return <IssuesFilter {...props} name="Reliability" property="reliability" />;
+  return (
+    <IssuesFilter
+      {...props}
+      headerDetail={
+        <span className="note little-spacer-left">
+          {'('}
+          <BugIcon className="little-spacer-right" />
+          {translate('metric.bugs.name')}
+          {' )'}
+        </span>
+      }
+      name="Reliability"
+      property="reliability"
+    />
+  );
 }
index 262573864c5b343e3603394a73f067e4f9928ce5..4fbad543cf2a506436831a37413675b5f134ad5d 100644 (file)
@@ -20,6 +20,8 @@
 import * as React from 'react';
 import IssuesFilter from './IssuesFilter';
 import { Facet } from '../types';
+import VulnerabilityIcon from '../../../components/icons-components/VulnerabilityIcon';
+import { translate } from '../../../helpers/l10n';
 
 interface Props {
   className?: string;
@@ -33,5 +35,19 @@ interface Props {
 }
 
 export default function SecurityFilter(props: Props) {
-  return <IssuesFilter {...props} name="Security" property="security" />;
+  return (
+    <IssuesFilter
+      {...props}
+      headerDetail={
+        <span className="note little-spacer-left">
+          {'('}
+          <VulnerabilityIcon className="little-spacer-right" />
+          {translate('metric.vulnerabilities.name')}
+          {' )'}
+        </span>
+      }
+      name="Security"
+      property="security"
+    />
+  );
 }
index ef3d9057b14ddae1d8464cb3a61881176e56d3c3..bf53d3df2a02f188228da9f8197ce1b59f36045b 100644 (file)
@@ -2,6 +2,18 @@
 
 exports[`renders 1`] = `
 <IssuesFilter
+  headerDetail={
+    <span
+      className="note little-spacer-left"
+    >
+      (
+      <CodeSmellIcon
+        className="little-spacer-right"
+      />
+      metric.code_smells.name
+       )
+    </span>
+  }
   name="Maintainability"
   property="maintainability"
   query={Object {}}
index 4494914b1604f869d46733916076da96f9fee054..00c4db1716b2d3b823450a55029d45407be95877 100644 (file)
@@ -2,6 +2,18 @@
 
 exports[`renders 1`] = `
 <IssuesFilter
+  headerDetail={
+    <span
+      className="note little-spacer-left"
+    >
+      (
+      <BugIcon
+        className="little-spacer-right"
+      />
+      metric.bugs.name
+       )
+    </span>
+  }
   name="Reliability"
   property="reliability"
   query={Object {}}
index 7142354de29571d153d89cf0290f9b061daf1175..bc4c098e76ea0e73ac113d88951a839ee67bebec 100644 (file)
@@ -2,6 +2,18 @@
 
 exports[`renders 1`] = `
 <IssuesFilter
+  headerDetail={
+    <span
+      className="note little-spacer-left"
+    >
+      (
+      <VulnerabilityIcon
+        className="little-spacer-right"
+      />
+      metric.vulnerabilities.name
+       )
+    </span>
+  }
   name="Security"
   property="security"
   query={Object {}}
index fd464b6618cb1fb32a8a46ecd28c272b72263fb6..615d31ae40a36b1685aedbfb86800dd296b08520 100644 (file)
 }
 
 .project-card-measures {
+  display: flex;
   padding-top: 8px;
   margin: 0 -15px;
 }
 
 .project-card-leak-measures {
+  display: flex;
   padding: 8px 0;
   margin: 4px -4px;
   background-color: #fbf3d5;
   content: '';
 }
 
-.project-card-measure.pull-right {
-  text-align: right;
-}
-
-.project-card-measure.pull-right:before {
-  display: none;
-}
-
-.project-card-measure.pull-right .project-card-measure-inner {
-  text-align: right;
-}
-
 .project-card-measure .level {
   margin-top: 0;
   margin-bottom: 0;
   font-size: 12px;
 }
 
+.project-card-ncloc {
+  margin-left: auto;
+  text-align: right;
+}
+
+.project-card-ncloc:before {
+  display: none;
+}
+
+.project-card-ncloc .project-card-measure-inner {
+  text-align: right;
+}
+
 .project-card-languages {
   display: inline-block;
   max-width: 120px;
index 8b99d5ee803f87e0a6a41089a35a7fed8dad1042..30f46344a6ff6ccd31e249c0c2c7c3108b6a145e 100644 (file)
@@ -86,8 +86,11 @@ const PAGE_SIZE_VISUALIZATIONS = 99;
 
 const METRICS = [
   'alert_status',
+  'bugs',
   'reliability_rating',
+  'vulnerabilities',
   'security_rating',
+  'code_smells',
   'sqale_rating',
   'duplicated_lines_density',
   'coverage',