*/
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';
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';
<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"
</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"
</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>
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>
);
}
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';
</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>
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} />);
+}
<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"
<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"
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>
</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>
+`;
>
<rect
className="bar-chart-bar"
+ fill="#4b9fd5"
height="10"
width={50}
x="0"
>
<rect
className="bar-chart-bar"
+ fill="#4b9fd5"
height="10"
width={25}
x="0"
>
<rect
className="bar-chart-bar"
+ fill="#4b9fd5"
height="10"
width={38}
x="0"
.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;