From 4f961dab2afbd52218da5e1512ba2497b11a8185 Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Wed, 26 Jul 2023 10:56:07 -0400 Subject: [PATCH] fix(ui) Fix broken dataPlatformInstance references in browseV2 (#8485) --- datahub-web-react/src/App.tsx | 2 + .../DataPlatformInstanceEntity.tsx | 61 +++++++++++++++++++ .../src/app/search/sidebar/BrowseNode.tsx | 3 +- .../src/graphql/fragments.graphql | 3 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 datahub-web-react/src/app/entity/dataPlatformInstance/DataPlatformInstanceEntity.tsx diff --git a/datahub-web-react/src/App.tsx b/datahub-web-react/src/App.tsx index 7b580d3c14643..1d9c9cbd27dbb 100644 --- a/datahub-web-react/src/App.tsx +++ b/datahub-web-react/src/App.tsx @@ -34,6 +34,7 @@ import { ContainerEntity } from './app/entity/container/ContainerEntity'; import GlossaryNodeEntity from './app/entity/glossaryNode/GlossaryNodeEntity'; import { DataPlatformEntity } from './app/entity/dataPlatform/DataPlatformEntity'; import { DataProductEntity } from './app/entity/dataProduct/DataProductEntity'; +import { DataPlatformInstanceEntity } from './app/entity/dataPlatformInstance/DataPlatformInstanceEntity'; /* Construct Apollo Client @@ -116,6 +117,7 @@ const App: React.VFC = () => { register.register(new GlossaryNodeEntity()); register.register(new DataPlatformEntity()); register.register(new DataProductEntity()); + register.register(new DataPlatformInstanceEntity()); return register; }, []); diff --git a/datahub-web-react/src/app/entity/dataPlatformInstance/DataPlatformInstanceEntity.tsx b/datahub-web-react/src/app/entity/dataPlatformInstance/DataPlatformInstanceEntity.tsx new file mode 100644 index 0000000000000..a542e1b52f510 --- /dev/null +++ b/datahub-web-react/src/app/entity/dataPlatformInstance/DataPlatformInstanceEntity.tsx @@ -0,0 +1,61 @@ +import * as React from 'react'; +import { DataPlatformInstance, EntityType } from '../../../types.generated'; +import { Entity } from '../Entity'; +import { GenericEntityProperties } from '../shared/types'; +import { getDataForEntityType } from '../shared/containers/profile/utils'; + +/** + * Definition of the DataHub DataPlatformInstance entity. + * Most of this still needs to be filled out. + */ +export class DataPlatformInstanceEntity implements Entity { + type: EntityType = EntityType.DataPlatformInstance; + + icon = () => { + return <>; + }; + + isSearchEnabled = () => false; + + isBrowseEnabled = () => false; + + isLineageEnabled = () => false; + + getAutoCompleteFieldName = () => 'name'; + + getPathName = () => 'dataPlatformInstance'; + + getEntityName = () => 'Data Platform Instance'; + + getCollectionName = () => 'Data Platform Instances'; + + renderProfile = () => <>; + + getOverridePropertiesFromEntity = (): GenericEntityProperties => { + return {}; + }; + + renderPreview = () => { + return <>; + }; + + renderSearch = () => { + return <>; + }; + + displayName = (data: DataPlatformInstance) => { + return data?.instanceId || data.urn; + }; + + getGenericEntityProperties = (data: DataPlatformInstance) => { + return getDataForEntityType({ + data, + entityType: this.type, + getOverrideProperties: this.getOverridePropertiesFromEntity, + }); + }; + + supportedCapabilities = () => { + return new Set([]); + }; +} diff --git a/datahub-web-react/src/app/search/sidebar/BrowseNode.tsx b/datahub-web-react/src/app/search/sidebar/BrowseNode.tsx index ab066027eff52..2125c7a90a3d6 100644 --- a/datahub-web-react/src/app/search/sidebar/BrowseNode.tsx +++ b/datahub-web-react/src/app/search/sidebar/BrowseNode.tsx @@ -21,6 +21,7 @@ import { } from './BrowseContext'; import useSidebarAnalytics from './useSidebarAnalytics'; import EntityLink from './EntityLink'; +import { EntityType } from '../../../types.generated'; const FolderStyled = styled(FolderOutlined)` font-size: 16px; @@ -42,7 +43,7 @@ const BrowseNode = () => { const platformAggregation = usePlatformAggregation(); const browseResultGroup = useBrowseResultGroup(); const { count, entity } = browseResultGroup; - const hasEntityLink = !!entity; + const hasEntityLink = !!entity && entity.type !== EntityType.DataPlatformInstance; const displayName = useBrowseDisplayName(); const { trackSelectNodeEvent, trackToggleNodeEvent } = useSidebarAnalytics(); diff --git a/datahub-web-react/src/graphql/fragments.graphql b/datahub-web-react/src/graphql/fragments.graphql index f0e6841c9f86c..219722ad1645a 100644 --- a/datahub-web-react/src/graphql/fragments.graphql +++ b/datahub-web-react/src/graphql/fragments.graphql @@ -1112,4 +1112,7 @@ fragment entityDisplayNameFields on Entity { name } } + ... on DataPlatformInstance { + instanceId + } }