-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(React): deprecation status in header
- Loading branch information
1 parent
c2698b9
commit 96a8f23
Showing
8 changed files
with
180 additions
and
42 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.graphql |
65 changes: 65 additions & 0 deletions
65
datahub-web-react/src/components/entity/dataset/profile/DatasetHeader.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,65 @@ | ||
import { Avatar, Badge, Popover, Space, Tooltip, Typography } from 'antd'; | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { Dataset, EntityType } from '../../../../types.generated'; | ||
import { useEntityRegistry } from '../../../useEntityRegistry'; | ||
import defaultAvatar from '../../../../images/default_avatar.png'; | ||
|
||
export type Props = { | ||
dataset: Dataset; | ||
}; | ||
|
||
export default function DatasetHeader({ dataset: { description, ownership, deprecation } }: Props) { | ||
const entityRegistry = useEntityRegistry(); | ||
|
||
return ( | ||
<> | ||
<Typography.Paragraph>{description}</Typography.Paragraph> | ||
<Space direction="vertical"> | ||
<Avatar.Group maxCount={6} size="large"> | ||
{ownership && | ||
ownership.owners && | ||
ownership.owners.map((owner: any) => ( | ||
<Tooltip title={owner.owner.info?.fullName}> | ||
<Link to={`/${entityRegistry.getPathName(EntityType.CorpUser)}/${owner.owner.urn}`}> | ||
<Avatar | ||
style={{ | ||
color: '#f56a00', | ||
backgroundColor: '#fde3cf', | ||
}} | ||
src={ | ||
(owner.owner.editableInfo && owner.owner.editableInfo.pictureLink) || | ||
defaultAvatar | ||
} | ||
/> | ||
</Link> | ||
</Tooltip> | ||
))} | ||
</Avatar.Group> | ||
<div> | ||
{deprecation?.deprecated && ( | ||
<Popover | ||
placement="bottomLeft" | ||
content={ | ||
<> | ||
<Typography.Paragraph>By: {deprecation?.actor}</Typography.Paragraph> | ||
{deprecation.decommissionTime && ( | ||
<Typography.Paragraph> | ||
On: {new Date(deprecation?.decommissionTime).toUTCString()} | ||
</Typography.Paragraph> | ||
)} | ||
{deprecation?.note && ( | ||
<Typography.Paragraph>{deprecation.note}</Typography.Paragraph> | ||
)} | ||
</> | ||
} | ||
title="Deprecated" | ||
> | ||
<Badge count="Deprecated" /> | ||
</Popover> | ||
)} | ||
</div> | ||
</Space> | ||
</> | ||
); | ||
} |
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
37 changes: 37 additions & 0 deletions
37
datahub-web-react/src/components/entity/dataset/profile/stories/DatasetHeader.stories.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,37 @@ | ||
import React from 'react'; | ||
import { Story, Meta } from '@storybook/react'; | ||
|
||
import TestPageContainer from '../../../../../utils/test-utils/TestPageContainer'; | ||
import DatasetHeader, { Props } from '../DatasetHeader'; | ||
import { sampleDataset, sampleDeprecatedDataset } from './sampleDataset'; | ||
|
||
export default { | ||
title: 'Dataset Profile / DatasetHeader', | ||
component: DatasetHeader, | ||
} as Meta; | ||
|
||
const Template: Story<Props> = (args) => <DatasetHeader {...args} />; | ||
|
||
export const DescriptionAndOwner = Template.bind({}); | ||
DescriptionAndOwner.args = { dataset: sampleDataset }; | ||
DescriptionAndOwner.decorators = [ | ||
(InnerStory) => ( | ||
<> | ||
<TestPageContainer> | ||
<InnerStory /> | ||
</TestPageContainer> | ||
</> | ||
), | ||
]; | ||
|
||
export const Deprecated = Template.bind({}); | ||
Deprecated.args = { dataset: sampleDeprecatedDataset }; | ||
Deprecated.decorators = [ | ||
(InnerStory) => ( | ||
<> | ||
<TestPageContainer> | ||
<InnerStory /> | ||
</TestPageContainer> | ||
</> | ||
), | ||
]; |
53 changes: 53 additions & 0 deletions
53
datahub-web-react/src/components/entity/dataset/profile/stories/sampleDataset.ts
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 { Dataset, EntityType, FabricType, OwnershipType } from '../../../../../types.generated'; | ||
|
||
export const sampleDataset: Dataset = { | ||
__typename: 'Dataset', | ||
urn: 'test:urn', | ||
platform: { | ||
type: EntityType.DataPlatform, | ||
urn: 'test:hive:urn', | ||
name: 'hive', | ||
}, | ||
name: 'hive dataset', | ||
origin: FabricType.Prod, | ||
description: 'Some description', | ||
type: EntityType.Dataset, | ||
created: { time: 1 }, | ||
lastModified: { time: 1 }, | ||
tags: [], | ||
ownership: { | ||
owners: [ | ||
{ owner: { urn: 'user:urn', type: EntityType.CorpUser, username: 'UserA' }, type: OwnershipType.Dataowner }, | ||
], | ||
lastModified: { time: 1 }, | ||
}, | ||
}; | ||
|
||
export const sampleDeprecatedDataset: Dataset = { | ||
__typename: 'Dataset', | ||
urn: 'test:urn', | ||
platform: { | ||
type: EntityType.DataPlatform, | ||
urn: 'test:hive:urn', | ||
name: 'hive', | ||
}, | ||
name: 'hive dataset', | ||
origin: FabricType.Prod, | ||
description: 'Some deprecated description', | ||
type: EntityType.Dataset, | ||
created: { time: 1 }, | ||
lastModified: { time: 1 }, | ||
tags: [], | ||
ownership: { | ||
owners: [ | ||
{ owner: { urn: 'user:urn', type: EntityType.CorpUser, username: 'UserA' }, type: OwnershipType.Dataowner }, | ||
], | ||
lastModified: { time: 1 }, | ||
}, | ||
deprecation: { | ||
actor: 'UserB', | ||
deprecated: true, | ||
note: "Don't touch this dataset with a 10 foot pole", | ||
decommissionTime: 1612565520292, | ||
}, | ||
}; |
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
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