1
1
import { LayoutOutlined } from '@ant-design/icons' ;
2
+ import { MatchesGroupedByFieldName } from '@app/searchV2/matches/constants' ;
2
3
import React , { useContext } from 'react' ;
3
4
import AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined' ;
4
5
import FindInPageOutlinedIcon from '@mui/icons-material/FindInPageOutlined' ;
5
6
import SellOutlinedIcon from '@mui/icons-material/SellOutlined' ;
6
7
import styled from 'styled-components' ;
7
8
import { BookmarkSimple } from '@phosphor-icons/react' ;
8
- import { useMatchedFieldsForList } from '../search/context/SearchResultContext' ;
9
- import {
10
- EntityPath ,
11
- EntityType ,
12
- GlossaryTermAssociation ,
13
- LineageDirection ,
14
- Owner ,
15
- TagAssociation ,
16
- } from '../../types.generated' ;
17
- import { EntityCapabilityType } from '../entityV2/Entity' ;
9
+ import { EntityPath , GlossaryTermAssociation , LineageDirection , Owner , TagAssociation } from '../../types.generated' ;
18
10
import MatchesContext , { PreviewSection } from '../shared/MatchesContext' ;
19
11
import SearchPill from './SearchPill' ;
20
- import { entityHasCapability , getHighlightedTag } from './utils' ;
21
- import { LineageTabContext } from '../entityV2/shared/tabs/Lineage/LineageTabContext' ;
12
+ import { getHighlightedTag } from './utils' ;
22
13
23
14
const PillsContainer = styled . div `
24
15
gap: 5px;
@@ -32,19 +23,14 @@ interface Props {
32
23
glossaryTerms : GlossaryTermAssociation [ ] ;
33
24
tags : TagAssociation [ ] ;
34
25
owners : Owner [ ] ;
35
- entityCapabilities : Set < EntityCapabilityType > ;
26
+ groupedMatches : MatchesGroupedByFieldName [ ] ;
36
27
paths ?: EntityPath [ ] ;
37
- entityType : EntityType ;
28
+ lineageDirection : LineageDirection ;
38
29
}
39
30
40
- const Pills = ( { glossaryTerms, tags, owners, entityCapabilities, paths, entityType } : Props ) => {
41
- const { lineageDirection, isColumnLevelLineage, selectedColumn } = useContext ( LineageTabContext ) ;
31
+ const Pills = ( { glossaryTerms, tags, owners, groupedMatches, paths, lineageDirection } : Props ) => {
42
32
const lineageDirectionText = lineageDirection === LineageDirection . Downstream ? 'downstream' : 'upstream' ;
43
33
const { setExpandedSection, expandedSection } = useContext ( MatchesContext ) ;
44
- const groupedMatches = useMatchedFieldsForList ( 'fieldLabels' ) ;
45
- const showGlossaryTermsBadge = entityHasCapability ( entityCapabilities , EntityCapabilityType . GLOSSARY_TERMS ) ;
46
- const showTagsBadge = entityHasCapability ( entityCapabilities , EntityCapabilityType . TAGS ) ;
47
- const showOwnersBadge = entityHasCapability ( entityCapabilities , EntityCapabilityType . OWNERS ) ;
48
34
const highlightedTag = getHighlightedTag ( tags ) ;
49
35
50
36
const handlePillClick = ( section : PreviewSection | undefined , data ) => ( e ) => {
@@ -56,7 +42,7 @@ const Pills = ({ glossaryTerms, tags, owners, entityCapabilities, paths, entityT
56
42
57
43
return (
58
44
< PillsContainer >
59
- { showGlossaryTermsBadge && ! ! glossaryTerms . length && (
45
+ { ! ! glossaryTerms . length && (
60
46
< SearchPill
61
47
icon = { < BookmarkSimple /> }
62
48
count = { glossaryTerms . length || 0 }
@@ -68,7 +54,7 @@ const Pills = ({ glossaryTerms, tags, owners, entityCapabilities, paths, entityT
68
54
highlightedText = { glossaryTerms . length ? glossaryTerms [ 0 ] ?. term ?. properties ?. name : '' }
69
55
/>
70
56
) }
71
- { showTagsBadge && ! ! tags . length && (
57
+ { ! ! tags . length && (
72
58
< SearchPill
73
59
icon = { < SellOutlinedIcon /> }
74
60
count = { tags . length }
@@ -80,7 +66,7 @@ const Pills = ({ glossaryTerms, tags, owners, entityCapabilities, paths, entityT
80
66
highlightedText = { highlightedTag }
81
67
/>
82
68
) }
83
- { showOwnersBadge && ! ! owners . length && (
69
+ { ! ! owners . length && (
84
70
< SearchPill
85
71
icon = { < AccountCircleOutlinedIcon /> }
86
72
count = { owners . length }
@@ -92,7 +78,7 @@ const Pills = ({ glossaryTerms, tags, owners, entityCapabilities, paths, entityT
92
78
/>
93
79
) }
94
80
95
- { groupedMatches . length > 0 && (
81
+ { ! ! groupedMatches . length && (
96
82
< SearchPill
97
83
icon = { < FindInPageOutlinedIcon /> }
98
84
count = { groupedMatches ?. length || 0 }
@@ -103,22 +89,17 @@ const Pills = ({ glossaryTerms, tags, owners, entityCapabilities, paths, entityT
103
89
onClick = { handlePillClick ( PreviewSection . MATCHES , groupedMatches ) }
104
90
/>
105
91
) }
106
- { /* only show the column paths pill on datasets who actually have columns to show */ }
107
- { paths &&
108
- paths . length > 0 &&
109
- entityType === EntityType . Dataset &&
110
- isColumnLevelLineage &&
111
- selectedColumn && (
112
- < SearchPill
113
- icon = { < LayoutOutlined /> }
114
- count = { paths . length || 0 }
115
- enabled = { ! ! paths . length }
116
- active = { expandedSection === PreviewSection . COLUMN_PATHS }
117
- label = ""
118
- countLabel = { `${ lineageDirectionText } column` }
119
- onClick = { handlePillClick ( PreviewSection . COLUMN_PATHS , paths ) }
120
- />
121
- ) }
92
+ { ! ! paths ?. length && (
93
+ < SearchPill
94
+ icon = { < LayoutOutlined /> }
95
+ count = { paths . length }
96
+ enabled = { ! ! paths . length }
97
+ active = { expandedSection === PreviewSection . COLUMN_PATHS }
98
+ label = ""
99
+ countLabel = { `${ lineageDirectionText } column` }
100
+ onClick = { handlePillClick ( PreviewSection . COLUMN_PATHS , paths ) }
101
+ />
102
+ ) }
122
103
</ PillsContainer >
123
104
) ;
124
105
} ;
0 commit comments