table > thead > tr.code-components-header > th {
vertical-align: middle;
}
+
+.code-child-component-icon {
+ display: inline-block;
+ border-left: 1px solid var(--secondFontColor);
+ border-bottom: 1px solid var(--secondFontColor);
+ margin-left: 8px;
+ margin-bottom: 8px;
+ margin-right: 4px;
+ height: 8px;
+ width: 4px;
+}
canBePinned?: boolean;
canBrowse?: boolean;
component: T.ComponentMeasure;
+ hasBaseComponent: boolean;
metrics: T.Metric[];
previous?: T.ComponentMeasure;
rootComponent: T.ComponentMeasure;
canBePinned = true,
canBrowse = false,
component,
+ hasBaseComponent,
metrics,
previous,
rootComponent,
</td>
)}
<td className="code-name-cell">
+ {hasBaseComponent && <div className="code-child-component-icon" />}
<ComponentName
branchLike={branchLike}
canBrowse={canBrowse}
selected?: T.ComponentMeasure;
}
+const BASE_COLUMN_COUNT = 4;
+
export class Components extends React.PureComponent<Props> {
render() {
const { baseComponent, branchLike, components, rootComponent, selected } = this.props;
Object.keys(this.props.metrics)
);
const metrics = metricKeys.map(metric => this.props.metrics[metric]);
- const colSpan = metrics.length + 4;
+ const colSpan = metrics.length + BASE_COLUMN_COUNT;
const canBePinned = baseComponent && !['APP', 'VW', 'SVW'].includes(baseComponent.qualifier);
return (
branchLike={branchLike}
canBePinned={canBePinned}
component={baseComponent}
+ hasBaseComponent={false}
key={baseComponent.key}
metrics={metrics}
rootComponent={rootComponent}
/>
<tr className="blank">
- <td colSpan={3}> </td>
- <td colSpan={colSpan}> </td>
+ <td colSpan={3}>
+ <hr className="null-spacer-top" />
+ </td>
+ <td colSpan={colSpan}>
+ <hr className="null-spacer-top" />
+ </td>
</tr>
</>
)}
canBePinned={canBePinned}
canBrowse={true}
component={component}
+ hasBaseComponent={baseComponent !== undefined}
key={component.key}
metrics={metrics}
previous={index > 0 ? list[index - 1] : undefined}
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot();
+ expect(shallowRender({ hasBaseComponent: true })).toMatchSnapshot('with base component');
});
it('should render correctly for a file', () => {
{ metric: 'vulnerabilities', value: '1' }
]
})}
+ hasBaseComponent={false}
metrics={[mockMetric({ key: 'bugs' }), mockMetric({ key: 'vulnerabilities' })]}
rootComponent={mockComponentMeasure()}
{...props}
/>
</tr>
`;
+
+exports[`should render correctly: with base component 1`] = `
+<tr
+ className=""
+>
+ <td
+ className="blank"
+ />
+ <td
+ className="thin nowrap"
+ />
+ <td
+ className="code-name-cell"
+ >
+ <div
+ className="code-child-component-icon"
+ />
+ <ComponentName
+ canBrowse={false}
+ component={
+ Object {
+ "key": "bar",
+ "measures": Array [
+ Object {
+ "metric": "bugs",
+ "value": "12",
+ },
+ Object {
+ "metric": "vulnerabilities",
+ "value": "1",
+ },
+ ],
+ "name": "Bar",
+ "qualifier": "TRK",
+ }
+ }
+ rootComponent={
+ Object {
+ "key": "foo",
+ "measures": Array [
+ Object {
+ "bestValue": false,
+ "metric": "bugs",
+ "value": "12",
+ },
+ ],
+ "name": "Foo",
+ "qualifier": "TRK",
+ }
+ }
+ />
+ </td>
+ <td
+ className="thin nowrap text-right"
+ key="bugs"
+ >
+ <div
+ className="code-components-cell"
+ >
+ <ComponentMeasure
+ component={
+ Object {
+ "key": "bar",
+ "measures": Array [
+ Object {
+ "metric": "bugs",
+ "value": "12",
+ },
+ Object {
+ "metric": "vulnerabilities",
+ "value": "1",
+ },
+ ],
+ "name": "Bar",
+ "qualifier": "TRK",
+ }
+ }
+ metric={
+ Object {
+ "id": "bugs",
+ "key": "bugs",
+ "name": "Bugs",
+ "type": "PERCENT",
+ }
+ }
+ />
+ </div>
+ </td>
+ <td
+ className="thin nowrap text-right"
+ key="vulnerabilities"
+ >
+ <div
+ className="code-components-cell"
+ >
+ <ComponentMeasure
+ component={
+ Object {
+ "key": "bar",
+ "measures": Array [
+ Object {
+ "metric": "bugs",
+ "value": "12",
+ },
+ Object {
+ "metric": "vulnerabilities",
+ "value": "1",
+ },
+ ],
+ "name": "Bar",
+ "qualifier": "TRK",
+ }
+ }
+ metric={
+ Object {
+ "id": "vulnerabilities",
+ "key": "vulnerabilities",
+ "name": "Vulnerabilities",
+ "type": "PERCENT",
+ }
+ }
+ />
+ </div>
+ </td>
+ <td
+ className="blank"
+ />
+</tr>
+`;
"qualifier": "TRK",
}
}
+ hasBaseComponent={false}
key="foo"
metrics={
Array [
<td
colSpan={3}
>
-
+ <hr
+ className="null-spacer-top"
+ />
</td>
<td
colSpan={5}
>
-
+ <hr
+ className="null-spacer-top"
+ />
</td>
</tr>
<withScrollTo(Component)
"qualifier": "TRK",
}
}
+ hasBaseComponent={true}
key="foo"
metrics={
Array [
"qualifier": "TRK",
}
}
+ hasBaseComponent={false}
key="foo"
metrics={Array []}
rootComponent={
"qualifier": "TRK",
}
}
+ hasBaseComponent={false}
key="foo"
metrics={
Array [
<td
colSpan={3}
>
-
+ <hr
+ className="null-spacer-top"
+ />
</td>
<td
colSpan={5}
>
-
+ <hr
+ className="null-spacer-top"
+ />
</td>
</tr>
<withScrollTo(Component)
"qualifier": "TRK",
}
}
+ hasBaseComponent={true}
key="foo"
metrics={
Array [