From 06674aad38fcda5f10c4c0b843f23e454fd06d44 Mon Sep 17 00:00:00 2001 From: Philipp Martens Date: Wed, 26 Feb 2025 17:48:47 +0100 Subject: [PATCH] feat: add classification column to signals per sources table in project statistics popup --- ...tributionCountPerSourcePerLicenseTable.tsx | 34 +++++++++++++++++-- .../ProjectStatisticsPopup.tsx | 1 + src/shared/text.ts | 1 + 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Frontend/Components/AttributionCountPerSourcePerLicenseTable/AttributionCountPerSourcePerLicenseTable.tsx b/src/Frontend/Components/AttributionCountPerSourcePerLicenseTable/AttributionCountPerSourcePerLicenseTable.tsx index e26569823..1b39c23ba 100644 --- a/src/Frontend/Components/AttributionCountPerSourcePerLicenseTable/AttributionCountPerSourcePerLicenseTable.tsx +++ b/src/Frontend/Components/AttributionCountPerSourcePerLicenseTable/AttributionCountPerSourcePerLicenseTable.tsx @@ -15,7 +15,13 @@ import MuiTypography from '@mui/material/Typography'; import { Criticality } from '../../../shared/shared-types'; import { text } from '../../../shared/text'; import { OpossumColors, tableClasses } from '../../shared-styles'; -import { LicenseCounts, LicenseNamesWithCriticality } from '../../types/types'; +import { useAppSelector } from '../../state/hooks'; +import { getClassifications } from '../../state/selectors/resource-selectors'; +import { + LicenseCounts, + LicenseNamesWithClassification, + LicenseNamesWithCriticality, +} from '../../types/types'; const classes = { container: { @@ -29,12 +35,15 @@ const TOTAL_SOURCE_NAME = 'Total'; interface AttributionCountPerSourcePerLicenseTableProps { licenseCounts: LicenseCounts; licenseNamesWithCriticality: LicenseNamesWithCriticality; + licenseNamesWithClassification: LicenseNamesWithClassification; title: string; } export const AttributionCountPerSourcePerLicenseTable: React.FC< AttributionCountPerSourcePerLicenseTableProps > = (props) => { + const classifications = useAppSelector(getClassifications); + const sourceNames = Object.keys( props.licenseCounts.totalAttributionsPerSource, ); @@ -51,6 +60,7 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC< const footerRow = [ text.attributionCountPerSourcePerLicenseTable.footerTitle, '', + '', ...totalNumberOfAttributionsPerSource, totalNumberOfAttributions, ]; @@ -58,6 +68,7 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC< const headerRow = [ text.attributionCountPerSourcePerLicenseTable.columnNames.licenseName, text.attributionCountPerSourcePerLicenseTable.columnNames.criticality, + text.attributionCountPerSourcePerLicenseTable.columnNames.classification, ...sourceNames, text.attributionCountPerSourcePerLicenseTable.columnNames.totalSources, ].map( @@ -122,6 +133,25 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC< ); + const licenseClassification = + props.licenseNamesWithClassification[licenseName]; + + const classificationCell = ( + + + {licenseClassification + ? (classifications[licenseClassification] ?? '-') + : '-'} + + + ); + const buildCountBySourceCell = (columnOffset: number) => (sourceName: string, sourceIdx: number) => { const columnIndex = columnOffset + sourceIdx; @@ -141,7 +171,7 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC< ); }; - const singleCells = [licenseNameCell, criticalityCell]; + const singleCells = [licenseNameCell, criticalityCell, classificationCell]; return ( diff --git a/src/Frontend/Components/ProjectStatisticsPopup/ProjectStatisticsPopup.tsx b/src/Frontend/Components/ProjectStatisticsPopup/ProjectStatisticsPopup.tsx index 53984a514..93830f147 100644 --- a/src/Frontend/Components/ProjectStatisticsPopup/ProjectStatisticsPopup.tsx +++ b/src/Frontend/Components/ProjectStatisticsPopup/ProjectStatisticsPopup.tsx @@ -158,6 +158,7 @@ export const ProjectStatisticsPopup: React.FC = () => { diff --git a/src/shared/text.ts b/src/shared/text.ts index a9d2ddfb9..2f501a9af 100644 --- a/src/shared/text.ts +++ b/src/shared/text.ts @@ -182,6 +182,7 @@ export const text = { columnNames: { licenseName: 'License Name', criticality: 'Criticality', + classification: 'Classification', totalSources: 'Total', }, },