From 8d4c3bb1a476d8a059938d1c48e59bfe150964bb Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Tue, 17 Oct 2023 11:20:53 +0530 Subject: [PATCH] chore(ui): update block editor extension to show correct data (#13591) Co-authored-by: Sriharsha Chintalapani Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> --- .../ui/src/components/BlockEditor/BlockEditor.tsx | 3 ++- .../Extensions/hashtag/hashtagSuggestion.ts | 9 +++++---- .../Extensions/mention/mentionSuggestions.ts | 10 +++++----- .../BlockEditor/Extensions/slashCommand/renderItems.ts | 3 ++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockEditor.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockEditor.tsx index f1afc513824..1e41d4722ab 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockEditor.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockEditor.tsx @@ -121,7 +121,7 @@ const BlockEditor = forwardRef( const target = e.target as HTMLElement; const dataType = target.getAttribute('data-type'); - const hasPopup = !isEmpty(popup); + let hasPopup = !isEmpty(popup); if (['mention', 'hashtag'].includes(dataType ?? '')) { return; @@ -158,6 +158,7 @@ const BlockEditor = forwardRef( placement: 'top', hideOnClick: true, }); + hasPopup = !isEmpty(popup); } else { if (hasPopup) { popup[0].hide(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/hashtag/hashtagSuggestion.ts b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/hashtag/hashtagSuggestion.ts index 07527936e24..c8d9dfce1f9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/hashtag/hashtagSuggestion.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/hashtag/hashtagSuggestion.ts @@ -27,13 +27,13 @@ import HashList from './HashList'; export const hashtagSuggestion = () => ({ items: async ({ query }: { query: string }) => { if (!query) { - const data = await searchData('*', 1, 5, '', '', '', SearchIndex.TABLE); + const data = await searchData('', 1, 5, '', '', '', SearchIndex.ALL); const hits = data.data.hits.hits; return hits.map((hit) => ({ id: hit._id, name: hit._source.name, - label: hit._source.displayName, + label: hit._source.displayName ?? hit._source.name, fqn: hit._source.fullyQualifiedName, href: buildMentionLink( hit._source.entityType, @@ -53,7 +53,7 @@ export const hashtagSuggestion = () => ({ return hits.map((hit) => ({ id: hit._id, name: hit._source.name, - label: hit._source.displayName, + label: hit._source.displayName ?? hit._source.name, fqn: hit._source.fullyQualifiedName, href: buildMentionLink( hit._source.entityType, @@ -72,7 +72,7 @@ export const hashtagSuggestion = () => ({ render: () => { let component: ReactRenderer; let popup: Instance[] = []; - const hasPopup = !isEmpty(popup); + let hasPopup = !isEmpty(popup); return { onStart: (props: SuggestionProps) => { @@ -95,6 +95,7 @@ export const hashtagSuggestion = () => ({ trigger: 'manual', placement: 'bottom-start', }); + hasPopup = !isEmpty(popup); }, onUpdate(props: SuggestionProps) { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/mention/mentionSuggestions.ts b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/mention/mentionSuggestions.ts index 713cbc12be1..b0a96b14ca5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/mention/mentionSuggestions.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/mention/mentionSuggestions.ts @@ -14,7 +14,6 @@ import { ReactRenderer } from '@tiptap/react'; import { SuggestionKeyDownProps, SuggestionProps } from '@tiptap/suggestion'; import { isEmpty } from 'lodash'; import tippy, { Instance, Props } from 'tippy.js'; -import { WILD_CARD_CHAR } from '../../../../constants/char.constants'; import { EntityUrlMapType, ENTITY_URL_MAP, @@ -27,13 +26,13 @@ import MentionList from './MentionList'; export const mentionSuggestion = () => ({ items: async ({ query }: { query: string }) => { if (!query) { - const data = await getSearchedUsers(WILD_CARD_CHAR, 1, 5); + const data = await getSearchedUsers('', 1, 5); const hits = data.data.hits.hits; return hits.map((hit) => ({ id: hit._id, name: hit._source.name, - label: hit._source.displayName, + label: hit._source.displayName ?? hit._source.name, fqn: hit._source.fullyQualifiedName, href: buildMentionLink( ENTITY_URL_MAP[hit._source.entityType as EntityUrlMapType], @@ -48,7 +47,7 @@ export const mentionSuggestion = () => ({ return hits.map((hit) => ({ id: hit._id, name: hit._source.name, - label: hit._source.displayName, + label: hit._source.displayName ?? hit._source.name, fqn: hit._source.fullyQualifiedName, href: buildMentionLink( ENTITY_URL_MAP[hit._source.entityType as EntityUrlMapType], @@ -62,7 +61,7 @@ export const mentionSuggestion = () => ({ render: () => { let component: ReactRenderer; let popup: Instance[] = []; - const hasPopup = !isEmpty(popup); + let hasPopup = !isEmpty(popup); return { onStart: (props: SuggestionProps) => { @@ -85,6 +84,7 @@ export const mentionSuggestion = () => ({ trigger: 'manual', placement: 'bottom-start', }); + hasPopup = !isEmpty(popup); }, onUpdate(props: SuggestionProps) { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/slashCommand/renderItems.ts b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/slashCommand/renderItems.ts index fafc223fc06..ed6df87fe2d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/slashCommand/renderItems.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/slashCommand/renderItems.ts @@ -20,7 +20,7 @@ const renderItems = () => { let component: ReactRenderer; let popup: Instance[] = []; let suggestionProps: SuggestionProps; - const hasPopup = !isEmpty(popup); + let hasPopup = !isEmpty(popup); return { onStart: (props: SuggestionProps) => { @@ -44,6 +44,7 @@ const renderItems = () => { trigger: 'manual', placement: 'bottom-start', }); + hasPopup = !isEmpty(popup); }, onUpdate: (props: SuggestionProps) => { suggestionProps = props;