forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): Add SchemaFieldEntity to search functionality
- Loading branch information
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
datahub-web-react/src/app/entity/schemaField/SchemaFieldPropertiesEntity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
import { PicCenterOutlined } from '@ant-design/icons'; | ||
import { EntityType, SchemaFieldEntity, SearchResult } from '../../../types.generated'; | ||
import { Entity, IconStyleType, PreviewType } from '../Entity'; | ||
import { getDataForEntityType } from '../shared/containers/profile/utils'; | ||
import { Preview } from './preview/Preview'; | ||
|
||
export class SchemaFieldPropertiesEntity implements Entity<SchemaFieldEntity> { | ||
type: EntityType = EntityType.SchemaField; | ||
|
||
icon = (fontSize: number, styleType: IconStyleType, color = '#BFBFBF') => ( | ||
<PicCenterOutlined style={{ fontSize, color }} /> | ||
); | ||
|
||
isSearchEnabled = () => true; | ||
|
||
isBrowseEnabled = () => false; | ||
|
||
isLineageEnabled = () => false; | ||
|
||
// Currently unused. | ||
getAutoCompleteFieldName = () => 'schemaField'; | ||
|
||
// Currently unused. | ||
getPathName = () => 'schemaField'; | ||
|
||
// Currently unused. | ||
getEntityName = () => 'schemaField'; | ||
|
||
// Currently unused. | ||
getCollectionName = () => 'schemaFields'; | ||
|
||
// Currently unused. | ||
renderProfile = (_: string) => <></>; | ||
|
||
renderPreview = (previewType: PreviewType, data: SchemaFieldEntity) => ( | ||
<Preview | ||
previewType={previewType} | ||
datasetUrn={data.parent.urn} | ||
businessAttributeUrn={data.businessAttributes?.businessAttribute?.businessAttribute.urn || ''} | ||
name={data.fieldPath} | ||
/> | ||
); | ||
|
||
renderSearch = (result: SearchResult) => this.renderPreview(PreviewType.SEARCH, result.entity as SchemaFieldEntity); | ||
|
||
displayName = (data: SchemaFieldEntity) => data?.fieldPath || data.urn; | ||
|
||
getGenericEntityProperties = (data: SchemaFieldEntity) => | ||
getDataForEntityType({ data, entityType: this.type, getOverrideProperties: (newData) => newData }); | ||
|
||
supportedCapabilities = () => new Set([]); | ||
} |
50 changes: 50 additions & 0 deletions
50
datahub-web-react/src/app/entity/schemaField/preview/Preview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { PicCenterOutlined } from '@ant-design/icons'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { EntityType, Owner } from '../../../../types.generated'; | ||
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard'; | ||
import { useEntityRegistry } from '../../../useEntityRegistry'; | ||
import { IconStyleType, PreviewType } from '../../Entity'; | ||
import UrlButton from '../../shared/UrlButton'; | ||
import { getRelatedEntitiesUrl } from '../../../businessAttribute/businessAttributeUtils'; | ||
|
||
export const Preview = ({ | ||
datasetUrn, | ||
businessAttributeUrn, | ||
name, | ||
description, | ||
owners, | ||
previewType, | ||
}: { | ||
datasetUrn: string; | ||
businessAttributeUrn: string; | ||
name: string; | ||
description?: string | null; | ||
owners?: Array<Owner> | null; | ||
previewType: PreviewType; | ||
}): JSX.Element => { | ||
const entityRegistry = useEntityRegistry(); | ||
const location = useLocation(); | ||
const relatedEntitiesUrl = getRelatedEntitiesUrl(entityRegistry, businessAttributeUrn); | ||
|
||
const url = `${entityRegistry.getEntityUrl(EntityType.Dataset, datasetUrn)}/${encodeURIComponent('Schema')}?schemaFilter=${encodeURIComponent('customer_id')}`; | ||
|
||
return ( | ||
<DefaultPreviewCard | ||
previewType={previewType} | ||
url={url} | ||
name={name ?? ''} | ||
urn={datasetUrn} | ||
description={description ?? ''} | ||
owners={owners} | ||
logoComponent={<PicCenterOutlined style={{ fontSize: '20px' }} />} | ||
type="Column" | ||
typeIcon={entityRegistry.getIcon(EntityType.SchemaField, 14, IconStyleType.ACCENT)} | ||
entityTitleSuffix={ | ||
decodeURIComponent(location.pathname) !== decodeURIComponent(relatedEntitiesUrl) && ( | ||
<UrlButton href={relatedEntitiesUrl}>View Related Entities</UrlButton> | ||
) | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters