-
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(propagation): UI for rendering propagated column documentation #11047
Changes from 12 commits
55a94e7
fc325d2
53f462b
ca9b85a
08bcea4
2cc7081
15c2580
23eba77
907cba4
486f7bb
2773e04
3b3ef05
0598921
1c86fdd
c1da3d7
215a31a
bf3b739
d1487bc
54bdf6b
e32eef2
86db1bc
298e9e4
c4a313b
edbc0db
b0c61a1
5945235
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,75 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Popover } from 'antd'; | ||
import { StringMapEntry } from '../../../../types.generated'; | ||
import PropagationEntityLink from './PropagationEntityLink'; | ||
import { usePropagationDetails } from './utils'; | ||
import { ANTD_GRAY } from '../constants'; | ||
import { PropagateThunderbolt, PropagateThunderboltFilled } from './PropagationIcon'; | ||
|
||
const PopoverWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
const PopoverTitle = styled.div` | ||
font-weight: bold; | ||
font-size: 14px; | ||
padding: 6px 0px; | ||
`; | ||
|
||
const PopoverDescription = styled.div` | ||
max-width: 340px; | ||
font-size: 14px; | ||
color: ${ANTD_GRAY[7]}; | ||
display: inline; | ||
padding: 0px 0px 4px 0px; | ||
`; | ||
|
||
interface Props { | ||
sourceDetail?: StringMapEntry[] | null; | ||
} | ||
|
||
export default function PropagationDetails({ sourceDetail }: Props) { | ||
const { | ||
isPropagated, | ||
origin: { entity: originEntity }, | ||
via: { entity: viaEntity }, | ||
} = usePropagationDetails(sourceDetail); | ||
|
||
if (!sourceDetail || !isPropagated) return null; | ||
|
||
const popoverContent = | ||
originEntity || viaEntity ? ( | ||
<PopoverWrapper> | ||
<PopoverDescription> | ||
This description was automatically propagated{' '} | ||
{originEntity && originEntity.urn !== viaEntity?.urn && ( | ||
<> | ||
from <PropagationEntityLink entity={originEntity} /> | ||
</> | ||
)} | ||
{viaEntity && ( | ||
<> | ||
via <PropagationEntityLink entity={viaEntity} /> | ||
</> | ||
)} | ||
</PopoverDescription> | ||
</PopoverWrapper> | ||
) : undefined; | ||
|
||
return ( | ||
<Popover | ||
showArrow={false} | ||
title={ | ||
<PopoverTitle> | ||
<PropagateThunderboltFilled /> | ||
Propagated Description | ||
</PopoverTitle> | ||
} | ||
content={popoverContent} | ||
> | ||
<PropagateThunderbolt data-testid="docPropagationIndicator" /> | ||
</Popover> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Link } from 'react-router-dom'; | ||
import { useEntityRegistry } from '../../../useEntityRegistry'; | ||
import { Entity, EntityType, SchemaFieldEntity } from '../../../../types.generated'; | ||
import { GenericEntityProperties } from '../types'; | ||
|
||
const PreviewImage = styled.img<{ size: number }>` | ||
height: ${(props) => props.size}px; | ||
width: ${(props) => props.size}px; | ||
min-width: ${(props) => props.size}px; | ||
object-fit: contain; | ||
background-color: transparent; | ||
margin: 0 3px; | ||
`; | ||
|
||
const StyledLink = styled(Link)` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
interface Props { | ||
entity: Entity; | ||
} | ||
|
||
export default function PropagationEntityLink({ entity }: Props) { | ||
const entityRegistry = useEntityRegistry(); | ||
|
||
const isSchemaField = entity.type === EntityType.SchemaField; | ||
const baseEntity = isSchemaField ? (entity as SchemaFieldEntity).parent : entity; | ||
|
||
const logoUrl = (baseEntity as GenericEntityProperties)?.platform?.properties?.logoUrl || ''; | ||
let entityUrl = entityRegistry.getEntityUrl(baseEntity.type, baseEntity.urn); | ||
let entityDisplayName = entityRegistry.getDisplayName(baseEntity.type, baseEntity); | ||
|
||
if (isSchemaField) { | ||
entityUrl = `${entityUrl}/${encodeURIComponent('Columns')}?schemaFilter=${encodeURIComponent( | ||
(entity as SchemaFieldEntity).fieldPath, | ||
)}`; | ||
const schemaFieldName = entityRegistry.getDisplayName(entity.type, entity); | ||
entityDisplayName = `${entityDisplayName}.${schemaFieldName}`; | ||
} | ||
|
||
return ( | ||
<StyledLink to={entityUrl}> | ||
<PreviewImage src={logoUrl} alt="test" size={14} /> | ||
{entityDisplayName} | ||
</StyledLink> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import styled from 'styled-components'; | ||
import { ThunderboltFilled } from '@ant-design/icons'; | ||
import { REDESIGN_COLORS } from '../constants'; | ||
|
||
export const PropagateThunderbolt = styled(ThunderboltFilled)` | ||
&& { | ||
color: #a7c7fa; | ||
} | ||
font-size: 16px; | ||
&:hover { | ||
color: ${REDESIGN_COLORS.BLUE}; | ||
} | ||
margin-right: 4px; | ||
`; | ||
|
||
export const PropagateThunderboltFilled = styled(ThunderboltFilled)` | ||
&& { | ||
color: ${REDESIGN_COLORS.BLUE}; | ||
} | ||
font-size: 16px; | ||
margin-right: 4px; | ||
`; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||||
import { StringMapEntry } from '../../../../types.generated'; | ||||||||||||||||||
import { useGetEntities } from '../useGetEntities'; | ||||||||||||||||||
|
||||||||||||||||||
export function usePropagationDetails(sourceDetail?: StringMapEntry[] | null) { | ||||||||||||||||||
const isPropagated = !!sourceDetail?.find((mapEntry) => mapEntry.key === 'propagated' && mapEntry.value === 'true'); | ||||||||||||||||||
const originEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'origin')?.value || ''; | ||||||||||||||||||
const viaEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'via')?.value || ''; | ||||||||||||||||||
Comment on lines
+4
to
+7
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. Consider handling edge cases for Ensure that - const isPropagated = !!sourceDetail?.find((mapEntry) => mapEntry.key === 'propagated' && mapEntry.value === 'true');
- const originEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'origin')?.value || '';
- const viaEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'via')?.value || '';
+ const isPropagated = sourceDetail?.some((mapEntry) => mapEntry.key === 'propagated' && mapEntry.value === 'true') ?? false;
+ const originEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'origin')?.value ?? '';
+ const viaEntityUrn = sourceDetail?.find((mapEntry) => mapEntry.key === 'via')?.value ?? ''; Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
const entities = useGetEntities([originEntityUrn, viaEntityUrn]); | ||||||||||||||||||
const originEntity = entities.find((e) => e.urn === originEntityUrn); | ||||||||||||||||||
const viaEntity = entities.find((e) => e.urn === viaEntityUrn); | ||||||||||||||||||
|
||||||||||||||||||
return { | ||||||||||||||||||
isPropagated, | ||||||||||||||||||
origin: { | ||||||||||||||||||
urn: originEntityUrn, | ||||||||||||||||||
entity: originEntity, | ||||||||||||||||||
}, | ||||||||||||||||||
via: { | ||||||||||||||||||
urn: viaEntityUrn, | ||||||||||||||||||
entity: viaEntity, | ||||||||||||||||||
}, | ||||||||||||||||||
}; | ||||||||||||||||||
} |
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.
Optimize the entity type check and assignment.
The entity type check and assignment can be optimized for better readability and performance.
Committable suggestion