2021-02-03 11:49:51 -08:00
|
|
|
import * as React from 'react';
|
2021-02-23 12:45:42 -08:00
|
|
|
import { DatabaseFilled, DatabaseOutlined } from '@ant-design/icons';
|
2021-10-14 10:11:56 -07:00
|
|
|
import { Typography } from 'antd';
|
2022-03-14 11:14:32 -07:00
|
|
|
import { Dataset, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
|
2021-02-23 12:45:42 -08:00
|
|
|
import { Entity, IconStyleType, PreviewType } from '../Entity';
|
2021-02-03 11:49:51 -08:00
|
|
|
import { Preview } from './preview/Preview';
|
2021-03-23 15:18:32 -07:00
|
|
|
import { FIELDS_TO_HIGHLIGHT } from './search/highlights';
|
2021-08-31 22:00:56 -07:00
|
|
|
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
|
|
|
|
import { GetDatasetQuery, useGetDatasetQuery, useUpdateDatasetMutation } from '../../../graphql/dataset.generated';
|
|
|
|
import { GenericEntityProperties } from '../shared/types';
|
|
|
|
import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
|
|
|
|
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
|
|
|
|
import { SchemaTab } from '../shared/tabs/Dataset/Schema/SchemaTab';
|
|
|
|
import QueriesTab from '../shared/tabs/Dataset/Queries/QueriesTab';
|
|
|
|
import { SidebarAboutSection } from '../shared/containers/profile/sidebar/SidebarAboutSection';
|
|
|
|
import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/SidebarOwnerSection';
|
|
|
|
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
|
|
|
|
import { SidebarStatsSection } from '../shared/containers/profile/sidebar/Dataset/StatsSidebarSection';
|
|
|
|
import StatsTab from '../shared/tabs/Dataset/Stats/StatsTab';
|
|
|
|
import { LineageTab } from '../shared/tabs/Lineage/LineageTab';
|
2022-01-27 10:33:12 -08:00
|
|
|
import { capitalizeFirstLetter } from '../../shared/textUtil';
|
2021-10-12 15:47:29 -07:00
|
|
|
import ViewDefinitionTab from '../shared/tabs/Dataset/View/ViewDefinitionTab';
|
|
|
|
import { SidebarViewDefinitionSection } from '../shared/containers/profile/sidebar/Dataset/View/SidebarViewDefinitionSection';
|
2021-10-26 21:23:08 -07:00
|
|
|
import { SidebarRecommendationsSection } from '../shared/containers/profile/sidebar/Recommendations/SidebarRecommendationsSection';
|
|
|
|
import { getDataForEntityType } from '../shared/containers/profile/utils';
|
2022-01-27 22:02:41 -08:00
|
|
|
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
|
2022-03-04 11:51:31 -08:00
|
|
|
import { ValidationsTab } from '../shared/tabs/Dataset/Validations/ValidationsTab';
|
2021-03-23 15:18:32 -07:00
|
|
|
|
2021-10-12 15:47:29 -07:00
|
|
|
const SUBTYPES = {
|
|
|
|
VIEW: 'view',
|
|
|
|
};
|
|
|
|
|
2021-02-03 11:49:51 -08:00
|
|
|
/**
|
|
|
|
* Definition of the DataHub Dataset entity.
|
|
|
|
*/
|
|
|
|
export class DatasetEntity implements Entity<Dataset> {
|
|
|
|
type: EntityType = EntityType.Dataset;
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
icon = (fontSize: number, styleType: IconStyleType) => {
|
|
|
|
if (styleType === IconStyleType.TAB_VIEW) {
|
|
|
|
return <DatabaseOutlined style={{ fontSize }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (styleType === IconStyleType.HIGHLIGHT) {
|
|
|
|
return <DatabaseFilled style={{ fontSize, color: '#B37FEB' }} />;
|
|
|
|
}
|
|
|
|
|
2021-04-17 00:46:02 +08:00
|
|
|
if (styleType === IconStyleType.SVG) {
|
|
|
|
return (
|
2021-04-19 11:58:04 -07:00
|
|
|
<path d="M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z" />
|
2021-04-17 00:46:02 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
return (
|
2022-02-02 13:51:39 -08:00
|
|
|
<DatabaseOutlined
|
2021-02-23 12:45:42 -08:00
|
|
|
style={{
|
|
|
|
fontSize,
|
|
|
|
color: '#BFBFBF',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-02-03 11:49:51 -08:00
|
|
|
isSearchEnabled = () => true;
|
|
|
|
|
|
|
|
isBrowseEnabled = () => true;
|
|
|
|
|
2021-04-09 11:55:25 -07:00
|
|
|
isLineageEnabled = () => true;
|
|
|
|
|
2021-02-03 11:49:51 -08:00
|
|
|
getAutoCompleteFieldName = () => 'name';
|
|
|
|
|
|
|
|
getPathName = () => 'dataset';
|
|
|
|
|
2021-09-28 10:30:37 -07:00
|
|
|
getEntityName = () => 'Dataset';
|
|
|
|
|
2021-02-03 11:49:51 -08:00
|
|
|
getCollectionName = () => 'Datasets';
|
|
|
|
|
2021-08-31 22:00:56 -07:00
|
|
|
renderProfile = (urn: string) => (
|
|
|
|
<EntityProfile
|
|
|
|
urn={urn}
|
|
|
|
entityType={EntityType.Dataset}
|
|
|
|
useEntityQuery={useGetDatasetQuery}
|
|
|
|
useUpdateQuery={useUpdateDatasetMutation}
|
2021-10-26 21:23:08 -07:00
|
|
|
getOverrideProperties={this.getOverridePropertiesFromEntity}
|
2021-08-31 22:00:56 -07:00
|
|
|
tabs={[
|
|
|
|
{
|
|
|
|
name: 'Schema',
|
|
|
|
component: SchemaTab,
|
|
|
|
},
|
2021-10-12 15:47:29 -07:00
|
|
|
{
|
|
|
|
name: 'View Definition',
|
|
|
|
component: ViewDefinitionTab,
|
|
|
|
display: {
|
|
|
|
visible: (_, dataset: GetDatasetQuery) =>
|
2021-10-13 13:28:13 -07:00
|
|
|
(dataset?.dataset?.subTypes?.typeNames?.includes(SUBTYPES.VIEW) && true) || false,
|
2021-10-12 15:47:29 -07:00
|
|
|
enabled: (_, dataset: GetDatasetQuery) =>
|
|
|
|
(dataset?.dataset?.viewProperties?.logic && true) || false,
|
|
|
|
},
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
{
|
|
|
|
name: 'Documentation',
|
|
|
|
component: DocumentationTab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Properties',
|
|
|
|
component: PropertiesTab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Lineage',
|
|
|
|
component: LineageTab,
|
2021-10-12 15:47:29 -07:00
|
|
|
display: {
|
|
|
|
visible: (_, _1) => true,
|
2022-03-10 15:23:47 -08:00
|
|
|
enabled: (_, dataset: GetDatasetQuery) => {
|
|
|
|
console.log(dataset?.dataset?.upstream, dataset?.dataset?.downstream);
|
|
|
|
return (
|
|
|
|
(dataset?.dataset?.upstream?.total || 0) > 0 ||
|
|
|
|
(dataset?.dataset?.downstream?.total || 0) > 0
|
|
|
|
);
|
|
|
|
},
|
2021-10-12 15:47:29 -07:00
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Queries',
|
|
|
|
component: QueriesTab,
|
2021-10-12 15:47:29 -07:00
|
|
|
display: {
|
|
|
|
visible: (_, _1) => true,
|
|
|
|
enabled: (_, dataset: GetDatasetQuery) =>
|
|
|
|
(dataset?.dataset?.usageStats?.buckets?.length || 0) > 0,
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Stats',
|
|
|
|
component: StatsTab,
|
2021-10-12 15:47:29 -07:00
|
|
|
display: {
|
|
|
|
visible: (_, _1) => true,
|
|
|
|
enabled: (_, dataset: GetDatasetQuery) =>
|
|
|
|
(dataset?.dataset?.datasetProfiles?.length || 0) > 0 ||
|
2022-01-07 15:27:09 -10:00
|
|
|
(dataset?.dataset?.usageStats?.buckets?.length || 0) > 0 ||
|
|
|
|
(dataset?.dataset?.operations?.length || 0) > 0,
|
2021-10-12 15:47:29 -07:00
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
2022-03-04 11:51:31 -08:00
|
|
|
{
|
|
|
|
name: 'Validation',
|
|
|
|
component: ValidationsTab,
|
|
|
|
display: {
|
|
|
|
visible: (_, _1) => true,
|
|
|
|
enabled: (_, dataset: GetDatasetQuery) => {
|
|
|
|
return (dataset?.dataset?.assertions?.total || 0) > 0;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
]}
|
|
|
|
sidebarSections={[
|
|
|
|
{
|
|
|
|
component: SidebarAboutSection,
|
|
|
|
},
|
2021-10-12 15:47:29 -07:00
|
|
|
{
|
|
|
|
component: SidebarViewDefinitionSection,
|
|
|
|
display: {
|
|
|
|
visible: (_, dataset: GetDatasetQuery) =>
|
|
|
|
(dataset?.dataset?.viewProperties?.logic && true) || false,
|
|
|
|
},
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
{
|
|
|
|
component: SidebarStatsSection,
|
2021-10-12 15:47:29 -07:00
|
|
|
display: {
|
|
|
|
visible: (_, dataset: GetDatasetQuery) =>
|
|
|
|
(dataset?.dataset?.datasetProfiles?.length || 0) > 0 ||
|
|
|
|
(dataset?.dataset?.usageStats?.buckets?.length || 0) > 0,
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: SidebarTagsSection,
|
2021-09-13 09:16:37 -07:00
|
|
|
properties: {
|
|
|
|
hasTags: true,
|
|
|
|
hasTerms: true,
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
component: SidebarOwnerSection,
|
2022-03-14 11:14:32 -07:00
|
|
|
properties: {
|
|
|
|
defaultOwnerType: OwnershipType.TechnicalOwner,
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
},
|
2022-01-27 22:02:41 -08:00
|
|
|
{
|
|
|
|
component: SidebarDomainSection,
|
|
|
|
},
|
2021-10-26 21:23:08 -07:00
|
|
|
{
|
|
|
|
component: SidebarRecommendationsSection,
|
|
|
|
},
|
2021-08-31 22:00:56 -07:00
|
|
|
]}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-10-26 21:23:08 -07:00
|
|
|
getOverridePropertiesFromEntity = (dataset?: Dataset | null): GenericEntityProperties => {
|
2021-10-06 23:39:52 -07:00
|
|
|
// if dataset has subTypes filled out, pick the most specific subtype and return it
|
2021-10-26 21:23:08 -07:00
|
|
|
const subTypes = dataset?.subTypes;
|
2021-10-06 07:13:38 -07:00
|
|
|
return {
|
2022-03-05 01:22:04 +05:30
|
|
|
name: dataset?.properties?.name || dataset?.name,
|
2021-10-26 21:23:08 -07:00
|
|
|
externalUrl: dataset?.properties?.externalUrl,
|
2021-10-06 23:39:52 -07:00
|
|
|
entityTypeOverride: subTypes ? capitalizeFirstLetter(subTypes.typeNames?.[0]) : '',
|
2021-10-06 07:13:38 -07:00
|
|
|
};
|
2021-08-31 22:00:56 -07:00
|
|
|
};
|
2021-02-03 11:49:51 -08:00
|
|
|
|
2021-02-09 14:30:23 -08:00
|
|
|
renderPreview = (_: PreviewType, data: Dataset) => {
|
2021-02-03 11:49:51 -08:00
|
|
|
return (
|
|
|
|
<Preview
|
|
|
|
urn={data.urn}
|
2022-03-05 01:22:04 +05:30
|
|
|
name={data.properties?.name || data.name}
|
2021-02-03 11:49:51 -08:00
|
|
|
origin={data.origin}
|
2021-10-06 23:39:52 -07:00
|
|
|
subtype={data.subTypes?.typeNames?.[0]}
|
2021-11-08 16:24:50 -08:00
|
|
|
description={data.editableProperties?.description || data.properties?.description}
|
2022-02-02 13:51:39 -08:00
|
|
|
platformName={data.platform.properties?.displayName || data.platform.name}
|
2022-01-25 21:03:31 -06:00
|
|
|
platformLogo={data.platform.properties?.logoUrl}
|
2021-02-23 12:45:42 -08:00
|
|
|
owners={data.ownership?.owners}
|
2021-03-07 11:26:47 -08:00
|
|
|
globalTags={data.globalTags}
|
2021-05-25 10:42:35 +05:30
|
|
|
glossaryTerms={data.glossaryTerms}
|
2022-01-27 22:02:41 -08:00
|
|
|
domain={data.domain}
|
2022-02-02 13:51:39 -08:00
|
|
|
container={data.container}
|
2021-02-03 11:49:51 -08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2021-03-23 15:18:32 -07:00
|
|
|
|
|
|
|
renderSearch = (result: SearchResult) => {
|
|
|
|
const data = result.entity as Dataset;
|
|
|
|
return (
|
|
|
|
<Preview
|
|
|
|
urn={data.urn}
|
2022-03-05 01:22:04 +05:30
|
|
|
name={data.properties?.name || data.name}
|
2021-03-23 15:18:32 -07:00
|
|
|
origin={data.origin}
|
2021-11-08 16:24:50 -08:00
|
|
|
description={data.editableProperties?.description || data.properties?.description}
|
2022-02-02 13:51:39 -08:00
|
|
|
platformName={data.platform.properties?.displayName || data.platform.name}
|
2022-01-25 21:03:31 -06:00
|
|
|
platformLogo={data.platform.properties?.logoUrl}
|
2021-03-23 15:18:32 -07:00
|
|
|
owners={data.ownership?.owners}
|
|
|
|
globalTags={data.globalTags}
|
2022-01-27 22:02:41 -08:00
|
|
|
domain={data.domain}
|
2021-10-12 23:21:43 -07:00
|
|
|
glossaryTerms={data.glossaryTerms}
|
2021-10-06 23:39:52 -07:00
|
|
|
subtype={data.subTypes?.typeNames?.[0]}
|
2022-02-02 13:51:39 -08:00
|
|
|
container={data.container}
|
2021-03-23 15:18:32 -07:00
|
|
|
snippet={
|
|
|
|
// Add match highlights only if all the matched fields are in the FIELDS_TO_HIGHLIGHT
|
|
|
|
result.matchedFields.length > 0 &&
|
|
|
|
result.matchedFields.every((field) => FIELDS_TO_HIGHLIGHT.has(field.name)) && (
|
2021-10-14 10:11:56 -07:00
|
|
|
<Typography.Text>
|
|
|
|
Matches {FIELDS_TO_HIGHLIGHT.get(result.matchedFields[0].name)}{' '}
|
|
|
|
<b>{result.matchedFields[0].value}</b>
|
|
|
|
</Typography.Text>
|
2021-03-23 15:18:32 -07:00
|
|
|
)
|
|
|
|
}
|
2021-10-14 10:11:56 -07:00
|
|
|
insights={result.insights}
|
2021-03-23 15:18:32 -07:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2021-04-09 11:55:25 -07:00
|
|
|
|
|
|
|
getLineageVizConfig = (entity: Dataset) => {
|
|
|
|
return {
|
2021-10-22 15:46:46 -07:00
|
|
|
urn: entity?.urn,
|
2022-03-05 01:22:04 +05:30
|
|
|
name: entity.properties?.name || entity.name,
|
2021-04-09 11:55:25 -07:00
|
|
|
type: EntityType.Dataset,
|
2021-10-06 23:39:52 -07:00
|
|
|
subtype: entity.subTypes?.typeNames?.[0] || undefined,
|
2022-01-25 21:03:31 -06:00
|
|
|
icon: entity?.platform?.properties?.logoUrl || undefined,
|
2021-10-22 15:46:46 -07:00
|
|
|
platform: entity?.platform?.name,
|
2021-04-09 11:55:25 -07:00
|
|
|
};
|
|
|
|
};
|
2021-09-02 19:05:13 -07:00
|
|
|
|
|
|
|
displayName = (data: Dataset) => {
|
2022-03-05 01:22:04 +05:30
|
|
|
return data?.properties?.name || data.name;
|
2021-09-02 19:05:13 -07:00
|
|
|
};
|
2021-10-26 21:23:08 -07:00
|
|
|
|
|
|
|
platformLogoUrl = (data: Dataset) => {
|
2022-01-25 21:03:31 -06:00
|
|
|
return data.platform.properties?.logoUrl || undefined;
|
2021-10-26 21:23:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
getGenericEntityProperties = (data: Dataset) => {
|
|
|
|
return getDataForEntityType({
|
|
|
|
data,
|
|
|
|
entityType: this.type,
|
|
|
|
getOverrideProperties: this.getOverridePropertiesFromEntity,
|
|
|
|
});
|
|
|
|
};
|
2021-02-03 11:49:51 -08:00
|
|
|
}
|