diff --git a/clients/admin-ui/cypress/fixtures/custom-reports/custom-report.json b/clients/admin-ui/cypress/fixtures/custom-reports/custom-report.json index e1ee3836a9..ea45816b36 100644 --- a/clients/admin-ui/cypress/fixtures/custom-reports/custom-report.json +++ b/clients/admin-ui/cypress/fixtures/custom-reports/custom-report.json @@ -58,21 +58,21 @@ "uses_non_cookie_access", "uses_profiling", "system_lorem" - ], + ] }, "column_map": { "data_categories": { "label": "My Data Category Map" }, "data_subjects": { - "enabled": false, + "enabled": false }, "system_undeclared_data_categories": { - "enabled": false, + "enabled": false }, "data_use_undeclared_data_categories": { - "enabled": false, - }, + "enabled": false + } } } } diff --git a/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx b/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx index e55e0bc4d6..b0135b2f12 100644 --- a/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx +++ b/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx @@ -26,7 +26,7 @@ interface CustomReportCreationModalProps { isOpen: boolean; handleClose: () => void; tableStateToSave: CustomReportTableState | undefined; - columnMapToSave: Record | undefined; + columnMapToSave: Record> | undefined; unavailableNames?: string[]; onCreateCustomReport: (newReport: CustomReportResponse) => void; } @@ -35,7 +35,7 @@ export const CustomReportCreationModal = ({ isOpen, handleClose, tableStateToSave, - columnMapToSave, + columnMapToSave = {}, unavailableNames, onCreateCustomReport, }: CustomReportCreationModalProps) => { @@ -63,7 +63,7 @@ export const CustomReportCreationModal = ({ ); const handleCreateReport = async (reportName: string) => { - const columnMap: Record = {}; + const columnMap: Record = {}; const columnVisibility: Record = tableStateToSave?.columnVisibility || {}; Object.keys(columnMapToSave).forEach((key) => { diff --git a/clients/admin-ui/src/features/common/custom-reports/CustomReportTemplates.tsx b/clients/admin-ui/src/features/common/custom-reports/CustomReportTemplates.tsx index 557aabc6e8..d05ecca529 100644 --- a/clients/admin-ui/src/features/common/custom-reports/CustomReportTemplates.tsx +++ b/clients/admin-ui/src/features/common/custom-reports/CustomReportTemplates.tsx @@ -54,7 +54,7 @@ interface CustomReportTemplatesProps { reportType: ReportType; savedReportId: string; // from local storage tableStateToSave: CustomReportTableState | undefined; - currentColumnMap?: Record | undefined; + currentColumnMap?: Record> | undefined; onCustomReportSaved: (customReport: CustomReportResponse | null) => void; onSavedReportDeleted: () => void; } diff --git a/clients/admin-ui/src/features/common/table/v2/util.ts b/clients/admin-ui/src/features/common/table/v2/util.ts index 401c26a8e8..323d43be10 100644 --- a/clients/admin-ui/src/features/common/table/v2/util.ts +++ b/clients/admin-ui/src/features/common/table/v2/util.ts @@ -26,7 +26,7 @@ export const columnExpandedVersion = ( interface GetColumnHeaderTextProps { columnId: string | undefined; - columnNameMap?: Record>; + columnNameMap?: Record; } /** * Get the header text for a column. @@ -56,5 +56,5 @@ export const getColumnHeaderText = ({ "", ); const nameFromId = _.upperFirst(keyWithoutPrefix.replaceAll("_", " ")); - return columnNameMap?.[columnId]?.label || nameFromId; + return columnNameMap?.[columnId] || nameFromId; }; diff --git a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx index 91f2050368..c015a1d41d 100644 --- a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx +++ b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx @@ -195,7 +195,9 @@ export const DatamapReportTable = () => { // Column renaming const [isRenamingColumns, setIsRenamingColumns] = useState(false); - const handleColumnRenaming = (values: Record) => { + const handleColumnRenaming = ( + values: Record>, + ) => { setSavedCustomReportId(""); setColumnNameMapOverrides(values); setIsRenamingColumns(false); @@ -235,7 +237,7 @@ export const DatamapReportTable = () => { } = useDisclosure(); const onExport = (downloadType: ExportFormat) => { - const columnMap: Record = {}; + const columnMap: Record> = {}; Object.keys(columnNameMapOverrides).forEach((key) => { columnMap[key] = { label: columnNameMapOverrides[key], @@ -328,7 +330,7 @@ export const DatamapReportTable = () => { const handleSavedReport = ( savedReport: CustomReportResponse | null, resetForm: ( - nextState?: Partial>> | undefined, + nextState?: Partial>> | undefined, ) => void, ) => { if (!savedReport) { @@ -380,10 +382,17 @@ export const DatamapReportTable = () => { return ; } + const x: Record = {}; + Object.keys(columnNameMapOverrides).forEach((key) => { + if (columnNameMapOverrides[key].label) { + x[key] = columnNameMapOverrides[key].label; + } + }); + return ( { isOpen={isColumnSettingsOpen} onClose={onColumnSettingsClose} headerText="Data map settings" - columnNameMap={{ ...DEFAULT_COLUMN_NAMES, ...columnNameMapOverrides }} + columnNameMap={{ ...DEFAULT_COLUMN_NAMES, ...x }} prefixColumns={getPrefixColumns(groupBy)} tableInstance={tableInstance} savedCustomReportId={savedCustomReportId} diff --git a/clients/admin-ui/src/features/datamap/reporting/datamap-report-context.tsx b/clients/admin-ui/src/features/datamap/reporting/datamap-report-context.tsx index 65aa83b333..27bbcc0a2b 100644 --- a/clients/admin-ui/src/features/datamap/reporting/datamap-report-context.tsx +++ b/clients/admin-ui/src/features/datamap/reporting/datamap-report-context.tsx @@ -26,8 +26,10 @@ interface DatamapReportContextProps { setColumnVisibility: Dispatch>>; columnSizing: Record; setColumnSizing: Dispatch>>; - columnNameMapOverrides: Record; - setColumnNameMapOverrides: Dispatch>>; + columnNameMapOverrides: Record>; + setColumnNameMapOverrides: Dispatch< + SetStateAction>> + >; } export const DatamapReportContext = createContext( @@ -76,7 +78,7 @@ export const DatamapReportProvider = ({ >(DATAMAP_LOCAL_STORAGE_KEYS.COLUMN_SIZING, {}); const [columnNameMapOverrides, setColumnNameMapOverrides] = useLocalStorage< - Record + Record> >(DATAMAP_LOCAL_STORAGE_KEYS.COLUMN_NAMES, {}); const contextValue: DatamapReportContextProps = useMemo( diff --git a/clients/admin-ui/src/types/api/models/CustomReportConfig.ts b/clients/admin-ui/src/types/api/models/CustomReportConfig.ts index 157e19c36b..1432ab85d6 100644 --- a/clients/admin-ui/src/types/api/models/CustomReportConfig.ts +++ b/clients/admin-ui/src/types/api/models/CustomReportConfig.ts @@ -13,5 +13,5 @@ export type CustomReportConfig = { /** * A map between column keys and custom labels */ - column_map?: Record; + column_map?: Record; };