line-height: 15px;
}
-.data tr > th.leak,
-.data tr > td.leak {
- background-color: var(--leakColor) !important;
- line-height: 15px;
-}
-
.data tr.highlight {
background-color: var(--lightBlue);
}
background-color: #f5f5f5;
}
-table.data.zebra:not(.zebra-inversed)
- > tbody
- > tr:not(.blank):nth-child(even)
- > td:not(.blank).leak,
-table.data.zebra.zebra-inversed > tbody > tr:not(.blank):nth-child(odd) > td:not(.blank).leak {
- background-color: var(--leakColorHover) !important;
-}
-
table#project-history tr > td {
vertical-align: top;
}
branchLike?: T.BranchLike;
canBrowse?: boolean;
component: T.ComponentMeasure;
- isLeak: boolean;
metrics: T.Metric[];
previous?: T.ComponentMeasure;
rootComponent: T.ComponentMeasure;
branchLike,
canBrowse = false,
component,
- isLeak,
metrics,
previous,
rootComponent,
</td>
{metrics.map(metric => (
- <td className={classNames('thin nowrap text-right', { leak: isLeak })} key={metric.key}>
+ <td className="thin nowrap text-right" key={metric.key}>
<div className="code-components-cell">
<ComponentMeasure component={component} metric={metric} />
</div>
</td>
))}
- <td className={classNames('blank', { leak: isLeak })} />
+ <td className="blank" />
</tr>
);
}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import * as classNames from 'classnames';
import Component from './Component';
import ComponentsEmpty from './ComponentsEmpty';
import ComponentsHeader from './ComponentsHeader';
import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation';
-import { getCodeMetrics, showLeakMeasure } from '../utils';
+import { getCodeMetrics } from '../utils';
import { isDefined } from '../../../helpers/types';
interface Props {
const { baseComponent, branchLike, components, rootComponent, selected } = this.props;
const metricKeys = getCodeMetrics(rootComponent.qualifier, branchLike);
const metrics = metricKeys.map(metric => this.props.metrics[metric]).filter(isDefined);
- const isLeak = Boolean(baseComponent && showLeakMeasure(branchLike));
return (
<table className="data boxed-padding zebra">
{baseComponent && (
<ComponentsHeader
baseComponent={baseComponent}
- isLeak={isLeak}
metrics={metricKeys}
rootComponent={rootComponent}
/>
<Component
branchLike={branchLike}
component={baseComponent}
- isLeak={isLeak}
key={baseComponent.key}
metrics={metrics}
rootComponent={rootComponent}
/>
<tr className="blank">
<td colSpan={3}> </td>
- <td className={classNames({ leak: isLeak })} colSpan={10}>
- {' '}
- {' '}
- </td>
+ <td colSpan={10}> </td>
</tr>
</tbody>
)}
branchLike={branchLike}
canBrowse={true}
component={component}
- isLeak={isLeak}
key={component.key}
metrics={metrics}
previous={index > 0 ? list[index - 1] : undefined}
/>
))
) : (
- <ComponentsEmpty isLeak={isLeak} />
+ <ComponentsEmpty />
)}
<tr className="blank">
<td colSpan={3} />
- <td className={classNames({ leak: isLeak })} colSpan={10} />
+ <td colSpan={10} />
</tr>
</tbody>
</table>
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import * as classNames from 'classnames';
import { translate } from '../../../helpers/l10n';
-export default function ComponentsEmpty({ isLeak }: { isLeak: boolean }) {
+export default function ComponentsEmpty() {
return (
<tr>
<td />
<td className="note" colSpan={2}>
{translate('no_results')}
</td>
- <td className={classNames({ leak: isLeak })} colSpan={10} />
+ <td colSpan={10} />
</tr>
);
}
interface Props {
baseComponent?: T.ComponentMeasure;
- isLeak: boolean;
metrics: string[];
rootComponent: T.ComponentMeasure;
}
'new_duplicated_lines_density'
];
-export default function ComponentsHeader({ baseComponent, isLeak, metrics, rootComponent }: Props) {
+export default function ComponentsHeader({ baseComponent, metrics, rootComponent }: Props) {
const isPortfolio = ['VW', 'SVW'].includes(rootComponent.qualifier);
let columns: string[] = [];
if (isPortfolio) {
columns.map((column, index) => (
<th
className={classNames('thin', 'nowrap', 'text-right', {
- 'code-components-cell': index > 0,
- leak: isLeak
+ 'code-components-cell': index > 0
})}
key={column}>
{column}
</th>
))}
- <th className={classNames({ leak: isLeak })} />
+ <th />
</tr>
</thead>
);
import * as React from 'react';
import { shallow } from 'enzyme';
import ComponentsHeader from '../ComponentsHeader';
-
-const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' };
-const PORTFOLIO = { key: 'bar', name: 'Bar', qualifier: 'VW' };
-const METRICS = ['foo', 'bar'];
+import { mockComponent } from '../../../../helpers/testMocks';
it('renders correctly for projects', () => {
- expect(
- shallow(
- <ComponentsHeader
- baseComponent={COMPONENT}
- isLeak={false}
- metrics={METRICS}
- rootComponent={COMPONENT}
- />
- )
- ).toMatchSnapshot();
-});
-
-it('renders correctly for leak', () => {
- expect(
- shallow(
- <ComponentsHeader
- baseComponent={COMPONENT}
- isLeak={true}
- metrics={METRICS}
- rootComponent={COMPONENT}
- />
- )
- ).toMatchSnapshot();
+ expect(shallowRender()).toMatchSnapshot();
});
it('renders correctly for portfolios', () => {
- expect(
- shallow(
- <ComponentsHeader
- baseComponent={PORTFOLIO}
- isLeak={false}
- metrics={METRICS}
- rootComponent={PORTFOLIO}
- />
- )
- ).toMatchSnapshot();
+ const portfolio = mockComponent({ qualifier: 'VW' });
+ expect(shallowRender({ baseComponent: portfolio, rootComponent: portfolio })).toMatchSnapshot();
});
it('renders correctly for a search', () => {
- expect(
- shallow(<ComponentsHeader isLeak={false} metrics={METRICS} rootComponent={COMPONENT} />)
- ).toMatchSnapshot();
+ expect(shallowRender({ baseComponent: undefined })).toMatchSnapshot();
});
+
+function shallowRender(props = {}) {
+ return shallow(
+ <ComponentsHeader
+ baseComponent={mockComponent()}
+ metrics={['foo', 'bar']}
+ rootComponent={mockComponent()}
+ {...props}
+ />
+ );
+}
"qualifier": "TRK",
}
}
- isLeak={false}
metrics={
Array [
"ncloc",
"qualifier": "TRK",
}
}
- isLeak={false}
key="foo"
metrics={
Array [
</td>
<td
- className=""
colSpan={10}
>
-
-
</td>
</tr>
</tbody>
"qualifier": "TRK",
}
}
- isLeak={false}
key="foo"
metrics={
Array [
colSpan={3}
/>
<td
- className=""
colSpan={10}
/>
</tr>
"qualifier": "TRK",
}
}
- isLeak={false}
key="foo"
metrics={
Array [
colSpan={3}
/>
<td
- className=""
colSpan={10}
/>
</tr>
"qualifier": "TRK",
}
}
- isLeak={true}
metrics={
Array [
"new_lines",
"qualifier": "TRK",
}
}
- isLeak={true}
key="foo"
metrics={Array []}
rootComponent={
</td>
<td
- className="leak"
colSpan={10}
>
-
-
</td>
</tr>
</tbody>
"qualifier": "TRK",
}
}
- isLeak={true}
key="foo"
metrics={Array []}
rootComponent={
colSpan={3}
/>
<td
- className="leak"
colSpan={10}
/>
</tr>
colSpan={2}
/>
<th />
- <th
- className=""
- />
- </tr>
-</thead>
-`;
-
-exports[`renders correctly for leak 1`] = `
-<thead>
- <tr
- className="code-components-header"
- >
- <th
- className="thin nowrap"
- colSpan={2}
- />
<th />
- <th
- className="thin nowrap text-right leak"
- key="metric.foo.name"
- >
- metric.foo.name
- </th>
- <th
- className="thin nowrap text-right code-components-cell leak"
- key="metric.bar.name"
- >
- metric.bar.name
- </th>
- <th
- className="leak"
- />
</tr>
</thead>
`;
>
metric.ncloc.name
</th>
- <th
- className=""
- />
+ <th />
</tr>
</thead>
`;
>
metric.bar.name
</th>
- <th
- className=""
- />
+ <th />
</tr>
</thead>
`;