Skip to content

Commit

Permalink
perf(ui): Performance improvements and misc refactorings in the UI (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored Jul 1, 2022
1 parent b02c7f5 commit c9be9e0
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 139 deletions.
14 changes: 11 additions & 3 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,15 @@ export const dataFlow1 = {
],
},
platform: {
...dataPlatform,
urn: 'urn:li:dataPlatform:airflow',
name: 'Airflow',
type: EntityType.DataPlatform,
properties: {
displayName: 'Airflow',
type: PlatformType.FileSystem,
datasetNameDelimiter: '.',
logoUrl: '',
},
},
domain: null,
deprecation: null,
Expand Down Expand Up @@ -1754,7 +1762,7 @@ export const mocks = [
variables: {
input: {
query: 't',
limit: 30,
limit: 10,
},
},
},
Expand Down Expand Up @@ -3235,7 +3243,7 @@ export const mocks = [
types: [],
query: '*',
start: 0,
count: 20,
count: 6,
filters: [],
},
},
Expand Down
21 changes: 4 additions & 17 deletions datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LineChartOutlined } from '@ant-design/icons';
import * as React from 'react';
import { Chart, EntityType, PlatformType, SearchResult } from '../../../types.generated';
import { Chart, EntityType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { ChartPreview } from './preview/ChartPreview';
import { GetChartQuery, useGetChartQuery, useUpdateChartMutation } from '../../../graphql/chart.generated';
Expand All @@ -14,7 +14,6 @@ import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
import { ChartInputsTab } from '../shared/tabs/Entity/ChartInputsTab';
import { ChartDashboardsTab } from '../shared/tabs/Entity/ChartDashboardsTab';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { capitalizeFirstLetter } from '../../shared/textUtil';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';

Expand Down Expand Up @@ -120,31 +119,19 @@ export class ChartEntity implements Entity<Chart> {

getOverridePropertiesFromEntity = (chart?: Chart | null): GenericEntityProperties => {
// TODO: Get rid of this once we have correctly formed platform coming back.
const tool = chart?.tool || '';
const name = chart?.properties?.name;
const externalUrl = chart?.properties?.externalUrl;
return {
name,
externalUrl,
platform: {
urn: `urn:li:dataPlatform:(${tool})`,
type: EntityType.DataPlatform,
name: tool,
properties: {
logoUrl: chart?.platform?.properties?.logoUrl,
displayName: capitalizeFirstLetter(tool),
type: PlatformType.Others,
datasetNameDelimiter: '.',
},
},
};
};

renderPreview = (_: PreviewType, data: Chart) => {
return (
<ChartPreview
urn={data.urn}
platform={data.tool}
platform={data.platform.properties?.displayName || data.platform.name}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
access={data.properties?.access}
Expand All @@ -163,7 +150,7 @@ export class ChartEntity implements Entity<Chart> {
return (
<ChartPreview
urn={data.urn}
platform={data.tool}
platform={data.platform.properties?.displayName || data.platform.name}
platformInstanceId={data.dataPlatformInstance?.instanceId}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
Expand All @@ -184,7 +171,7 @@ export class ChartEntity implements Entity<Chart> {
name: entity.properties?.name || '',
type: EntityType.Chart,
icon: entity?.platform?.properties?.logoUrl || '',
platform: entity.tool,
platform: entity?.platform.properties?.displayName || entity?.platform.name,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';

export const ChartPreview = ({
urn,
Expand Down Expand Up @@ -54,6 +55,7 @@ export const ChartPreview = ({
name={name || ''}
description={description || ''}
type="Chart"
typeIcon={entityRegistry.getIcon(EntityType.Chart, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platform={capitalizedPlatform}
platformInstanceId={platformInstanceId}
Expand Down
21 changes: 4 additions & 17 deletions datahub-web-react/src/app/entity/dashboard/DashboardEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useGetDashboardQuery,
useUpdateDashboardMutation,
} from '../../../graphql/dashboard.generated';
import { Dashboard, EntityType, OwnershipType, PlatformType, SearchResult } from '../../../types.generated';
import { Dashboard, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/SidebarOwnerSection';
Expand All @@ -17,7 +17,6 @@ import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
import { GenericEntityProperties } from '../shared/types';
import { DashboardPreview } from './preview/DashboardPreview';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { capitalizeFirstLetter } from '../../shared/textUtil';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';

Expand Down Expand Up @@ -118,31 +117,19 @@ export class DashboardEntity implements Entity<Dashboard> {

getOverridePropertiesFromEntity = (dashboard?: Dashboard | null): GenericEntityProperties => {
// TODO: Get rid of this once we have correctly formed platform coming back.
const tool = dashboard?.tool || '';
const name = dashboard?.properties?.name;
const externalUrl = dashboard?.properties?.externalUrl;
return {
name,
externalUrl,
platform: {
urn: `urn:li:dataPlatform:(${tool})`,
type: EntityType.DataPlatform,
name: tool,
properties: {
logoUrl: dashboard?.platform?.properties?.logoUrl || '',
displayName: capitalizeFirstLetter(tool),
type: PlatformType.Others,
datasetNameDelimiter: '.',
},
},
};
};

renderPreview = (_: PreviewType, data: Dashboard) => {
return (
<DashboardPreview
urn={data.urn}
platform={data.tool}
platform={data.platform.properties?.displayName || data.platform.name}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
access={data.properties?.access}
Expand All @@ -161,7 +148,7 @@ export class DashboardEntity implements Entity<Dashboard> {
return (
<DashboardPreview
urn={data.urn}
platform={data.tool}
platform={data.platform.properties?.displayName || data.platform.name}
name={data.properties?.name}
platformInstanceId={data.dataPlatformInstance?.instanceId}
description={data.editableProperties?.description || data.properties?.description}
Expand All @@ -184,7 +171,7 @@ export class DashboardEntity implements Entity<Dashboard> {
name: entity.properties?.name || '',
type: EntityType.Dashboard,
icon: entity?.platform?.properties?.logoUrl || '',
platform: entity.tool,
platform: entity?.platform.properties?.displayName || entity?.platform.name,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';

export const DashboardPreview = ({
urn,
Expand Down Expand Up @@ -54,6 +55,7 @@ export const DashboardPreview = ({
name={name || ''}
description={description || ''}
type="Dashboard"
typeIcon={entityRegistry.getIcon(EntityType.Dashboard, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platformInstanceId={platformInstanceId}
platform={capitalizedPlatform}
Expand Down
21 changes: 3 additions & 18 deletions datahub-web-react/src/app/entity/dataFlow/DataFlowEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { ShareAltOutlined } from '@ant-design/icons';
import { DataFlow, EntityType, OwnershipType, PlatformType, SearchResult } from '../../../types.generated';
import { DataFlow, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
Expand All @@ -13,7 +13,6 @@ import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Owners
import { GenericEntityProperties } from '../shared/types';
import { DataFlowJobsTab } from '../shared/tabs/Entity/DataFlowJobsTab';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { capitalizeFirstLetter } from '../../shared/textUtil';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';

Expand Down Expand Up @@ -104,34 +103,21 @@ export class DataFlowEntity implements Entity<DataFlow> {

getOverridePropertiesFromEntity = (dataFlow?: DataFlow | null): GenericEntityProperties => {
// TODO: Get rid of this once we have correctly formed platform coming back.
const tool = dataFlow?.orchestrator || '';
const name = dataFlow?.properties?.name;
const externalUrl = dataFlow?.properties?.externalUrl;
return {
name,
externalUrl,
platform: {
urn: `urn:li:dataPlatform:(${tool})`,
type: EntityType.DataPlatform,
name: tool,
properties: {
logoUrl: dataFlow?.platform?.properties?.logoUrl || '',
displayName: capitalizeFirstLetter(tool),
type: PlatformType.Others,
datasetNameDelimiter: '.',
},
},
};
};

renderPreview = (_: PreviewType, data: DataFlow) => {
const platformName = data.orchestrator.charAt(0).toUpperCase() + data.orchestrator.slice(1);
return (
<Preview
urn={data.urn}
name={data.properties?.name || ''}
description={data.editableProperties?.description || data.properties?.description}
platformName={platformName}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data?.platform?.properties?.logoUrl || ''}
owners={data.ownership?.owners}
globalTags={data.globalTags}
Expand All @@ -142,14 +128,13 @@ export class DataFlowEntity implements Entity<DataFlow> {

renderSearch = (result: SearchResult) => {
const data = result.entity as DataFlow;
const platformName = data.orchestrator.charAt(0).toUpperCase() + data.orchestrator.slice(1);
return (
<Preview
urn={data.urn}
name={data.properties?.name || ''}
platformInstanceId={data.dataPlatformInstance?.instanceId}
description={data.editableProperties?.description || data.properties?.description || ''}
platformName={platformName}
platformName={data.platform.properties?.displayName || data.platform.name}
platformLogo={data?.platform?.properties?.logoUrl || ''}
owners={data.ownership?.owners}
globalTags={data.globalTags}
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/dataFlow/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Domain, EntityType, GlobalTags, Owner, SearchInsight } from '../../../.
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';

export const Preview = ({
urn,
Expand Down Expand Up @@ -38,6 +39,7 @@ export const Preview = ({
description={description || ''}
platformInstanceId={platformInstanceId}
type="Data Pipeline"
typeIcon={entityRegistry.getIcon(EntityType.DataFlow, 14, IconStyleType.ACCENT)}
platform={capitalizedPlatform}
logoUrl={platformLogo || ''}
owners={owners}
Expand Down
32 changes: 9 additions & 23 deletions datahub-web-react/src/app/entity/dataJob/DataJobEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { ConsoleSqlOutlined } from '@ant-design/icons';
import { DataJob, EntityType, OwnershipType, PlatformType, SearchResult } from '../../../types.generated';
import { DataJob, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
Expand All @@ -14,11 +14,14 @@ import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Owners
import { GenericEntityProperties } from '../shared/types';
import { DataJobFlowTab } from '../shared/tabs/Entity/DataJobFlowTab';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { capitalizeFirstLetter } from '../../shared/textUtil';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { RunsTab } from './tabs/RunsTab';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';

const getDataJobPlatformName = (data: DataJob): string => {
return data.dataFlow?.platform.properties?.displayName || data.dataFlow?.platform.name || '';
};

/**
* Definition of the DataHub DataJob entity.
*/
Expand Down Expand Up @@ -124,36 +127,22 @@ export class DataJobEntity implements Entity<DataJob> {

getOverridePropertiesFromEntity = (dataJob?: DataJob | null): GenericEntityProperties => {
// TODO: Get rid of this once we have correctly formed platform coming back.
const tool = dataJob?.dataFlow?.orchestrator || '';
const name = dataJob?.properties?.name;
const externalUrl = dataJob?.properties?.externalUrl;
return {
name,
externalUrl,
platform: {
urn: `urn:li:dataPlatform:(${tool})`,
type: EntityType.DataPlatform,
name: tool,
properties: {
logoUrl: dataJob?.dataFlow?.platform?.properties?.logoUrl || '',
displayName: capitalizeFirstLetter(tool),
type: PlatformType.Others,
datasetNameDelimiter: '.',
},
},
platform: dataJob?.dataFlow?.platform,
};
};

renderPreview = (_: PreviewType, data: DataJob) => {
const platformName = data.dataFlow
? data.dataFlow?.orchestrator.charAt(0).toUpperCase() + data.dataFlow?.orchestrator.slice(1)
: '';
return (
<Preview
urn={data.urn}
name={data.properties?.name || ''}
description={data.editableProperties?.description || data.properties?.description}
platformName={platformName}
platformName={getDataJobPlatformName(data)}
platformLogo={data?.dataFlow?.platform?.properties?.logoUrl || ''}
owners={data.ownership?.owners}
globalTags={data.globalTags || null}
Expand All @@ -164,15 +153,12 @@ export class DataJobEntity implements Entity<DataJob> {

renderSearch = (result: SearchResult) => {
const data = result.entity as DataJob;
const platformName = data.dataFlow
? data.dataFlow?.orchestrator.charAt(0).toUpperCase() + data.dataFlow?.orchestrator.slice(1)
: '';
return (
<Preview
urn={data.urn}
name={data.properties?.name || ''}
description={data.editableProperties?.description || data.properties?.description}
platformName={platformName}
platformName={getDataJobPlatformName(data)}
platformLogo={data?.dataFlow?.platform?.properties?.logoUrl || ''}
platformInstanceId={data.dataPlatformInstance?.instanceId}
owners={data.ownership?.owners}
Expand All @@ -189,7 +175,7 @@ export class DataJobEntity implements Entity<DataJob> {
name: entity?.properties?.name || '',
type: EntityType.DataJob,
icon: entity?.dataFlow?.platform?.properties?.logoUrl || '',
platform: entity?.dataFlow?.orchestrator || '',
platform: getDataJobPlatformName(entity),
};
};

Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/dataJob/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Domain, EntityType, GlobalTags, Owner, SearchInsight } from '../../../.
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';

export const Preview = ({
urn,
Expand Down Expand Up @@ -37,6 +38,7 @@ export const Preview = ({
name={name}
description={description || ''}
type="Data Task"
typeIcon={entityRegistry.getIcon(EntityType.DataJob, 14, IconStyleType.ACCENT)}
platform={capitalizedPlatform}
logoUrl={platformLogo || ''}
platformInstanceId={platformInstanceId}
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class DatasetEntity implements Entity<Dataset> {
};

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

platformLogoUrl = (data: Dataset) => {
Expand Down
Loading

0 comments on commit c9be9e0

Please sign in to comment.