-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(React): Deprecation status in dataset header #2097
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.graphql |
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()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here with the ":" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great points- let's do those in followups. |
||
</Typography.Paragraph> | ||
)} | ||
{deprecation?.note && ( | ||
<Typography.Paragraph>{deprecation.note}</Typography.Paragraph> | ||
)} | ||
</> | ||
} | ||
title="Deprecated" | ||
> | ||
<Badge count="Deprecated" /> | ||
</Popover> | ||
)} | ||
</div> | ||
</Space> | ||
</> | ||
); | ||
} |
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> | ||
</> | ||
), | ||
]; |
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, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { RoutedTabs } from './RoutedTabs'; | |
export interface EntityProfileProps { | ||
title: string; | ||
tags?: Array<string>; | ||
body: React.ReactNode; | ||
header: React.ReactNode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this rename! |
||
tabs?: Array<{ | ||
name: string; | ||
path: string; | ||
|
@@ -21,27 +21,27 @@ const defaultProps = { | |
/** | ||
* A default container view for presenting Entity details. | ||
*/ | ||
export const EntityProfile = ({ title: _title, tags: _tags, body: _body, tabs: _tabs }: EntityProfileProps) => { | ||
const defaultTabPath = _tabs && _tabs?.length > 0 ? _tabs[0].path : ''; | ||
export const EntityProfile = ({ title, tags, header, tabs }: EntityProfileProps) => { | ||
const defaultTabPath = tabs && tabs?.length > 0 ? tabs[0].path : ''; | ||
|
||
/* eslint-disable spaced-comment */ | ||
return ( | ||
<Layout.Content style={{ backgroundColor: 'white', padding: '0px 100px' }}> | ||
<Row style={{ padding: '20px 0px 10px 0px' }}> | ||
<Col span={24}> | ||
<div> | ||
<h1 style={{ float: 'left' }}>{_title}</h1> | ||
<h1 style={{ float: 'left' }}>{title}</h1> | ||
<div style={{ float: 'left', margin: '5px 20px' }}> | ||
{_tags && _tags.map((t) => <Tag color="blue">{t}</Tag>)} | ||
{tags && tags.map((t) => <Tag color="blue">{t}</Tag>)} | ||
</div> | ||
</div> | ||
</Col> | ||
</Row> | ||
{_body} | ||
{header} | ||
<Divider style={{ marginBottom: '0px' }} /> | ||
<Row style={{ padding: '0px 0px 10px 0px' }}> | ||
<Col span={24}> | ||
<RoutedTabs defaultPath={defaultTabPath} tabs={_tabs || []} /> | ||
<RoutedTabs defaultPath={defaultTabPath} tabs={tabs || []} /> | ||
</Col> | ||
</Row> | ||
</Layout.Content> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe not need for the ":" here. It would also be useful to add a link