forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(propagation): Add Documentation Propagation Settings (datahub-pr…
- Loading branch information
Showing
5 changed files
with
377 additions
and
0 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
179 changes: 179 additions & 0 deletions
179
datahub-web-react/src/app/settings/features/Feature.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,179 @@ | ||
import React from 'react'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { Divider, Typography, Switch, Card, Button, Tooltip } from 'antd'; | ||
import { ArrowRightOutlined } from '@ant-design/icons'; | ||
import { ANTD_GRAY } from '../../entity/shared/constants'; | ||
|
||
const Title = styled(Typography.Title)` | ||
&& { | ||
margin-bottom: 8px; | ||
} | ||
`; | ||
|
||
const FeatureRow = styled.div` | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: space-between; | ||
`; | ||
|
||
const FeatureOptionRow = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
&:not(:last-child) { | ||
margin-bottom: 8px; | ||
} | ||
`; | ||
|
||
const SettingsOptionRow = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 0 16px; | ||
&:not(:last-child) { | ||
margin-bottom: 8px; | ||
} | ||
`; | ||
|
||
const DescriptionText = styled(Typography.Text)` | ||
color: ${ANTD_GRAY[7]}; | ||
font-size: 11px; | ||
`; | ||
|
||
const SettingTitle = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
font-size: 14px; | ||
margin-bottom: 4px; | ||
`; | ||
|
||
const OptionTitle = styled(Typography.Text)` | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
font-size: 12px; | ||
`; | ||
|
||
const learnMoreLinkStyle = { | ||
flex: 1, | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '8px', | ||
color: '#1890FF', | ||
fontSize: '12px', | ||
cursor: 'pointer', | ||
}; | ||
|
||
const NewTag = styled.div` | ||
padding: 4px 8px; | ||
border-radius: 24px; | ||
background: #f1fbfe; | ||
color: #09739a; | ||
font-size: 12px; | ||
`; | ||
|
||
const DataHubOnlyTag = styled.div` | ||
padding: 2px 8px; | ||
border-radius: 24px; | ||
background: #c9fff2; | ||
color: #50a494; | ||
font-size: 12px; | ||
`; | ||
|
||
export interface FeatureType { | ||
key: string; | ||
title: string; | ||
description: string; | ||
settings: Array<{ | ||
key: string; | ||
title: string; | ||
isAvailable: boolean; | ||
buttonText: string; | ||
onClick?: () => void; | ||
}>; | ||
options: Array<{ | ||
key: string; | ||
title: string; | ||
description: string; | ||
isAvailable: boolean; | ||
checked: boolean; | ||
onChange?: (checked: boolean) => void; | ||
}>; | ||
isNew: boolean; | ||
learnMoreLink?: string; | ||
} | ||
|
||
export const Feature = ({ key, title, description, settings, options, isNew, learnMoreLink }: FeatureType) => ( | ||
<Card style={{ marginBottom: '1rem' }} key={key}> | ||
<FeatureRow> | ||
<div style={{ flex: 1 }}> | ||
<SettingTitle> | ||
<Title level={5} style={{ marginBottom: 0 }}> | ||
{title} | ||
</Title> | ||
{isNew && <NewTag>New!</NewTag>} | ||
</SettingTitle> | ||
<div> | ||
<Typography.Paragraph type="secondary">{description}</Typography.Paragraph> | ||
</div> | ||
</div> | ||
<div> | ||
{learnMoreLink && ( | ||
<a href={learnMoreLink} target="_blank" style={learnMoreLinkStyle} rel="noreferrer"> | ||
Learn more <ArrowRightOutlined /> | ||
</a> | ||
)} | ||
</div> | ||
</FeatureRow> | ||
<Divider style={{ margin: `8px 0 24px 0` }} /> | ||
{settings.map((option) => ( | ||
<> | ||
<SettingsOptionRow key={option.key}> | ||
<span> | ||
<OptionTitle> | ||
<span>{option.title}</span> | ||
</OptionTitle> | ||
</span> | ||
<Tooltip title={option.isAvailable ? '' : 'Only available on DataHub Cloud'}> | ||
<Button onClick={option.onClick} disabled={!option.isAvailable}> | ||
{option.buttonText} | ||
</Button> | ||
</Tooltip> | ||
</SettingsOptionRow> | ||
</> | ||
))} | ||
<Card style={{ margin: `16px auto` }}> | ||
{options.map((option, index) => ( | ||
<> | ||
<FeatureOptionRow key={option.key}> | ||
<span> | ||
<OptionTitle> | ||
<span>{option.title}</span> | ||
{!option.isAvailable && ( | ||
<DataHubOnlyTag>Only available on DataHub Cloud</DataHubOnlyTag> | ||
)} | ||
</OptionTitle> | ||
<div> | ||
<DescriptionText>{option.description}</DescriptionText> | ||
</div> | ||
</span> | ||
<Switch | ||
checked={option.checked} | ||
onChange={(checked) => (option.onChange ? option.onChange(checked) : null)} | ||
disabled={!option.isAvailable} | ||
/> | ||
</FeatureOptionRow> | ||
{index !== options.length - 1 && <Divider />} | ||
</> | ||
))} | ||
</Card> | ||
</Card> | ||
); |
110 changes: 110 additions & 0 deletions
110
datahub-web-react/src/app/settings/features/Features.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,110 @@ | ||
import React from 'react'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { Divider, Typography } from 'antd'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
import { Feature, FeatureType } from './Feature'; | ||
|
||
import { useGetDocPropagationSettings, useUpdateDocPropagationSettings } from './useDocPropagationSettings'; | ||
|
||
const Page = styled.div` | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
`; | ||
|
||
const SourceContainer = styled.div` | ||
width: 80%; | ||
padding-top: 20px; | ||
padding-right: 40px; | ||
padding-left: 40px; | ||
`; | ||
const Container = styled.div` | ||
padding-top: 0px; | ||
`; | ||
|
||
const Title = styled(Typography.Title)` | ||
&& { | ||
margin-bottom: 8px; | ||
} | ||
`; | ||
|
||
export const Features = () => { | ||
/* | ||
* Note: When adding new features, make sure to update the features array below | ||
* and create a hook file for the new feature in the same directory | ||
*/ | ||
|
||
// Hooks to get and update the document propagation settings | ||
const { isColPropagateChecked, setIsColPropagateChecked } = useGetDocPropagationSettings(); | ||
const { updateDocPropagation } = useUpdateDocPropagationSettings(); | ||
|
||
// Features to display | ||
const features: FeatureType[] = [ | ||
{ | ||
key: uuidv4(), | ||
title: 'Documentation Propagation', | ||
description: 'Automatically propagate documentation from upstream to downstream columns and assets.', | ||
settings: [ | ||
{ | ||
key: uuidv4(), | ||
title: 'Rollback Propagation Changes', | ||
isAvailable: false, | ||
buttonText: 'Rollback', | ||
}, | ||
{ | ||
key: uuidv4(), | ||
title: 'Backfill existing documentation from upstream to downstream columns/assets', | ||
isAvailable: false, | ||
buttonText: 'Initialize', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
key: uuidv4(), | ||
title: 'Column Level Propagation', | ||
description: | ||
'Propagate new documentation from upstream to downstream columns based on column-level lineage relationships.', | ||
isAvailable: true, | ||
checked: isColPropagateChecked, | ||
onChange: (checked: boolean) => { | ||
setIsColPropagateChecked(checked); | ||
updateDocPropagation(checked); | ||
}, | ||
}, | ||
{ | ||
key: uuidv4(), | ||
title: 'Asset Level Propagation', | ||
description: | ||
'Propagate new documentation from upstream to downstream assets based on data lineage relationships.', | ||
isAvailable: false, | ||
checked: false, | ||
}, | ||
], | ||
isNew: true, | ||
learnMoreLink: 'https://datahubproject.io/docs/automations/doc-propagation', | ||
}, | ||
]; | ||
|
||
// Render | ||
return ( | ||
<Page> | ||
<SourceContainer> | ||
<Container> | ||
<div> | ||
<Title level={2}>Features</Title> | ||
<Typography.Paragraph type="secondary"> | ||
Explore and configure specific features | ||
</Typography.Paragraph> | ||
</div> | ||
</Container> | ||
<Divider /> | ||
{features.map((feature) => ( | ||
<Feature {...feature} /> | ||
))} | ||
</SourceContainer> | ||
</Page> | ||
); | ||
}; |
Oops, something went wrong.