From 186bbdcc75d004c85037dbee233da2beb3d5d036 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 5 Dec 2024 12:26:55 -0500 Subject: [PATCH] Edited DrawerInterior.tsx to fix filter sort - Added sort to portFacet. - Added sort to cveFacet. - Severity levels are now sorted in order of Low, Medium, High, Critical. --- frontend/src/components/DrawerInterior.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 3b43e432..f9945e5f 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -151,7 +151,9 @@ export const DrawerInterior: React.FC = (props) => { ); const portFacet: any[] = facets['services.port'] - ? facets['services.port'][0].data + ? facets['services.port'][0].data.sort( + (a: { value: number }, b: { value: number }) => a.value - b.value + ) : []; const fromDomainFacet: any[] = facets['fromRootDomain'] @@ -159,7 +161,10 @@ export const DrawerInterior: React.FC = (props) => { : []; const cveFacet: any[] = facets['vulnerabilities.cve'] - ? facets['vulnerabilities.cve'][0].data + ? facets['vulnerabilities.cve'][0].data.sort( + (a: { value: string }, b: { value: string }) => + a.value.localeCompare(b.value) + ) : []; const severityFacet: any[] = facets['vulnerabilities.severity'] @@ -167,7 +172,7 @@ export const DrawerInterior: React.FC = (props) => { : []; // Always show all severities - for (const value of ['Critical', 'High', 'Medium', 'Low']) { + for (const value of ['Low', 'Medium', 'High', 'Critical']) { if (!severityFacet.find((severity) => value === severity.value)) severityFacet.push({ value, count: 0 }); }