From 98243f72a4c9c6cc4eab18197405a7a70d261d60 Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:54:50 +0100 Subject: [PATCH] fix: dashboard - avoid rendering barchart when no sboms are available --- .../home/components/MonitoringSection.tsx | 226 ++++++++++-------- 1 file changed, 122 insertions(+), 104 deletions(-) diff --git a/client/src/app/pages/home/components/MonitoringSection.tsx b/client/src/app/pages/home/components/MonitoringSection.tsx index 56996ac4..4ac12c24 100644 --- a/client/src/app/pages/home/components/MonitoringSection.tsx +++ b/client/src/app/pages/home/components/MonitoringSection.tsx @@ -19,6 +19,10 @@ import { DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, + EmptyState, + EmptyStateBody, + EmptyStateHeader, + EmptyStateVariant, Grid, GridItem, Stack, @@ -116,117 +120,131 @@ export const MonitoringSection: React.FC = () => { -
- { - const severity = severityList[legend.severity]; - return { name: severity.name }; - })} - legendPosition="bottom-left" - height={375} - name="sbom-summary-status" - padding={{ - bottom: 75, - left: 330, - right: 50, - top: 50, - }} - themeColor={ChartThemeColor.multiOrdered} - width={700} - legendComponent={ - 0 ? ( +
+ { + const severity = severityList[legend.severity]; + return { name: severity.name }; + })} + legendPosition="bottom-left" + height={375} + name="sbom-summary-status" + padding={{ + bottom: 75, + left: 330, + right: 50, + top: 50, + }} + themeColor={ChartThemeColor.multiOrdered} + width={700} + legendComponent={ + { + const severity = severityList[legend.severity]; + return severity.color.value; + })} + /> + } + > + + } + tickLabelComponent={ + { + const sbomName = (event.target as any) + .innerHTML as string | null; + const sbom = barchartSboms.find( + (item, index) => { + return ( + generateSbomBarName(item, index) === + sbomName + ); + } + ); + if (sbom) { + navigate(`/sboms/${sbom.id}`); + } + }, + }} + /> + } + /> + + { const severity = severityList[legend.severity]; return severity.color.value; })} - /> - } - > - - } - tickLabelComponent={ - { - const sbomName = (event.target as any) - .innerHTML as string | null; - const sbom = barchartSboms.find( - (item, index) => { - return ( - generateSbomBarName(item, index) === - sbomName - ); - } - ); - if (sbom) { - navigate(`/sboms/${sbom.id}`); + > + {LEGENDS.map((legend) => { + const severityData = severityList[legend.severity]; + return ( + } - }, - }} - /> - } - /> - - { - const severity = severityList[legend.severity]; - return severity.color.value; - })} - > - {LEGENDS.map((legend) => { - const severityData = severityList[legend.severity]; - return ( - - } - data={barchartSbomsVulnerabilities.map( - ( - { - summary: { - vulnerabilityStatus: { affected }, + data={barchartSbomsVulnerabilities.map( + ( + { + summary: { + vulnerabilityStatus: { affected }, + }, }, - }, - index - ) => { - const sbom = barchartSboms[index]; + index + ) => { + const sbom = barchartSboms[index]; - const severity = legend.severity; - const count = affected.severities[severity]; - return { - x: generateSbomBarName(sbom, index), - y: count, - label: `${severityData.name}: ${count}`, - }; - } - )} - /> - ); - })} - - -
+ const severity = legend.severity; + const count = affected.severities[severity]; + return { + x: generateSbomBarName(sbom, index), + y: count, + label: `${severityData.name}: ${count}`, + }; + } + )} + /> + ); + })} + +
+
+ ) : ( + + + + You can get started by uploading an SBOM. Once your + SBOMs are uploaded come back to this page to see your + overview. + + + )}