Skip to content

Commit

Permalink
HJ-128 - Fix on FE columnOrder and CHANGELOG.md update (#5623)
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-torres-marroquin committed Dec 19, 2024
1 parent 2d75060 commit 918f233
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The types of changes are:
- Added new `has_next` parameter for the `link` pagination strategy [#5596](https://github.com/ethyca/fides/pull/5596)
- Added a `DBCache` model for database-backed caching [#5613](https://github.com/ethyca/fides/pull/5613)
- Adds "reclassify" button to discovery result tables [#5574](https://github.com/ethyca/fides/pull/5574)
- Added support for exporting datamaps with column renaming, reordering and visibility options [#5543](https://github.com/ethyca/fides/pull/5543)

### Changed
- Adjusted Ant's Select component colors and icon [#5594](https://github.com/ethyca/fides/pull/5594)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import {
getDatamapReportColumns,
getDefaultColumn,
} from "./DatamapReportTableColumns";
import { getGrouping, getPrefixColumns } from "./utils";
import { getColumnOrder, getGrouping, getPrefixColumns } from "./utils";

const emptyMinimalDatamapReportResponse: Page_DatamapReport_ = {
items: [],
Expand Down Expand Up @@ -223,6 +223,14 @@ export const DatamapReportTable = () => {
],
);

useEffect(() => {
if (datamapReport) {
const columnIDs = Object.keys(datamapReport.items[0]);
setColumnOrder(getColumnOrder(groupBy, columnIDs));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [groupBy, datamapReport]);

const {
isOpen: isColumnSettingsOpen,
onOpen: onColumnSettingsOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { DATAMAP_GROUPING } from "~/types/api";

import { DatamapReportFilterSelections } from "../types";
import { COLUMN_IDS, DATAMAP_LOCAL_STORAGE_KEYS } from "./constants";
import { getColumnOrder } from "./utils";

interface DatamapReportContextProps {
savedCustomReportId: string;
Expand Down Expand Up @@ -61,7 +60,7 @@ export const DatamapReportProvider = ({

const [columnOrder, setColumnOrder] = useLocalStorage<string[]>(
DATAMAP_LOCAL_STORAGE_KEYS.COLUMN_ORDER,
getColumnOrder(groupBy),
[],
);

const [columnVisibility, setColumnVisibility] = useLocalStorage<
Expand Down
25 changes: 12 additions & 13 deletions clients/admin-ui/src/features/datamap/reporting/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ export const getGrouping = (groupBy?: DATAMAP_GROUPING) => {
}
};

export const getColumnOrder = (groupBy: DATAMAP_GROUPING) => {
export const getColumnOrder = (
groupBy: DATAMAP_GROUPING,
columnIDs: string[],
) => {
let columnOrder: string[] = [];
if (DATAMAP_GROUPING.SYSTEM_DATA_USE === groupBy) {
columnOrder = [
COLUMN_IDS.SYSTEM_NAME,
COLUMN_IDS.DATA_USE,
COLUMN_IDS.DATA_CATEGORY,
COLUMN_IDS.DATA_SUBJECT,
];
columnOrder = [COLUMN_IDS.SYSTEM_NAME, COLUMN_IDS.DATA_USE];
}
if (DATAMAP_GROUPING.DATA_USE_SYSTEM === groupBy) {
columnOrder = [
COLUMN_IDS.DATA_USE,
COLUMN_IDS.SYSTEM_NAME,
COLUMN_IDS.DATA_CATEGORY,
COLUMN_IDS.DATA_SUBJECT,
];
columnOrder = [COLUMN_IDS.DATA_USE, COLUMN_IDS.SYSTEM_NAME];
}
columnOrder = columnOrder.concat(
columnIDs.filter(
(columnID) =>
columnID !== COLUMN_IDS.SYSTEM_NAME && columnID !== COLUMN_IDS.DATA_USE,
),
);
return columnOrder;
};

Expand Down

0 comments on commit 918f233

Please sign in to comment.