Skip to content

Commit b4ddada

Browse files
Worked on the pop-over of matched entity (#5851)
1 parent b9b0147 commit b4ddada

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed

datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { OperationsTab } from './profile/OperationsTab';
2828
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
2929
import { SidebarSiblingsSection } from '../shared/containers/profile/sidebar/SidebarSiblingsSection';
3030
import { DatasetStatsSummarySubHeader } from './profile/stats/stats/DatasetStatsSummarySubHeader';
31+
import { TagSummary } from './shared/TagSummary';
32+
import { TermSummary } from './shared/TermSummary';
3133

3234
const SUBTYPES = {
3335
VIEW: 'view',
@@ -253,6 +255,19 @@ export class DatasetEntity implements Entity<Dataset> {
253255
renderSearch = (result: SearchResult) => {
254256
const data = result.entity as Dataset;
255257
const genericProperties = this.getGenericEntityProperties(data);
258+
259+
let snippet: React.ReactNode;
260+
261+
if (result.matchedFields.length > 0) {
262+
if (result.matchedFields[0].value.includes('urn:li:tag')) {
263+
snippet = <TagSummary urn={result.matchedFields[0].value} />;
264+
} else if (result.matchedFields[0].value.includes('urn:li:glossaryTerm')) {
265+
snippet = <TermSummary urn={result.matchedFields[0].value} />;
266+
} else {
267+
snippet = <b>{result.matchedFields[0].value}</b>;
268+
}
269+
}
270+
256271
return (
257272
<Preview
258273
urn={data.urn}
@@ -279,8 +294,7 @@ export class DatasetEntity implements Entity<Dataset> {
279294
result.matchedFields.length > 0 &&
280295
result.matchedFields.every((field) => FIELDS_TO_HIGHLIGHT.has(field.name)) && (
281296
<Typography.Text>
282-
Matches {FIELDS_TO_HIGHLIGHT.get(result.matchedFields[0].name)}{' '}
283-
<b>{result.matchedFields[0].value}</b>
297+
Matches {FIELDS_TO_HIGHLIGHT.get(result.matchedFields[0].name)} {snippet}
284298
</Typography.Text>
285299
)
286300
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import { useGetTagQuery } from '../../../../graphql/tag.generated';
4+
import { EntityType, Tag } from '../../../../types.generated';
5+
import { HoverEntityTooltip } from '../../../recommendations/renderer/component/HoverEntityTooltip';
6+
import { useEntityRegistry } from '../../../useEntityRegistry';
7+
import { StyledTag } from '../../shared/components/styled/StyledTag';
8+
9+
const TagLink = styled.span`
10+
display: inline-block;
11+
`;
12+
13+
type Props = {
14+
urn: string;
15+
};
16+
17+
export const TagSummary = ({ urn }: Props) => {
18+
const entityRegistry = useEntityRegistry();
19+
const { data } = useGetTagQuery({ variables: { urn } });
20+
return (
21+
<>
22+
{data && (
23+
<HoverEntityTooltip entity={data?.tag as Tag}>
24+
<TagLink key={data?.tag?.urn}>
25+
<StyledTag
26+
style={{ cursor: 'pointer' }}
27+
$colorHash={data?.tag?.urn}
28+
$color={data?.tag?.properties?.colorHex}
29+
closable={false}
30+
>
31+
{entityRegistry.getDisplayName(EntityType.Tag, data?.tag)}
32+
</StyledTag>
33+
</TagLink>
34+
</HoverEntityTooltip>
35+
)}
36+
</>
37+
);
38+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { Tag } from 'antd';
3+
import { BookOutlined } from '@ant-design/icons';
4+
import styled from 'styled-components';
5+
import { useGetGlossaryTermQuery } from '../../../../graphql/glossaryTerm.generated';
6+
import { HoverEntityTooltip } from '../../../recommendations/renderer/component/HoverEntityTooltip';
7+
import { EntityType, GlossaryTerm } from '../../../../types.generated';
8+
import { useEntityRegistry } from '../../../useEntityRegistry';
9+
10+
const TermLink = styled.span`
11+
display: inline-block;
12+
`;
13+
14+
type Props = {
15+
urn: string;
16+
};
17+
18+
export const TermSummary = ({ urn }: Props) => {
19+
const entityRegistry = useEntityRegistry();
20+
const { data } = useGetGlossaryTermQuery({ variables: { urn } });
21+
22+
return (
23+
<>
24+
{data && (
25+
<HoverEntityTooltip entity={data?.glossaryTerm as GlossaryTerm}>
26+
<TermLink key={data?.glossaryTerm?.urn}>
27+
<Tag closable={false} style={{ cursor: 'pointer' }}>
28+
<BookOutlined style={{ marginRight: '3%' }} />
29+
{entityRegistry.getDisplayName(EntityType.GlossaryTerm, data?.glossaryTerm)}
30+
</Tag>
31+
</TermLink>
32+
</HoverEntityTooltip>
33+
)}
34+
</>
35+
);
36+
};

datahub-web-react/src/app/entity/glossaryNode/GlossaryNodeEntity.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
114114
};
115115

116116
renderPreview = (_: PreviewType, data: GlossaryNode) => {
117-
console.log(data);
118117
return (
119118
<Preview
120119
urn={data?.urn}

0 commit comments

Comments
 (0)