]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12204 Add measures icon to nloc link in portfolio overview
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Tue, 18 Jun 2019 12:42:43 +0000 (14:42 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 28 Jun 2019 06:45:41 +0000 (08:45 +0200)
server/sonar-web/src/main/js/apps/portfolio/components/App.tsx
server/sonar-web/src/main/js/apps/portfolio/components/MeasuresButtonLink.tsx
server/sonar-web/src/main/js/apps/portfolio/components/WorstProjects.tsx
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/MeasuresButtonLink-test.tsx
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/App-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/MeasuresButtonLink-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/WorstProjects-test.tsx.snap
server/sonar-web/src/main/js/apps/portfolio/styles.css

index c1b063059e3303bd508d22a531676e0eb4a37d02..433a00de531dcc244f8962d88ade9686f6613132 100644 (file)
@@ -19,7 +19,6 @@
  */
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { Link } from 'react-router';
 import MeasuresButtonLink from './MeasuresButtonLink';
 import MetricBox from './MetricBox';
 import Report from './Report';
@@ -30,7 +29,6 @@ import Measure from '../../../components/measure/Measure';
 import { getChildren } from '../../../api/components';
 import { getMeasures } from '../../../api/measures';
 import { translate } from '../../../helpers/l10n';
-import { getComponentDrilldownUrl } from '../../../helpers/urls';
 import { fetchMetrics } from '../../../store/rootActions';
 import { getMetrics, Store } from '../../../store/rootReducer';
 import '../styles.css';
@@ -171,8 +169,8 @@ export class App extends React.PureComponent<Props, State> {
         <h1>{translate('portfolio.breakdown')}</h1>
         <div className="portfolio-breakdown">
           <div className="portfolio-breakdown-box">
-            <h2>{translate('portfolio.number_of_projects')}</h2>
-            <div className="portfolio-breakdown-metric">
+            <h2 className="text-muted small">{translate('portfolio.number_of_projects')}</h2>
+            <div className="portfolio-breakdown-metric huge">
               <Measure
                 metricKey="projects"
                 metricType="SHORT_INT"
@@ -186,8 +184,8 @@ export class App extends React.PureComponent<Props, State> {
             </div>
           </div>
           <div className="portfolio-breakdown-box">
-            <h2>{translate('portfolio.number_of_lines')}</h2>
-            <div className="portfolio-breakdown-metric">
+            <h2 className="text-muted small">{translate('portfolio.number_of_lines')}</h2>
+            <div className="portfolio-breakdown-metric huge">
               <Measure
                 metricKey="ncloc"
                 metricType="SHORT_INT"
@@ -196,10 +194,11 @@ export class App extends React.PureComponent<Props, State> {
             </div>
             <div className="portfolio-breakdown-box-link">
               <div>
-                <Link
-                  to={getComponentDrilldownUrl({ componentKey: component.key, metric: 'ncloc' })}>
-                  <span>{translate('portfolio.language_breakdown_link')}</span>
-                </Link>
+                <MeasuresButtonLink
+                  component={component.key}
+                  label={translate('portfolio.language_breakdown_link')}
+                  metric="ncloc"
+                />
               </div>
             </div>
           </div>
index 258eed0869e636b849e1a7be59b1dcc28fee7d11..3d78ef61ebca44ef7d390001370ffbe7128865cc 100644 (file)
@@ -25,14 +25,15 @@ import { getComponentDrilldownUrl } from '../../../helpers/urls';
 
 interface Props {
   component: string;
+  label?: string;
   metric: string;
 }
 
-export default function MeasuresButtonLink({ component, metric }: Props) {
+export default function MeasuresButtonLink({ component, label, metric }: Props) {
   return (
     <Link to={getComponentDrilldownUrl({ componentKey: component, metric })}>
       <MeasuresIcon className="little-spacer-right" size={14} />
-      <span>{translate('portfolio.measures_link')}</span>
+      <span>{label || translate('portfolio.measures_link')}</span>
     </Link>
   );
 }
index 344fd501672563b112b173f196eeb6b5b9da8d58..6943e3e9dc1aeb2e4d32fa79219a1ebbe6941f9e 100644 (file)
@@ -21,6 +21,7 @@ import * as React from 'react';
 import { Link } from 'react-router';
 import { max } from 'lodash';
 import { SubComponent } from '../types';
+import * as theme from '../../../app/theme';
 import Measure from '../../../components/measure/Measure';
 import QualifierIcon from '../../../components/icons-components/QualifierIcon';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
@@ -129,7 +130,14 @@ function renderNcloc(measures: T.Dict<string | undefined>, maxLoc: number) {
       </span>
       {maxLoc > 0 && (
         <svg className="spacer-left" height="16" width="50">
-          <rect className="bar-chart-bar" height="10" width={barWidth} x="0" y="3" />
+          <rect
+            className="bar-chart-bar"
+            height="10"
+            fill={theme.blue}
+            width={barWidth}
+            x="0"
+            y="3"
+          />
         </svg>
       )}
     </td>
index 86b0d5c639e05d9f4bf673e5a2cd4637b2d5eb69..41aaba68219f5047c8a22788c7fd69d10912ab9b 100644 (file)
@@ -22,7 +22,10 @@ import { shallow } from 'enzyme';
 import MeasuresButtonLink from '../MeasuresButtonLink';
 
 it('renders', () => {
-  expect(
-    shallow(<MeasuresButtonLink component="foo" metric="security_rating" />)
-  ).toMatchSnapshot();
+  expect(shallowRender()).toMatchSnapshot();
+  expect(shallowRender({ label: 'Foo' })).toMatchSnapshot();
 });
+
+function shallowRender(props = {}) {
+  return shallow(<MeasuresButtonLink component="foo" metric="security_rating" {...props} />);
+}
index 9c400a1ff417848cfea9457a44fcfffc7ebd849b..4691a613e06b208111fbdc7ea6af9c929f9d3b30 100644 (file)
@@ -83,11 +83,13 @@ exports[`renders 1`] = `
     <div
       className="portfolio-breakdown-box"
     >
-      <h2>
+      <h2
+        className="text-muted small"
+      >
         portfolio.number_of_projects
       </h2>
       <div
-        className="portfolio-breakdown-metric"
+        className="portfolio-breakdown-metric huge"
       >
         <Measure
           metricKey="projects"
@@ -109,11 +111,13 @@ exports[`renders 1`] = `
     <div
       className="portfolio-breakdown-box"
     >
-      <h2>
+      <h2
+        className="text-muted small"
+      >
         portfolio.number_of_lines
       </h2>
       <div
-        className="portfolio-breakdown-metric"
+        className="portfolio-breakdown-metric huge"
       >
         <Measure
           metricKey="ncloc"
@@ -125,23 +129,11 @@ exports[`renders 1`] = `
         className="portfolio-breakdown-box-link"
       >
         <div>
-          <Link
-            onlyActiveOnIndex={false}
-            style={Object {}}
-            to={
-              Object {
-                "pathname": "/component_measures",
-                "query": Object {
-                  "id": "foo",
-                  "metric": "ncloc",
-                },
-              }
-            }
-          >
-            <span>
-              portfolio.language_breakdown_link
-            </span>
-          </Link>
+          <MeasuresButtonLink
+            component="foo"
+            label="portfolio.language_breakdown_link"
+            metric="ncloc"
+          />
         </div>
       </div>
     </div>
index 5b5aff8aff9e08f2099afa27017c7f0665e79d1c..4c62daa9f2d68c1b73be05c8910322f7e96ae9a9 100644 (file)
@@ -23,3 +23,27 @@ exports[`renders 1`] = `
   </span>
 </Link>
 `;
+
+exports[`renders 2`] = `
+<Link
+  onlyActiveOnIndex={false}
+  style={Object {}}
+  to={
+    Object {
+      "pathname": "/component_measures",
+      "query": Object {
+        "id": "foo",
+        "metric": "security_rating",
+      },
+    }
+  }
+>
+  <MeasuresIcon
+    className="little-spacer-right"
+    size={14}
+  />
+  <span>
+    Foo
+  </span>
+</Link>
+`;
index ee5e59a8907b0e9a32da7a5fa4cacd4976fcfc41..7fbb4c9db8b11dd8ec9e220de3c8241a7f4e6ec8 100644 (file)
@@ -134,6 +134,7 @@ exports[`renders 1`] = `
           >
             <rect
               className="bar-chart-bar"
+              fill="#4b9fd5"
               height="10"
               width={50}
               x="0"
@@ -230,6 +231,7 @@ exports[`renders 1`] = `
           >
             <rect
               className="bar-chart-bar"
+              fill="#4b9fd5"
               height="10"
               width={25}
               x="0"
@@ -326,6 +328,7 @@ exports[`renders 1`] = `
           >
             <rect
               className="bar-chart-bar"
+              fill="#4b9fd5"
               height="10"
               width={38}
               x="0"
index 3f810d2a79417b9a828fb88a768438ce9bb8a469..6778e7eca1a3814e656d087d604d646872502049 100644 (file)
 
 .portfolio-breakdown {
   display: flex;
-  flex-direction: row;
-  align-items: flex-start;
 }
 
 .portfolio-breakdown-box {
   flex: 0 0 auto;
+  display: flex;
+  flex-direction: column;
   background-color: white;
   border: 1px solid var(--barBorderColor);
-  margin: var(--gridSize) var(--gridSize) calc(2 * var(--gridSize));
-  padding: 0 var(--gridSize) 66px;
-  position: relative;
-}
-
-.portfolio-breakdown-box:first-child {
-  margin-left: 0;
-}
-
-.portfolio-breakdown-box:last-child {
-  margin-right: 0;
+  margin: var(--gridSize) 0 calc(2 * var(--gridSize));
 }
 
-.portfolio-breakdown-box > h2 {
-  color: var(--secondFontColor);
-  margin: var(--gridSize);
-  font-size: 12px;
+.portfolio-breakdown-box + .portfolio-breakdown-box {
+  margin-left: calc(2 * var(--gridSize));
 }
 
-.portfolio-breakdown-box > .portfolio-breakdown-metric {
-  font-size: var(--hugeFontSize);
-  margin-left: var(--gridSize);
+.portfolio-breakdown-box h2,
+.portfolio-breakdown-box .portfolio-breakdown-metric {
+  margin: var(--gridSize) calc(2 * var(--gridSize)) 0;
 }
 
 .portfolio-breakdown-box-link {
+  margin-top: calc(2 * var(--gridSize));
   border-top: 1px solid var(--barBorderColor);
   padding: calc(2 * var(--gridSize));
-  position: absolute;
-  bottom: 0;
-  left: 0;
-  right: 0;
 }
 
-.portfolio-sub-components table.data > thead > tr > th {
+.portfolio-sub-components table.data th {
   font-size: var(--baseFontSize);
   text-transform: none;
   vertical-align: middle;