mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 10:49:00 +00:00 
			
		
		
		
	feat(frontend): add additional tabs to glossary terms view (#7392)
Adds tabs for "Contained by" and "Inherited by" on the Glossary Related Terms tab.
This commit is contained in:
		
							parent
							
								
									d436ab9f9b
								
							
						
					
					
						commit
						79aa66ab0a
					
				| @ -12,6 +12,8 @@ import RelatedTerm from './RelatedTerm'; | |||||||
| export enum RelatedTermTypes { | export enum RelatedTermTypes { | ||||||
|     hasRelatedTerms = 'Contains', |     hasRelatedTerms = 'Contains', | ||||||
|     isRelatedTerms = 'Inherits', |     isRelatedTerms = 'Inherits', | ||||||
|  |     containedBy = 'Contained by', | ||||||
|  |     isAChildren = 'Inherited by', | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type Props = { | export type Props = { | ||||||
| @ -42,9 +44,13 @@ export default function GlossaryRelatedTermsResult({ glossaryRelatedTermType, gl | |||||||
|     }); |     }); | ||||||
|     const contentLoading = false; |     const contentLoading = false; | ||||||
|     const relationshipType = |     const relationshipType = | ||||||
|         glossaryRelatedTermType === RelatedTermTypes.hasRelatedTerms |         glossaryRelatedTermType === RelatedTermTypes.hasRelatedTerms || | ||||||
|  |         glossaryRelatedTermType === RelatedTermTypes.containedBy | ||||||
|             ? TermRelationshipType.HasA |             ? TermRelationshipType.HasA | ||||||
|             : TermRelationshipType.IsA; |             : TermRelationshipType.IsA; | ||||||
|  |     const canEditRelatedTerms = | ||||||
|  |         glossaryRelatedTermType === RelatedTermTypes.isRelatedTerms || | ||||||
|  |         glossaryRelatedTermType === RelatedTermTypes.hasRelatedTerms; | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <> |         <> | ||||||
| @ -56,12 +62,19 @@ export default function GlossaryRelatedTermsResult({ glossaryRelatedTermType, gl | |||||||
|                         <Typography.Title style={{ margin: '0' }} level={3}> |                         <Typography.Title style={{ margin: '0' }} level={3}> | ||||||
|                             {glossaryRelatedTermType} |                             {glossaryRelatedTermType} | ||||||
|                         </Typography.Title> |                         </Typography.Title> | ||||||
|  |                         {canEditRelatedTerms && ( | ||||||
|                             <Button type="text" onClick={() => setIsShowingAddModal(true)}> |                             <Button type="text" onClick={() => setIsShowingAddModal(true)}> | ||||||
|                                 <PlusOutlined /> Add Terms |                                 <PlusOutlined /> Add Terms | ||||||
|                             </Button> |                             </Button> | ||||||
|  |                         )} | ||||||
|                     </TitleContainer> |                     </TitleContainer> | ||||||
|                     {glossaryRelatedTermUrns.map((urn) => ( |                     {glossaryRelatedTermUrns.map((urn) => ( | ||||||
|                         <RelatedTerm key={urn} urn={urn} relationshipType={relationshipType} /> |                         <RelatedTerm | ||||||
|  |                             key={urn} | ||||||
|  |                             urn={urn} | ||||||
|  |                             relationshipType={relationshipType} | ||||||
|  |                             isEditable={canEditRelatedTerms} | ||||||
|  |                         /> | ||||||
|                     ))} |                     ))} | ||||||
|                     {glossaryRelatedTermUrns.length === 0 && ( |                     {glossaryRelatedTermUrns.length === 0 && ( | ||||||
|                         <EmptyTab tab={glossaryRelatedTermType.toLocaleLowerCase()} /> |                         <EmptyTab tab={glossaryRelatedTermType.toLocaleLowerCase()} /> | ||||||
|  | |||||||
| @ -35,10 +35,11 @@ const MenuItem = styled.div` | |||||||
| interface Props { | interface Props { | ||||||
|     urn: string; |     urn: string; | ||||||
|     relationshipType: TermRelationshipType; |     relationshipType: TermRelationshipType; | ||||||
|  |     isEditable: boolean; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function RelatedTerm(props: Props) { | function RelatedTerm(props: Props) { | ||||||
|     const { urn, relationshipType } = props; |     const { urn, relationshipType, isEditable } = props; | ||||||
| 
 | 
 | ||||||
|     const entityRegistry = useEntityRegistry(); |     const entityRegistry = useEntityRegistry(); | ||||||
|     const { data, loading } = useGetGlossaryTermQuery({ variables: { urn } }); |     const { data, loading } = useGetGlossaryTermQuery({ variables: { urn } }); | ||||||
| @ -54,6 +55,7 @@ function RelatedTerm(props: Props) { | |||||||
|         <ListItem> |         <ListItem> | ||||||
|             <Profile> |             <Profile> | ||||||
|                 {entityRegistry.renderPreview(EntityType.GlossaryTerm, PreviewType.PREVIEW, data?.glossaryTerm)} |                 {entityRegistry.renderPreview(EntityType.GlossaryTerm, PreviewType.PREVIEW, data?.glossaryTerm)} | ||||||
|  |                 {isEditable && ( | ||||||
|                     <Dropdown |                     <Dropdown | ||||||
|                         overlay={ |                         overlay={ | ||||||
|                             <Menu> |                             <Menu> | ||||||
| @ -68,6 +70,7 @@ function RelatedTerm(props: Props) { | |||||||
|                     > |                     > | ||||||
|                         <MenuIcon /> |                         <MenuIcon /> | ||||||
|                     </Dropdown> |                     </Dropdown> | ||||||
|  |                 )} | ||||||
|             </Profile> |             </Profile> | ||||||
|             <Divider style={{ margin: '20px 0' }} /> |             <Divider style={{ margin: '20px 0' }} /> | ||||||
|         </ListItem> |         </ListItem> | ||||||
|  | |||||||
| @ -51,12 +51,20 @@ export const EMPTY_MESSAGES = { | |||||||
|     }, |     }, | ||||||
|     contains: { |     contains: { | ||||||
|         title: 'Contains no Terms', |         title: 'Contains no Terms', | ||||||
|         description: 'Terms can contain other terms to represent an "Has A" style relationship.', |         description: 'Terms can contain other terms to represent a "Has A" style relationship.', | ||||||
|     }, |     }, | ||||||
|     inherits: { |     inherits: { | ||||||
|         title: 'Does not inherit from any terms', |         title: 'Does not inherit from any terms', | ||||||
|         description: 'Terms can inherit from other terms to represent an "Is A" style relationship.', |         description: 'Terms can inherit from other terms to represent an "Is A" style relationship.', | ||||||
|     }, |     }, | ||||||
|  |     'contained by': { | ||||||
|  |         title: 'Is not contained by any terms', | ||||||
|  |         description: 'Terms can be contained by other terms to represent a "Has A" style relationship.', | ||||||
|  |     }, | ||||||
|  |     'inherited by': { | ||||||
|  |         title: 'Is not inherited by any terms', | ||||||
|  |         description: 'Terms can be inherited by other terms to represent an "Is A" style relationship.', | ||||||
|  |     }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const ELASTIC_MAX_COUNT = 10000; | export const ELASTIC_MAX_COUNT = 10000; | ||||||
|  | |||||||
| @ -42,6 +42,18 @@ query getGlossaryTerm($urn: String!, $start: Int, $count: Int) { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         containedBy: relationships(input: { types: ["HasA"], direction: INCOMING, start: $start, count: $count }) { | ||||||
|  |             start | ||||||
|  |             count | ||||||
|  |             total | ||||||
|  |             relationships { | ||||||
|  |                 entity { | ||||||
|  |                     ... on GlossaryTerm { | ||||||
|  |                         urn | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|         parentNodes { |         parentNodes { | ||||||
|             ...parentNodesFields |             ...parentNodesFields | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Alexey Kravtsov
						Alexey Kravtsov