From 6489e64e46ff6c310ea9c9cd6b1868d6e426a07b Mon Sep 17 00:00:00 2001 From: Jeremy Pople Date: Thu, 31 Oct 2024 02:31:24 -0500 Subject: [PATCH 1/4] fix subfield naming --- .../tables/cells/ResultStatusCell.tsx | 3 ++- .../utils/getResourceName.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts diff --git a/clients/admin-ui/src/features/data-discovery-and-detection/tables/cells/ResultStatusCell.tsx b/clients/admin-ui/src/features/data-discovery-and-detection/tables/cells/ResultStatusCell.tsx index 554eb7b3ab..fa41077f30 100644 --- a/clients/admin-ui/src/features/data-discovery-and-detection/tables/cells/ResultStatusCell.tsx +++ b/clients/admin-ui/src/features/data-discovery-and-detection/tables/cells/ResultStatusCell.tsx @@ -3,6 +3,7 @@ import { Flex, Text, Tooltip } from "fidesui"; import { STATUS_INDICATOR_MAP } from "~/features/data-discovery-and-detection/statusIndicators"; import { ResourceChangeType } from "~/features/data-discovery-and-detection/types/ResourceChangeType"; import findResourceChangeType from "~/features/data-discovery-and-detection/utils/findResourceChangeType"; +import getResourceName from "~/features/data-discovery-and-detection/utils/getResourceName"; import resourceHasChildren from "~/features/data-discovery-and-detection/utils/resourceHasChildren"; import { StagedResource } from "~/types/api"; @@ -27,7 +28,7 @@ const ResultStatusCell = ({ overflow="hidden" textOverflow="ellipsis" > - {result.name} + {getResourceName(result)} ); diff --git a/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts new file mode 100644 index 0000000000..93fc8afdd4 --- /dev/null +++ b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts @@ -0,0 +1,19 @@ +import { DiscoveryMonitorItem } from "~/features/data-discovery-and-detection/types/DiscoveryMonitorItem"; + +const TOP_LEVEL_FIELD_URN_PARTS = 5; + +const getResourceName = (resource: DiscoveryMonitorItem) => { + const splitUrn = resource.urn.split("."); + if ( + !resource.parent_table_urn || + splitUrn.length === TOP_LEVEL_FIELD_URN_PARTS + ) { + // use name as-is if it's not a subfield + return resource.name; + } + // URN format is "monitor.project.dataset.field.[any number of subfields]" + // for a subfield, we want to show all subfield names separated by "." + return splitUrn.slice(5).join("."); +}; + +export default getResourceName; From 13f9cca54475f246e44a623eca818e8942f221a6 Mon Sep 17 00:00:00 2001 From: Jeremy Pople Date: Thu, 31 Oct 2024 02:41:00 -0500 Subject: [PATCH 2/4] apply const --- .../data-discovery-and-detection/utils/getResourceName.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts index 93fc8afdd4..2322db667d 100644 --- a/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts +++ b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts @@ -13,7 +13,7 @@ const getResourceName = (resource: DiscoveryMonitorItem) => { } // URN format is "monitor.project.dataset.field.[any number of subfields]" // for a subfield, we want to show all subfield names separated by "." - return splitUrn.slice(5).join("."); + return splitUrn.slice(TOP_LEVEL_FIELD_URN_PARTS).join("."); }; export default getResourceName; From f256f5b1fc981deeabf44ab57c054a1ca57ff493 Mon Sep 17 00:00:00 2001 From: Jeremy Pople Date: Thu, 31 Oct 2024 02:44:17 -0500 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d98aa8e5cf..a6ae2f3609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The types of changes are: ### Fixed - API router sanitizer being too aggressive with NextJS Catch-all Segments [#5438](https://github.com/ethyca/fides/pull/5438) + - Fix rendering of subfield names in D&D tables [#5439](https://github.com/ethyca/fides/pull/5439) ## [2.48.0](https://github.com/ethyca/fidesplus/compare/2.47.1...2.48.0) From dc1c9fbd14a29819c331fa53e44705a62bb47d25 Mon Sep 17 00:00:00 2001 From: Jeremy Pople Date: Tue, 5 Nov 2024 14:47:38 -0600 Subject: [PATCH 4/4] extract const; leave TODO --- .../data-discovery-and-detection/utils/getResourceName.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts index 2322db667d..0fc57caa7f 100644 --- a/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts +++ b/clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts @@ -3,7 +3,8 @@ import { DiscoveryMonitorItem } from "~/features/data-discovery-and-detection/ty const TOP_LEVEL_FIELD_URN_PARTS = 5; const getResourceName = (resource: DiscoveryMonitorItem) => { - const splitUrn = resource.urn.split("."); + const URN_SEPARATOR = "."; + const splitUrn = resource.urn.split(URN_SEPARATOR); if ( !resource.parent_table_urn || splitUrn.length === TOP_LEVEL_FIELD_URN_PARTS @@ -11,9 +12,11 @@ const getResourceName = (resource: DiscoveryMonitorItem) => { // use name as-is if it's not a subfield return resource.name; } + // TODO HJ-162: better handle case where field name contains "." + // URN format is "monitor.project.dataset.field.[any number of subfields]" // for a subfield, we want to show all subfield names separated by "." - return splitUrn.slice(TOP_LEVEL_FIELD_URN_PARTS).join("."); + return splitUrn.slice(TOP_LEVEL_FIELD_URN_PARTS).join(URN_SEPARATOR); }; export default getResourceName;