-
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(ui) Add full support for structured properties on assets (#12100)
- Loading branch information
1 parent
8b5fb71
commit dcc8ad9
Showing
49 changed files
with
1,290 additions
and
82 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
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
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
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
69 changes: 69 additions & 0 deletions
69
datahub-web-react/src/app/entity/dataset/profile/schema/components/StructuredPropValues.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,69 @@ | ||
import StructuredPropertyValue from '@src/app/entity/shared/tabs/Properties/StructuredPropertyValue'; | ||
import { mapStructuredPropertyToPropertyRow } from '@src/app/entity/shared/tabs/Properties/useStructuredProperties'; | ||
import { useEntityRegistry } from '@src/app/useEntityRegistry'; | ||
import { SchemaFieldEntity, SearchResult, StdDataType } from '@src/types.generated'; | ||
import { Tooltip } from 'antd'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const ValuesContainer = styled.span` | ||
max-width: 120px; | ||
display: flex; | ||
`; | ||
|
||
const MoreIndicator = styled.span` | ||
float: right; | ||
`; | ||
|
||
interface Props { | ||
schemaFieldEntity: SchemaFieldEntity; | ||
propColumn: SearchResult | undefined; | ||
} | ||
|
||
const StructuredPropValues = ({ schemaFieldEntity, propColumn }: Props) => { | ||
const entityRegistry = useEntityRegistry(); | ||
|
||
const property = schemaFieldEntity.structuredProperties?.properties?.find( | ||
(prop) => prop.structuredProperty.urn === propColumn?.entity.urn, | ||
); | ||
const propRow = property ? mapStructuredPropertyToPropertyRow(property) : undefined; | ||
const values = propRow?.values; | ||
const isRichText = propRow?.dataType?.info.type === StdDataType.RichText; | ||
|
||
const hasMoreValues = values && values.length > 2; | ||
const displayedValues = hasMoreValues ? values.slice(0, 1) : values; | ||
const tooltipContent = values?.map((value) => { | ||
const title = value.entity | ||
? entityRegistry.getDisplayName(value.entity.type, value.entity) | ||
: value.value?.toString(); | ||
return <div>{title}</div>; | ||
}); | ||
|
||
return ( | ||
<> | ||
{values && ( | ||
<> | ||
{displayedValues?.map((val) => { | ||
return ( | ||
<ValuesContainer> | ||
<StructuredPropertyValue | ||
value={val} | ||
isRichText={isRichText} | ||
truncateText | ||
isFieldColumn | ||
/> | ||
</ValuesContainer> | ||
); | ||
})} | ||
{hasMoreValues && ( | ||
<Tooltip title={tooltipContent} showArrow={false}> | ||
<MoreIndicator>...</MoreIndicator> | ||
</Tooltip> | ||
)} | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default StructuredPropValues; |
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
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
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
Oops, something went wrong.