Skip to content

Commit

Permalink
feat(containers): Adding Containers UI (as demo'd in Jan Townhall) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored Feb 2, 2022
1 parent f20382f commit 169cd4f
Show file tree
Hide file tree
Showing 32 changed files with 621 additions and 146 deletions.
3 changes: 2 additions & 1 deletion datahub-web-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { BrowserRouter as Router } from 'react-router-dom';
import { ApolloClient, ApolloProvider, createHttpLink, InMemoryCache, ServerError } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import { ThemeProvider } from 'styled-components';

import './App.less';
import { Routes } from './app/Routes';
import EntityRegistry from './app/entity/EntityRegistry';
Expand All @@ -30,6 +29,7 @@ import { MLFeatureTableEntity } from './app/entity/mlFeatureTable/MLFeatureTable
import { MLModelEntity } from './app/entity/mlModel/MLModelEntity';
import { MLModelGroupEntity } from './app/entity/mlModelGroup/MLModelGroupEntity';
import { DomainEntity } from './app/entity/domain/DomainEntity';
import { ContainerEntity } from './app/entity/container/ContainerEntity';

/*
Construct Apollo Client
Expand Down Expand Up @@ -96,6 +96,7 @@ const App: React.VFC = () => {
register.register(new MLModelEntity());
register.register(new MLModelGroupEntity());
register.register(new DomainEntity());
register.register(new ContainerEntity());
return register;
}, []);

Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const dataset1 = {
},
],
domain: null,
container: null,
};

const dataset2 = {
Expand Down Expand Up @@ -260,6 +261,7 @@ const dataset2 = {
},
],
domain: null,
container: null,
};

export const dataset3 = {
Expand Down Expand Up @@ -447,6 +449,7 @@ export const dataset3 = {
},
],
domain: null,
container: null,
} as Dataset;

export const dataset4 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {
AccessLevel,
Domain,
Container,
EntityType,
GlobalTags,
GlossaryTerms,
Expand All @@ -22,6 +23,7 @@ export const ChartPreview = ({
tags,
glossaryTerms,
domain,
container,
insights,
logoUrl,
}: {
Expand All @@ -34,6 +36,7 @@ export const ChartPreview = ({
tags?: GlobalTags;
glossaryTerms?: GlossaryTerms | null;
domain?: Domain | null;
container?: Container | null;
insights?: Array<SearchInsight> | null;
logoUrl?: string | null;
}): JSX.Element => {
Expand All @@ -53,6 +56,7 @@ export const ChartPreview = ({
owners={owners}
glossaryTerms={glossaryTerms || undefined}
domain={domain}
container={container || undefined}
insights={insights}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { useEntityData } from '../shared/EntityContext';
import { EmbeddedListSearch } from '../shared/components/styled/search/EmbeddedListSearch';

export const ContainerEntitiesTab = () => {
const { urn } = useEntityData();

const fixedFilter = {
field: 'container',
value: urn,
};

return (
<EmbeddedListSearch
fixedFilter={fixedFilter}
emptySearchQuery="*"
placeholderText="Filter container entities..."
/>
);
};
159 changes: 159 additions & 0 deletions datahub-web-react/src/app/entity/container/ContainerEntity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import * as React from 'react';
import { FolderOutlined } from '@ant-design/icons';
import { Container, EntityType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Preview } from './preview/Preview';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
import { SidebarAboutSection } from '../shared/containers/profile/sidebar/SidebarAboutSection';
import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/SidebarOwnerSection';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { useGetContainerQuery } from '../../../graphql/container.generated';
import { ContainerEntitiesTab } from './ContainerEntitiesTab';
import { SidebarRecommendationsSection } from '../shared/containers/profile/sidebar/Recommendations/SidebarRecommendationsSection';
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';

/**
* Definition of the DataHub Container entity.
*/
export class ContainerEntity implements Entity<Container> {
type: EntityType = EntityType.Container;

icon = (fontSize: number, styleType: IconStyleType) => {
if (styleType === IconStyleType.TAB_VIEW) {
return <FolderOutlined />;
}

if (styleType === IconStyleType.HIGHLIGHT) {
return <FolderOutlined style={{ fontSize, color: '#B37FEB' }} />;
}

if (styleType === IconStyleType.SVG) {
return (
<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" />
);
}

return (
<FolderOutlined
style={{
fontSize,
color: '#BFBFBF',
}}
/>
);
};

isSearchEnabled = () => true;

isBrowseEnabled = () => false;

isLineageEnabled = () => false;

getAutoCompleteFieldName = () => 'name';

getPathName = () => 'container';

getEntityName = () => 'Container';

getCollectionName = () => 'Containers';

renderProfile = (urn: string) => (
<EntityProfile
urn={urn}
entityType={EntityType.Container}
useEntityQuery={useGetContainerQuery}
useUpdateQuery={undefined}
getOverrideProperties={this.getOverridePropertiesFromEntity}
tabs={[
{
name: 'Entities',
component: ContainerEntitiesTab,
},
{
name: 'Documentation',
component: DocumentationTab,
},
{
name: 'Properties',
component: PropertiesTab,
},
]}
sidebarSections={[
{
component: SidebarAboutSection,
},
{
component: SidebarTagsSection,
properties: {
hasTags: true,
hasTerms: true,
},
},
{
component: SidebarOwnerSection,
},
{
component: SidebarDomainSection,
},
{
component: SidebarRecommendationsSection,
},
]}
/>
);

renderPreview = (_: PreviewType, data: Container) => {
return (
<Preview
urn={data.urn}
name={this.displayName(data)}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data.platform.properties?.logoUrl}
description={data.properties?.description}
owners={data.ownership?.owners}
subTypes={data.subTypes}
container={data.container}
entityCount={data.entities?.total}
/>
);
};

renderSearch = (result: SearchResult) => {
const data = result.entity as Container;
return (
<Preview
urn={data.urn}
name={this.displayName(data)}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data.platform.properties?.logoUrl}
description={data.properties?.description}
owners={data.ownership?.owners}
subTypes={data.subTypes}
container={data.container}
entityCount={data.entities?.total}
/>
);
};

displayName = (data: Container) => {
return data?.properties?.name || data?.urn;
};

getOverridePropertiesFromEntity = (data: Container) => {
return {
name: this.displayName(data),
entityCount: data.entities?.total,
};
};

getGenericEntityProperties = (data: Container) => {
return getDataForEntityType({
data,
entityType: this.type,
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};
}
50 changes: 50 additions & 0 deletions datahub-web-react/src/app/entity/container/preview/Preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { Container, EntityType, Owner, SearchInsight, SubTypes } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType } from '../../Entity';

export const Preview = ({
urn,
name,
platformName,
platformLogo,
description,
owners,
insights,
subTypes,
logoComponent,
container,
entityCount,
}: {
urn: string;
name: string;
platformName: string;
platformLogo?: string | null;
description?: string | null;
owners?: Array<Owner> | null;
insights?: Array<SearchInsight> | null;
subTypes?: SubTypes | null;
logoComponent?: JSX.Element;
container?: Container | null;
entityCount?: number;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const typeName = (subTypes?.typeNames?.length && subTypes?.typeNames[0]) || 'Container';
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.Container, urn)}
name={name || ''}
platform={platformName}
description={description || ''}
type={typeName}
owners={owners}
insights={insights}
logoUrl={platformLogo || undefined}
logoComponent={logoComponent}
container={container || undefined}
typeIcon={entityRegistry.getIcon(EntityType.Container, 12, IconStyleType.ACCENT)}
entityCount={entityCount}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class DashboardEntity implements Entity<Dashboard> {
glossaryTerms={data?.glossaryTerms}
logoUrl={data?.platform?.properties?.logoUrl}
domain={data.domain}
container={data.container}
/>
);
};
Expand All @@ -166,6 +167,7 @@ export class DashboardEntity implements Entity<Dashboard> {
insights={result.insights}
logoUrl={data?.platform?.properties?.logoUrl || ''}
domain={data.domain}
container={data.container}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {
AccessLevel,
Domain,
Container,
EntityType,
GlobalTags,
GlossaryTerms,
Expand All @@ -22,6 +23,7 @@ export const DashboardPreview = ({
tags,
glossaryTerms,
domain,
container,
insights,
logoUrl,
}: {
Expand All @@ -34,6 +36,7 @@ export const DashboardPreview = ({
tags?: GlobalTags;
glossaryTerms?: GlossaryTerms | null;
domain?: Domain | null;
container?: Container | null;
insights?: Array<SearchInsight> | null;
logoUrl?: string | null;
}): JSX.Element => {
Expand All @@ -51,6 +54,7 @@ export const DashboardPreview = ({
qualifier={access}
owners={owners}
tags={tags}
container={container || undefined}
glossaryTerms={glossaryTerms || undefined}
domain={domain}
insights={insights}
Expand Down
8 changes: 5 additions & 3 deletions datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DatasetEntity implements Entity<Dataset> {
}

return (
<DatabaseFilled
<DatabaseOutlined
style={{
fontSize,
color: '#BFBFBF',
Expand Down Expand Up @@ -192,12 +192,13 @@ export class DatasetEntity implements Entity<Dataset> {
origin={data.origin}
subtype={data.subTypes?.typeNames?.[0]}
description={data.editableProperties?.description || data.properties?.description}
platformName={data.platform.displayName || data.platform.name}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data.platform.properties?.logoUrl}
owners={data.ownership?.owners}
globalTags={data.globalTags}
glossaryTerms={data.glossaryTerms}
domain={data.domain}
container={data.container}
/>
);
};
Expand All @@ -210,13 +211,14 @@ export class DatasetEntity implements Entity<Dataset> {
name={data.name}
origin={data.origin}
description={data.editableProperties?.description || data.properties?.description}
platformName={data.platform.name}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data.platform.properties?.logoUrl}
owners={data.ownership?.owners}
globalTags={data.globalTags}
domain={data.domain}
glossaryTerms={data.glossaryTerms}
subtype={data.subTypes?.typeNames?.[0]}
container={data.container}
snippet={
// Add match highlights only if all the matched fields are in the FIELDS_TO_HIGHLIGHT
result.matchedFields.length > 0 &&
Expand Down
Loading

0 comments on commit 169cd4f

Please sign in to comment.