Skip to content

Commit

Permalink
QA
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-torres-marroquin committed Dec 12, 2024
1 parent 1c75bd4 commit 3781230
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface CustomReportCreationModalProps {
isOpen: boolean;
handleClose: () => void;
tableStateToSave: CustomReportTableState | undefined;
columnMapToSave: Record<string, string> | undefined;
columnMapToSave: Record<string, Record<string, any>> | undefined;
unavailableNames?: string[];
onCreateCustomReport: (newReport: CustomReportResponse) => void;
}
Expand All @@ -35,7 +35,7 @@ export const CustomReportCreationModal = ({
isOpen,
handleClose,
tableStateToSave,
columnMapToSave,
columnMapToSave = {},
unavailableNames,
onCreateCustomReport,
}: CustomReportCreationModalProps) => {
Expand Down Expand Up @@ -63,7 +63,7 @@ export const CustomReportCreationModal = ({
);

const handleCreateReport = async (reportName: string) => {
const columnMap: Record<string, { label: string; enabled: boolean }> = {};
const columnMap: Record<string, any> = {};
const columnVisibility: Record<string, boolean> =
tableStateToSave?.columnVisibility || {};
Object.keys(columnMapToSave).forEach((key) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface CustomReportTemplatesProps {
reportType: ReportType;
savedReportId: string; // from local storage
tableStateToSave: CustomReportTableState | undefined;
currentColumnMap?: Record<string, string> | undefined;
currentColumnMap?: Record<string, Record<string, any>> | undefined;
onCustomReportSaved: (customReport: CustomReportResponse | null) => void;
onSavedReportDeleted: () => void;
}
Expand Down
4 changes: 2 additions & 2 deletions clients/admin-ui/src/features/common/table/v2/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const columnExpandedVersion = (

interface GetColumnHeaderTextProps {
columnId: string | undefined;
columnNameMap?: Record<string, Record<string, any>>;
columnNameMap?: Record<string, string>;
}
/**
* Get the header text for a column.
Expand Down Expand Up @@ -56,5 +56,5 @@ export const getColumnHeaderText = ({
"",
);
const nameFromId = _.upperFirst(keyWithoutPrefix.replaceAll("_", " "));
return columnNameMap?.[columnId]?.label || nameFromId;
return columnNameMap?.[columnId] || nameFromId;
};
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export const DatamapReportTable = () => {

// Column renaming
const [isRenamingColumns, setIsRenamingColumns] = useState(false);
const handleColumnRenaming = (values: Record<string, string>) => {
const handleColumnRenaming = (
values: Record<string, Record<string, any>>,
) => {
setSavedCustomReportId("");
setColumnNameMapOverrides(values);
setIsRenamingColumns(false);
Expand Down Expand Up @@ -235,7 +237,7 @@ export const DatamapReportTable = () => {
} = useDisclosure();

const onExport = (downloadType: ExportFormat) => {
const columnMap: Record<string, { label: string; enabled: boolean }> = {};
const columnMap: Record<string, Record<string, any>> = {};
Object.keys(columnNameMapOverrides).forEach((key) => {
columnMap[key] = {
label: columnNameMapOverrides[key],
Expand Down Expand Up @@ -328,7 +330,7 @@ export const DatamapReportTable = () => {
const handleSavedReport = (
savedReport: CustomReportResponse | null,
resetForm: (
nextState?: Partial<FormikState<Record<string, string>>> | undefined,
nextState?: Partial<FormikState<Record<string, any>>> | undefined,
) => void,
) => {
if (!savedReport) {
Expand Down Expand Up @@ -380,10 +382,17 @@ export const DatamapReportTable = () => {
return <TableSkeletonLoader rowHeight={36} numRows={15} />;
}

const x: Record<string, string> = {};
Object.keys(columnNameMapOverrides).forEach((key) => {
if (columnNameMapOverrides[key].label) {
x[key] = columnNameMapOverrides[key].label;
}
});

return (
<Flex flex={1} direction="column" overflow="auto">
<DatamapReportFilterModal
columnNameMap={{ ...DEFAULT_COLUMN_NAMES, ...columnNameMapOverrides }}
columnNameMap={{ ...DEFAULT_COLUMN_NAMES, ...x }}
selectedFilters={selectedFilters}
isOpen={isFilterModalOpen}
onClose={onFilterModalClose}
Expand All @@ -396,7 +405,7 @@ export const DatamapReportTable = () => {
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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ interface DatamapReportContextProps {
setColumnVisibility: Dispatch<SetStateAction<Record<string, boolean>>>;
columnSizing: Record<string, number>;
setColumnSizing: Dispatch<SetStateAction<Record<string, number>>>;
columnNameMapOverrides: Record<string, string>;
setColumnNameMapOverrides: Dispatch<SetStateAction<Record<string, string>>>;
columnNameMapOverrides: Record<string, Record<string, any>>;
setColumnNameMapOverrides: Dispatch<
SetStateAction<Record<string, Record<string, any>>>
>;
}

export const DatamapReportContext = createContext<DatamapReportContextProps>(
Expand Down Expand Up @@ -76,7 +78,7 @@ export const DatamapReportProvider = ({
>(DATAMAP_LOCAL_STORAGE_KEYS.COLUMN_SIZING, {});

const [columnNameMapOverrides, setColumnNameMapOverrides] = useLocalStorage<
Record<string, string>
Record<string, Record<string, any>>
>(DATAMAP_LOCAL_STORAGE_KEYS.COLUMN_NAMES, {});

const contextValue: DatamapReportContextProps = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export type CustomReportConfig = {
/**
* A map between column keys and custom labels
*/
column_map?: Record<string, string>;
column_map?: Record<string, any>;
};

0 comments on commit 3781230

Please sign in to comment.