Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ui): refactor capitalization of platform name and sub types #7099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed datahub-web-react/public/meta-favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/domain/DomainsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const DomainsList = () => {

const handleDelete = (urn: string) => {
removeFromListDomainsCache(client, urn, page, pageSize);
setTimeout(function () {
setTimeout(() => {
refetch?.();
}, 2000);
};
Expand Down
9 changes: 5 additions & 4 deletions datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ChartStatsSummarySubHeader } from './profile/stats/ChartStatsSummarySub
import { InputFieldsTab } from '../shared/tabs/Entity/InputFieldsTab';
import { ChartSnippet } from './ChartSnippet';
import { EmbedTab } from '../shared/tabs/Embed/EmbedTab';
import { capitalizeFirstLetterOnly } from '../../shared/textUtil';

/**
* Definition of the DataHub Chart entity.
Expand Down Expand Up @@ -154,7 +155,7 @@ export class ChartEntity implements Entity<Chart> {
return (
<ChartPreview
urn={data.urn}
platform={data.platform.properties?.displayName || data.platform.name}
platform={data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
access={data.properties?.access}
Expand All @@ -173,7 +174,7 @@ export class ChartEntity implements Entity<Chart> {
return (
<ChartPreview
urn={data.urn}
platform={data.platform.properties?.displayName || data.platform.name}
platform={data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)}
platformInstanceId={data.dataPlatformInstance?.instanceId}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
Expand All @@ -197,9 +198,9 @@ export class ChartEntity implements Entity<Chart> {
getLineageVizConfig = (entity: Chart) => {
return {
urn: entity.urn,
name: entity.properties?.name || '',
name: entity.properties?.name || entity.urn,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

type: EntityType.Chart,
icon: entity?.platform?.properties?.logoUrl || '',
icon: entity?.platform?.properties?.logoUrl || undefined,
platform: entity?.platform,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';
import { ChartStatsSummary as ChartStatsSummaryView } from '../shared/ChartStatsSummary';

Expand All @@ -41,7 +40,7 @@ export const ChartPreview = ({
snippet,
}: {
urn: string;
platform: string;
platform?: string;
platformInstanceId?: string;
name?: string;
description?: string | null;
Expand All @@ -62,7 +61,6 @@ export const ChartPreview = ({
snippet?: React.ReactNode | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const capitalizedPlatform = capitalizeFirstLetter(platform);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you


return (
<DefaultPreviewCard
Expand All @@ -73,7 +71,7 @@ export const ChartPreview = ({
type="Chart"
typeIcon={entityRegistry.getIcon(EntityType.Chart, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platform={capitalizedPlatform}
platform={platform}
platformInstanceId={platformInstanceId}
qualifier={access}
tags={tags}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SidebarRecommendationsSection } from '../shared/containers/profile/side
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { capitalizeFirstLetterOnly } from '../../shared/textUtil';

/**
* Definition of the DataHub Container entity.
Expand Down Expand Up @@ -110,7 +111,7 @@ export class ContainerEntity implements Entity<Container> {
<Preview
urn={data.urn}
name={this.displayName(data)}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={data.platform.properties?.displayName || capitalizeFirstLetterOnly(data.platform.name)}
platformLogo={data.platform.properties?.logoUrl}
description={data.properties?.description}
owners={data.ownership?.owners}
Expand All @@ -130,7 +131,7 @@ export class ContainerEntity implements Entity<Container> {
<Preview
urn={data.urn}
name={this.displayName(data)}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={data.platform.properties?.displayName || capitalizeFirstLetterOnly(data.platform.name)}
platformLogo={data.platform.properties?.logoUrl}
platformInstanceId={data.dataPlatformInstance?.instanceId}
description={data.editableProperties?.description || data.properties?.description}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
GlossaryTerms,
} from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { capitalizeFirstLetterOnly } from '../../../shared/textUtil';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType } from '../../Entity';
import { ANTD_GRAY } from '../../shared/constants';
Expand Down Expand Up @@ -44,7 +45,7 @@ export const Preview = ({
}: {
urn: string;
name: string;
platformName: string;
platformName?: string;
platformLogo?: string | null;
platformInstanceId?: string;
description?: string | null;
Expand All @@ -62,7 +63,7 @@ export const Preview = ({
externalUrl?: string | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const typeName = (subTypes?.typeNames?.length && subTypes?.typeNames[0]) || 'Container';
const typeName = capitalizeFirstLetterOnly(subTypes?.typeNames?.[0]) || 'Container';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Will this work when

subTypes?.typeNames is an empty array?. If not, seems a bit worrisome to remove the first check.

return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.Container, urn)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class DashboardEntity implements Entity<Dashboard> {
return (
<DashboardPreview
urn={data.urn}
platform={data.platform.properties?.displayName || data.platform.name}
platform={data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)}
name={data.properties?.name}
description={data.editableProperties?.description || data.properties?.description}
access={data.properties?.access}
Expand All @@ -193,7 +193,7 @@ export class DashboardEntity implements Entity<Dashboard> {
return (
<DashboardPreview
urn={data.urn}
platform={data.platform.properties?.displayName || data.platform.name}
platform={data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)}
name={data.properties?.name}
platformInstanceId={data.dataPlatformInstance?.instanceId}
description={data.editableProperties?.description || data.properties?.description}
Expand Down Expand Up @@ -226,10 +226,10 @@ export class DashboardEntity implements Entity<Dashboard> {
getLineageVizConfig = (entity: Dashboard) => {
return {
urn: entity.urn,
name: entity.properties?.name || '',
name: entity.properties?.name || entity.urn,
type: EntityType.Dashboard,
subtype: entity?.subTypes?.typeNames?.[0] || undefined,
icon: entity?.platform?.properties?.logoUrl || '',
icon: entity?.platform?.properties?.logoUrl || undefined,
platform: entity?.platform,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter, capitalizeFirstLetterOnly } from '../../../shared/textUtil';
import { capitalizeFirstLetterOnly } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';
import { DashboardStatsSummary as DashboardStatsSummaryView } from '../shared/DashboardStatsSummary';

Expand Down Expand Up @@ -43,7 +43,7 @@ export const DashboardPreview = ({
snippet,
}: {
urn: string;
platform: string;
platform?: string;
platformInstanceId?: string;
name?: string;
subtype?: string | null;
Expand All @@ -66,7 +66,6 @@ export const DashboardPreview = ({
snippet?: React.ReactNode | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const capitalizedPlatform = capitalizeFirstLetter(platform);

return (
<DefaultPreviewCard
Expand All @@ -78,7 +77,7 @@ export const DashboardPreview = ({
typeIcon={entityRegistry.getIcon(EntityType.Dashboard, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platformInstanceId={platformInstanceId}
platform={capitalizedPlatform}
platform={platform}
qualifier={access}
owners={owners}
tags={tags}
Expand Down
9 changes: 7 additions & 2 deletions datahub-web-react/src/app/entity/dataFlow/DataFlowEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { DataFlowJobsTab } from '../shared/tabs/Entity/DataFlowJobsTab';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { capitalizeFirstLetterOnly } from '../../shared/textUtil';

/**
* Definition of the DataHub DataFlow entity.
Expand Down Expand Up @@ -117,7 +118,9 @@ export class DataFlowEntity implements Entity<DataFlow> {
urn={data.urn}
name={data.properties?.name || ''}
description={data.editableProperties?.description || data.properties?.description}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={
data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)
}
platformLogo={data?.platform?.properties?.logoUrl || ''}
owners={data.ownership?.owners}
globalTags={data.globalTags}
Expand All @@ -135,7 +138,9 @@ export class DataFlowEntity implements Entity<DataFlow> {
name={data.properties?.name || ''}
platformInstanceId={data.dataPlatformInstance?.instanceId}
description={data.editableProperties?.description || data.properties?.description || ''}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={
data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)
}
platformLogo={data?.platform?.properties?.logoUrl || ''}
owners={data.ownership?.owners}
globalTags={data.globalTags}
Expand Down
6 changes: 2 additions & 4 deletions datahub-web-react/src/app/entity/dataFlow/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import styled from 'styled-components';
import { Deprecation, Domain, EntityType, GlobalTags, Owner, SearchInsight } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';
import { ANTD_GRAY } from '../../shared/constants';

Expand Down Expand Up @@ -32,7 +31,7 @@ export const Preview = ({
name: string;
platformInstanceId?: string;
description?: string | null;
platformName: string;
platformName?: string;
platformLogo?: string | null;
owners?: Array<Owner> | null;
domain?: Domain | null;
Expand All @@ -44,7 +43,6 @@ export const Preview = ({
jobCount?: number | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const capitalizedPlatform = capitalizeFirstLetter(platformName);
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.DataFlow, urn)}
Expand All @@ -54,7 +52,7 @@ export const Preview = ({
platformInstanceId={platformInstanceId}
type="Data Pipeline"
typeIcon={entityRegistry.getIcon(EntityType.DataFlow, 14, IconStyleType.ACCENT)}
platform={capitalizedPlatform}
platform={platformName}
logoUrl={platformLogo || ''}
owners={owners}
tags={globalTags || undefined}
Expand Down
9 changes: 7 additions & 2 deletions datahub-web-react/src/app/entity/dataJob/DataJobEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domai
import { RunsTab } from './tabs/RunsTab';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { DataFlowEntity } from '../dataFlow/DataFlowEntity';
import { capitalizeFirstLetterOnly } from '../../shared/textUtil';

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

/**
Expand Down Expand Up @@ -194,7 +199,7 @@ export class DataJobEntity implements Entity<DataJob> {
name: this.displayName(entity),
expandedName: this.getExpandedNameForDataJob(entity),
type: EntityType.DataJob,
icon: entity?.dataFlow?.platform?.properties?.logoUrl || '',
icon: entity?.dataFlow?.platform?.properties?.logoUrl || undefined,
platform: entity?.dataFlow?.platform,
};
};
Expand Down
4 changes: 1 addition & 3 deletions datahub-web-react/src/app/entity/dataJob/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ClockCircleOutlined } from '@ant-design/icons';
import { Deprecation, Domain, EntityType, GlobalTags, Owner, SearchInsight } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';
import { ANTD_GRAY } from '../../shared/constants';
import { toRelativeTimeString } from '../../../shared/time/timeUtils';
Expand Down Expand Up @@ -47,7 +46,6 @@ export const Preview = ({
externalUrl?: string | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const capitalizedPlatform = capitalizeFirstLetter(platformName);
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.DataJob, urn)}
Expand All @@ -56,7 +54,7 @@ export const Preview = ({
description={description || ''}
type="Data Task"
typeIcon={entityRegistry.getIcon(EntityType.DataJob, 14, IconStyleType.ACCENT)}
platform={capitalizedPlatform}
platform={platformName}
logoUrl={platformLogo || ''}
platformInstanceId={platformInstanceId}
owners={owners}
Expand Down
14 changes: 9 additions & 5 deletions datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Owners
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
import StatsTab from '../shared/tabs/Dataset/Stats/StatsTab';
import { LineageTab } from '../shared/tabs/Lineage/LineageTab';
import { capitalizeFirstLetter } from '../../shared/textUtil';
import { capitalizeFirstLetterOnly } from '../../shared/textUtil';
import ViewDefinitionTab from '../shared/tabs/Dataset/View/ViewDefinitionTab';
import { SidebarViewDefinitionSection } from '../shared/containers/profile/sidebar/Dataset/View/SidebarViewDefinitionSection';
import { SidebarRecommendationsSection } from '../shared/containers/profile/sidebar/Recommendations/SidebarRecommendationsSection';
Expand Down Expand Up @@ -224,7 +224,7 @@ export class DatasetEntity implements Entity<Dataset> {
return {
name: dataset?.properties?.name || dataset?.name,
externalUrl: dataset?.properties?.externalUrl,
entityTypeOverride: subTypes ? capitalizeFirstLetter(subTypes.typeNames?.[0]) : '',
entityTypeOverride: subTypes ? capitalizeFirstLetterOnly(subTypes.typeNames?.[0]) : '',
properties: extendedProperties,
};
};
Expand All @@ -237,7 +237,9 @@ export class DatasetEntity implements Entity<Dataset> {
origin={data.origin}
subtype={data.subTypes?.typeNames?.[0]}
description={data.editableProperties?.description || data.properties?.description}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={
data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)
}
platformLogo={data.platform.properties?.logoUrl}
platformInstanceId={data.dataPlatformInstance?.instanceId}
owners={data.ownership?.owners}
Expand All @@ -260,11 +262,13 @@ export class DatasetEntity implements Entity<Dataset> {
name={data.properties?.name || data.name}
origin={data.origin}
description={data.editableProperties?.description || data.properties?.description}
platformName={data.platform.properties?.displayName || data.platform.name}
platformName={
data?.platform?.properties?.displayName || capitalizeFirstLetterOnly(data?.platform?.name)
}
platformLogo={data.platform.properties?.logoUrl}
platformInstanceId={data.dataPlatformInstance?.instanceId}
platformNames={genericProperties?.siblingPlatforms?.map(
(platform) => platform.properties?.displayName || platform.name,
(platform) => platform.properties?.displayName || capitalizeFirstLetterOnly(platform.name),
)}
platformLogos={genericProperties?.siblingPlatforms?.map((platform) => platform.properties?.logoUrl)}
owners={data.ownership?.owners}
Expand Down
5 changes: 2 additions & 3 deletions datahub-web-react/src/app/entity/dataset/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Preview = ({
name: string;
origin: FabricType;
description?: string | null;
platformName: string;
platformName?: string;
platformLogo?: string | null;
platformNames?: (Maybe<string> | undefined)[];
platformLogos?: (Maybe<string> | undefined)[];
Expand All @@ -69,7 +69,6 @@ export const Preview = ({
lastUpdatedMs?: number | null;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
const capitalPlatformName = capitalizeFirstLetterOnly(platformName);
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.Dataset, urn)}
Expand All @@ -79,7 +78,7 @@ export const Preview = ({
type={capitalizeFirstLetterOnly(subtype) || 'Dataset'}
logoUrl={platformLogo || ''}
typeIcon={entityRegistry.getIcon(EntityType.Dataset, 12, IconStyleType.ACCENT)}
platform={capitalPlatformName}
platform={platformName}
platforms={platformNames}
logoUrls={platformLogos}
platformInstanceId={platformInstanceId}
Expand Down
Loading