mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	chore(ui): add filter classifications option in tags container (#13668)
This commit is contained in:
		
							parent
							
								
									8cf8720a9d
								
							
						
					
					
						commit
						096a08ce57
					
				| @ -30,6 +30,7 @@ export type TagsContainerV2Props = { | |||||||
|   children?: ReactElement; |   children?: ReactElement; | ||||||
|   displayType?: DisplayType; |   displayType?: DisplayType; | ||||||
|   layoutType?: LayoutType; |   layoutType?: LayoutType; | ||||||
|  |   filterClassifications?: string[]; | ||||||
|   onSelectionChange?: (selectedTags: EntityTags[]) => Promise<void>; |   onSelectionChange?: (selectedTags: EntityTags[]) => Promise<void>; | ||||||
|   onThreadLinkSelect?: (value: string, threadType?: ThreadType) => void; |   onThreadLinkSelect?: (value: string, threadType?: ThreadType) => void; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -22,7 +22,10 @@ import { ReactComponent as IconComments } from '../../../assets/svg/comment.svg' | |||||||
| import { ReactComponent as EditIcon } from '../../../assets/svg/edit-new.svg'; | import { ReactComponent as EditIcon } from '../../../assets/svg/edit-new.svg'; | ||||||
| import { ReactComponent as IconRequest } from '../../../assets/svg/request-icon.svg'; | import { ReactComponent as IconRequest } from '../../../assets/svg/request-icon.svg'; | ||||||
| import { TableTagsProps } from '../../../components/TableTags/TableTags.interface'; | import { TableTagsProps } from '../../../components/TableTags/TableTags.interface'; | ||||||
| import { DE_ACTIVE_COLOR } from '../../../constants/constants'; | import { | ||||||
|  |   DE_ACTIVE_COLOR, | ||||||
|  |   KNOWLEDGE_CENTER_CLASSIFICATION, | ||||||
|  | } from '../../../constants/constants'; | ||||||
| import { TAG_CONSTANT, TAG_START_WITH } from '../../../constants/Tag.constants'; | import { TAG_CONSTANT, TAG_START_WITH } from '../../../constants/Tag.constants'; | ||||||
| import { SearchIndex } from '../../../enums/search.enum'; | import { SearchIndex } from '../../../enums/search.enum'; | ||||||
| import { GlossaryTerm } from '../../../generated/entity/data/glossaryTerm'; | import { GlossaryTerm } from '../../../generated/entity/data/glossaryTerm'; | ||||||
| @ -63,6 +66,7 @@ const TagsContainerV2 = ({ | |||||||
|   onSelectionChange, |   onSelectionChange, | ||||||
|   onThreadLinkSelect, |   onThreadLinkSelect, | ||||||
|   children, |   children, | ||||||
|  |   filterClassifications = [KNOWLEDGE_CENTER_CLASSIFICATION], | ||||||
| }: TagsContainerV2Props) => { | }: TagsContainerV2Props) => { | ||||||
|   const history = useHistory(); |   const history = useHistory(); | ||||||
|   const [form] = Form.useForm(); |   const [form] = Form.useForm(); | ||||||
| @ -131,7 +135,7 @@ const TagsContainerV2 = ({ | |||||||
|   const fetchAPI = useCallback( |   const fetchAPI = useCallback( | ||||||
|     (searchValue: string, page: number) => { |     (searchValue: string, page: number) => { | ||||||
|       if (tagType === TagSource.Classification) { |       if (tagType === TagSource.Classification) { | ||||||
|         return fetchTagsElasticSearch(searchValue, page); |         return fetchTagsElasticSearch(searchValue, page, filterClassifications); | ||||||
|       } else { |       } else { | ||||||
|         return fetchGlossaryList(searchValue, page); |         return fetchGlossaryList(searchValue, page); | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -840,3 +840,5 @@ export const ICON_DIMENSION = { | |||||||
| export const COMMON_ICON_STYLES: CSSProperties = { | export const COMMON_ICON_STYLES: CSSProperties = { | ||||||
|   verticalAlign: 'middle', |   verticalAlign: 'middle', | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | export const KNOWLEDGE_CENTER_CLASSIFICATION = 'KnowledgeCenter'; | ||||||
|  | |||||||
| @ -295,15 +295,18 @@ export const tagRender = (customTagProps: CustomTagProps) => { | |||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const fetchTagsElasticSearch = async ( | type ResultType = { | ||||||
|   searchText: string, |  | ||||||
|   page: number |  | ||||||
| ): Promise<{ |  | ||||||
|   data: { |  | ||||||
|   label: string; |   label: string; | ||||||
|   value: string; |   value: string; | ||||||
|   data: Tag; |   data: Tag; | ||||||
|   }[]; | }; | ||||||
|  | 
 | ||||||
|  | export const fetchTagsElasticSearch = async ( | ||||||
|  |   searchText: string, | ||||||
|  |   page: number, | ||||||
|  |   filterClassifications?: string[] | ||||||
|  | ): Promise<{ | ||||||
|  |   data: ResultType[]; | ||||||
|   paging: Paging; |   paging: Paging; | ||||||
| }> => { | }> => { | ||||||
|   const res = await searchQuery({ |   const res = await searchQuery({ | ||||||
| @ -316,11 +319,20 @@ export const fetchTagsElasticSearch = async ( | |||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     data: res.hits.hits.map(({ _source }) => ({ |     data: res.hits.hits.reduce((result: ResultType[], { _source }) => { | ||||||
|  |       const classificationName = | ||||||
|  |         _source.classification?.fullyQualifiedName ?? ''; | ||||||
|  | 
 | ||||||
|  |       if (!filterClassifications?.includes(classificationName)) { | ||||||
|  |         result.push({ | ||||||
|           label: _source.fullyQualifiedName ?? '', |           label: _source.fullyQualifiedName ?? '', | ||||||
|           value: _source.fullyQualifiedName ?? '', |           value: _source.fullyQualifiedName ?? '', | ||||||
|           data: _source, |           data: _source, | ||||||
|     })), |         }); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       return result; | ||||||
|  |     }, []), | ||||||
|     paging: { |     paging: { | ||||||
|       total: res.hits.total.value, |       total: res.hits.total.value, | ||||||
|     }, |     }, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sachin Chaurasiya
						Sachin Chaurasiya