Skip to content

Commit

Permalink
refactor: move user-facing text from signal by source table text.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMa committed Feb 26, 2025
1 parent 1e648da commit 271f0bb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import MuiTableRow from '@mui/material/TableRow';
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';

Expand All @@ -23,10 +24,7 @@ const classes = {
},
};

const LICENSE_COLUMN_NAME_IN_TABLE = 'License name';
const CRITICALITY_COLUMN_NAME_IN_TABLE = 'Criticality';
const FOOTER_TITLE = 'Total';
const TOTAL_SOURCES_TITLE = 'Total';
const TOTAL_SOURCE_NAME = 'Total';

interface AttributionCountPerSourcePerLicenseTableProps {
licenseCounts: LicenseCounts;
Expand All @@ -50,23 +48,27 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC<
.reduce((partialSum, num) => partialSum + num, 0)
.toString();

const footerRow = [FOOTER_TITLE]
.concat('')
.concat(totalNumberOfAttributionsPerSource)
.concat(totalNumberOfAttributions);
const headerRow = [LICENSE_COLUMN_NAME_IN_TABLE]
.concat(CRITICALITY_COLUMN_NAME_IN_TABLE)
.concat(sourceNames)
.concat(TOTAL_SOURCES_TITLE)
.map(
(sourceName) => sourceName.charAt(0).toUpperCase() + sourceName.slice(1),
);
const footerRow = [
text.attributionCountPerSourcePerLicenseTable.footerTitle,
'',
...totalNumberOfAttributionsPerSource,
totalNumberOfAttributions,
];

const headerRow = [
text.attributionCountPerSourcePerLicenseTable.columnNames.licenseName,
text.attributionCountPerSourcePerLicenseTable.columnNames.criticality,
...sourceNames,
text.attributionCountPerSourcePerLicenseTable.columnNames.totalSources,
].map(
(sourceName) => sourceName.charAt(0).toUpperCase() + sourceName.slice(1),
);

Object.entries(
props.licenseCounts.attributionCountPerSourcePerLicense,
).forEach(
([licenseName, value]) =>
(value[TOTAL_SOURCES_TITLE] =
(value[TOTAL_SOURCE_NAME] =
props.licenseCounts.totalAttributionsPerLicense[licenseName]),
);

Expand Down Expand Up @@ -145,7 +147,7 @@ export const AttributionCountPerSourcePerLicenseTable: React.FC<
<MuiTableRow key={rowIndex}>
{singleCells.concat(
sourceNames
.concat(TOTAL_SOURCES_TITLE)
.concat(TOTAL_SOURCE_NAME)
.map(buildCountBySourceCell(singleCells.length)),
)}
</MuiTableRow>
Expand Down
7 changes: 6 additions & 1 deletion src/e2e-tests/page-objects/ProjectStatisticsPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// SPDX-License-Identifier: Apache-2.0
import { expect, type Locator, type Page } from '@playwright/test';

import { text } from '../../shared/text';

export class ProjectStatisticsPopup {
private readonly node: Locator;
readonly title: Locator;
Expand All @@ -16,7 +18,10 @@ export class ProjectStatisticsPopup {
this.closeButton = this.node.getByRole('button', { name: 'Close' });
this.totalSignalCount = this.node
.getByRole('table')
.filter({ hasText: 'License name' })
.filter({
hasText:
text.attributionCountPerSourcePerLicenseTable.columnNames.licenseName,
})
.getByRole('row')
.last()
.getByRole('cell')
Expand Down
8 changes: 8 additions & 0 deletions src/shared/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ export const text = {
incompleteAttributionsPieChart: 'Incomplete Attributions',
},
},
attributionCountPerSourcePerLicenseTable: {
footerTitle: 'Total',
columnNames: {
licenseName: 'License Name',
criticality: 'Criticality',
totalSources: 'Total',
},
},
unsavedChangesPopup: {
title: 'Unsaved Changes',
message: 'You have unsaved changes. What would you like to do?',
Expand Down

0 comments on commit 271f0bb

Please sign in to comment.