diff --git a/ui/components/charts/BarChart.tsx b/ui/components/charts/BarChart.tsx index b96c8e2..d499e33 100644 --- a/ui/components/charts/BarChart.tsx +++ b/ui/components/charts/BarChart.tsx @@ -25,6 +25,7 @@ interface Props { interface State { series: MakeOptional[]; + total: number; } export class BarChart extends React.Component { @@ -43,6 +44,7 @@ export class BarChart extends React.Component { stack: d.stack, ...(d.color ? { color: d.color } : {}), })), + total: props.data.reduce((accX, itemX) => accX + itemX.data.reduce((accY, itemY) => accY + itemY, 0), 0), }; } @@ -53,7 +55,9 @@ export class BarChart extends React.Component { } public render(): JSX.Element { - return ( + return !this.state.total ? ( +
+ ) : (
{this.props.title &&

{this.props.title}

} { } public render(): JSX.Element { - return ( + return !this.state.total ? ( +
+ ) : (
{this.props.title &&

{this.props.title}

} { public render(): JSX.Element { return ( -
- {this.props.title &&

{this.props.title}

} -
-
{this.props.value.substring(0, 5)}
+ +
+ {this.props.title &&

{this.props.title}

} +
+
{this.props.value.substring(0, 5)}
+
+ {this.props.subtitle &&
{this.props.subtitle}
}
- {this.props.subtitle &&
{this.props.subtitle}
} -
+ ); } } diff --git a/ui/components/sbom/SpdxSecurityTableCard.tsx b/ui/components/sbom/SpdxSecurityTableCard.tsx index 19b0142..b3ea822 100644 --- a/ui/components/sbom/SpdxSecurityTableCard.tsx +++ b/ui/components/sbom/SpdxSecurityTableCard.tsx @@ -445,7 +445,9 @@ function renderAdvisoryCvssCell(
{tableItem.cvssScore} / 10 ( ) as [K, number][]; return reduced.sort().map(([k, v]) => mapper(k, v)); } - -function summariseAsMap( - array: T[], - keySelector: (item: T) => K | K[], - valueSelector: (item: T) => V, - mapper?: (key: K, value: V) => M, -) { - const summarised = Object.entries( - array.reduce( - (acc, item) => { - const key = keySelector(item); - const keys = Array.isArray(key) ? key : [key]; - keys.forEach((k) => { - acc[k] = valueSelector(item); - }); - return acc; - }, - {} as Record, - ), - ) as [K, V][]; - return summarised.sort().map(([k, v]) => (mapper ? mapper(k, v) : { label: k, value: v })); -}