From 10ef83779ea17ad1eaea81d7d6438c293c72500b Mon Sep 17 00:00:00 2001 From: karanh37 <33024356+karanh37@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:10:28 +0530 Subject: [PATCH] Data products explore tab (#13578) * fix: add data products in explore tab * fix: add data products to explore * fix: update icon positioning * fix: make dataProducts as default tab on explore * fix: multiple api calls * fix: data product feedback * fix: filtering ui screen for data product * fix: sonar tests --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> --- .../ui/src/assets/svg/ic-feeds-filter.svg | 3 + .../ui/src/components/AppBar/Appbar.tsx | 3 + .../AssetSelectionModal.interface.ts | 1 + .../AssetSelectionModal.tsx | 12 +--- .../DataProductsDetailsPage.component.tsx | 34 ++++------ .../data-products-details-page.less | 1 - .../DataProductsPage.component.tsx | 2 +- .../AdvanceSearchProvider.component.tsx | 56 ++++++++++++++-- .../DataProductSummary.component.tsx | 27 ++++++++ .../ui/src/components/Explore/exlore.mock.ts | 5 ++ .../components/Explore/explore.interface.ts | 1 + .../ExploreSearchCard/ExploreSearchCard.tsx | 3 +- .../ExploreV1/ExploreV1.component.tsx | 1 - .../components/ExploreV1/ExploreV1.test.tsx | 1 + .../src/components/FeedEditor/FeedEditor.tsx | 14 +++- .../GlossaryTermsV1.component.tsx | 4 ++ .../PermissionProvider.test.tsx | 33 +++++----- .../PermissionProvider/PermissionProvider.tsx | 8 +-- .../Widgets/FeedsWidget/feeds-widget.less | 2 +- .../EntitySummaryDetails.tsx | 38 +++++------ .../FeedsFilterPopover.component.tsx | 4 +- .../src/constants/AdvancedSearch.constants.ts | 11 ++++ .../ui/src/constants/LeftSidebar.constants.ts | 2 +- .../ui/src/constants/explore.constants.ts | 6 ++ .../src/constants/mockTourData.constants.ts | 1 + .../pages/explore/ExplorePageV1.component.tsx | 65 +++++++++++-------- .../main/resources/ui/src/utils/APIUtils.ts | 3 +- .../ui/src/utils/AdvancedSearchUtils.tsx | 3 + .../resources/ui/src/utils/DomainUtils.tsx | 20 ++++++ 29 files changed, 248 insertions(+), 116 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-feeds-filter.svg diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-feeds-filter.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-feeds-filter.svg new file mode 100644 index 00000000000..45afd156ae5 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-feeds-filter.svg @@ -0,0 +1,3 @@ + + + diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AppBar/Appbar.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AppBar/Appbar.tsx index 0ba73a5b60e..c5daefc521c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AppBar/Appbar.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AppBar/Appbar.tsx @@ -240,6 +240,9 @@ const Appbar: React.FC = (): JSX.Element => { tab: defaultTab, search: value, isPersistFilters: false, + extraParameters: { + sort: '_score', + }, }) ); } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.interface.ts index a3fdc561866..35cc267fd10 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.interface.ts @@ -38,6 +38,7 @@ export interface AssetSelectionModalProps { type?: AssetsOfEntity; onCancel: () => void; onSave?: () => void; + queryFilter?: Record; } export type AssetsUnion = diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx index 2cbe193db55..6f49f28a272 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx @@ -38,7 +38,6 @@ import { getAssetsSearchIndex, getEntityAPIfromSource, } from '../../../utils/Assets/AssetsUtils'; -import { getQueryFilterToExcludeTerm } from '../../../utils/GlossaryUtils'; import Searchbar from '../../common/searchbar/Searchbar'; import TableDataCardV2 from '../../common/table-data-card-v2/TableDataCardV2'; import { AssetsOfEntity } from '../../Glossary/GlossaryTerms/tabs/AssetsTabs.interface'; @@ -53,6 +52,7 @@ export const AssetSelectionModal = ({ onSave, open, type = AssetsOfEntity.GLOSSARY, + queryFilter = {}, }: AssetSelectionModalProps) => { const { t } = useTranslation(); const [search, setSearch] = useState(''); @@ -67,14 +67,6 @@ export const AssetSelectionModal = ({ const [pageNumber, setPageNumber] = useState(1); const [totalCount, setTotalCount] = useState(0); - const queryFilter = useMemo(() => { - if (type === AssetsOfEntity.GLOSSARY) { - return getQueryFilterToExcludeTerm(entityFqn); - } else { - return {}; - } - }, [entityFqn, type]); - const fetchEntities = useCallback( async ({ searchText = '', page = 1, index = activeFilter }) => { try { @@ -106,7 +98,7 @@ export const AssetSelectionModal = ({ } else if (type === AssetsOfEntity.DATA_PRODUCT) { const data = await getDataProductByName( encodeURIComponent(entityFqn), - '' + 'domain' ); setActiveEntity(data); } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/DataProductsDetailsPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/DataProductsDetailsPage.component.tsx index e4ea9fb6830..cfa5ee6130c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/DataProductsDetailsPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/DataProductsDetailsPage.component.tsx @@ -44,10 +44,7 @@ import { EntityDetailsObjectInterface } from '../../../components/Explore/explor import AssetsTabs, { AssetsTabRef, } from '../../../components/Glossary/GlossaryTerms/tabs/AssetsTabs.component'; -import { - AssetsOfEntity, - AssetsViewType, -} from '../../../components/Glossary/GlossaryTerms/tabs/AssetsTabs.interface'; +import { AssetsOfEntity } from '../../../components/Glossary/GlossaryTerms/tabs/AssetsTabs.interface'; import EntityDeleteModal from '../../../components/Modals/EntityDeleteModal/EntityDeleteModal'; import EntityNameModal from '../../../components/Modals/EntityNameModal/EntityNameModal.component'; import { usePermissionProvider } from '../../../components/PermissionProvider/PermissionProvider'; @@ -56,7 +53,6 @@ import { ResourceEntity, } from '../../../components/PermissionProvider/PermissionProvider.interface'; import TabsLabel from '../../../components/TabsLabel/TabsLabel.component'; -import { FQN_SEPARATOR_CHAR } from '../../../constants/char.constants'; import { DE_ACTIVE_COLOR } from '../../../constants/constants'; import { EntityField } from '../../../constants/Feeds.constants'; import { myDataSearchIndex } from '../../../constants/Mydata.constants'; @@ -70,8 +66,9 @@ import { Operation } from '../../../generated/entity/policies/policy'; import { Style } from '../../../generated/type/tagLabel'; import { searchData } from '../../../rest/miscAPI'; import { getEntityDeleteMessage } from '../../../utils/CommonUtils'; +import { getQueryFilterToIncludeDomain } from '../../../utils/DomainUtils'; +import { getEntityName } from '../../../utils/EntityUtils'; import { getEntityVersionByField } from '../../../utils/EntityVersionUtils'; -import Fqn from '../../../utils/Fqn.js'; import { checkPermission, DEFAULT_ENTITY_PERMISSION, @@ -117,25 +114,18 @@ const DataProductsDetailsPage = ({ const [assetCount, setAssetCount] = useState(0); const breadcrumbs = useMemo(() => { - if (!dataProductFqn) { + if (!dataProduct.domain) { return []; } - const arr = Fqn.split(dataProductFqn); - const dataFQN: Array = []; - return [ - ...arr.slice(0, -1).map((d) => { - dataFQN.push(d); - - return { - name: d, - url: getDomainPath(dataFQN.join(FQN_SEPARATOR_CHAR)), - activeTitle: false, - }; - }), + { + name: getEntityName(dataProduct.domain), + url: getDomainPath(dataProduct.domain.fullyQualifiedName), + activeTitle: false, + }, ]; - }, [dataProductFqn]); + }, [dataProduct.domain]); const [name, displayName] = useMemo(() => { const defaultName = dataProduct.name; @@ -425,7 +415,6 @@ const DataProductsDetailsPage = ({ permissions={dataProductPermission} ref={assetTabRef} type={AssetsOfEntity.DATA_PRODUCT} - viewType={AssetsViewType.TABS} onAddAsset={() => setAssetModelVisible(true)} onAssetClick={handleAssetClick} /> @@ -575,6 +564,9 @@ const DataProductsDetailsPage = ({ setAssetModelVisible(false)} onSave={handleAssetSave} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/data-products-details-page.less b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/data-products-details-page.less index 26b4b4751b8..cd099e288c1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/data-products-details-page.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsDetailsPage/data-products-details-page.less @@ -40,6 +40,5 @@ } .summary-panel-container { height: @domain-page-height; - border-left: 1px solid @border-color; } } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsPage/DataProductsPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsPage/DataProductsPage.component.tsx index 6263aa41d1f..2001a5edc91 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsPage/DataProductsPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataProducts/DataProductsPage/DataProductsPage.component.tsx @@ -101,7 +101,7 @@ const DataProductsPage = () => { try { const data = await getDataProductByName( encodeURIComponent(fqn), - 'owner,experts' + 'domain,owner,experts' ); setDataProduct(data); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx index a4a418604a5..884e2357149 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { isNil, isString } from 'lodash'; +import { cloneDeep, isNil, isString } from 'lodash'; import Qs from 'qs'; import React, { useCallback, @@ -22,9 +22,11 @@ import React, { } from 'react'; import { Config, + FieldGroup, ImmutableTree, JsonTree, Utils as QbUtils, + ValueSource, } from 'react-awesome-query-builder'; import { useHistory, useLocation, useParams } from 'react-router-dom'; import { @@ -33,7 +35,9 @@ import { } from '../../../constants/AdvancedSearch.constants'; import { tabsInfo } from '../../../constants/explore.constants'; import { SearchIndex } from '../../../enums/search.enum'; +import { getTypeByFQN } from '../../../rest/metadataTypeAPI'; import { elasticSearchFormat } from '../../../utils/QueryBuilderElasticsearchFormatUtils'; +import { getEntityTypeFromSearchIndex } from '../../../utils/SearchUtils'; import Loader from '../../Loader/Loader'; import { AdvancedSearchModal } from '../AdvanceSearchModal.component'; import { ExploreSearchIndex, UrlParams } from '../explore.interface'; @@ -165,15 +169,55 @@ export const AdvanceSearchProvider = ({ }); }, [history, location.pathname]); - useEffect(() => { - if (jsonTree) { - const tree = QbUtils.checkTree(QbUtils.loadTree(jsonTree), config); + async function getCustomAttributesSubfields() { + const updatedConfig = cloneDeep(config); + try { + const entityType = getEntityTypeFromSearchIndex(searchIndex); + if (!entityType) { + return; + } + const res = await getTypeByFQN(entityType); + const customAttributes = res.customProperties; + + const subfields: Record< + string, + { type: string; valueSources: ValueSource[] } + > = {}; + + if (customAttributes) { + customAttributes.forEach((attr) => { + subfields[attr.name] = { + type: 'text', + valueSources: ['value'], + }; + }); + } + (updatedConfig.fields.extension as FieldGroup).subfields = subfields; + + return updatedConfig; + } catch (error) { + // Error + return updatedConfig; + } + } + + const loadTree = useCallback( + async (treeObj: JsonTree) => { + const updatedConfig = (await getCustomAttributesSubfields()) ?? config; + const tree = QbUtils.checkTree(QbUtils.loadTree(treeObj), updatedConfig); setTreeInternal(tree); const qFilter = { - query: elasticSearchFormat(tree, config), + query: elasticSearchFormat(tree, updatedConfig), }; setQueryFilter(qFilter); - setSQLQuery(QbUtils.sqlFormat(tree, config) ?? ''); + setSQLQuery(QbUtils.sqlFormat(tree, updatedConfig) ?? ''); + }, + [config] + ); + + useEffect(() => { + if (jsonTree) { + loadTree(jsonTree); } else { handleReset(); } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/DataProductSummary/DataProductSummary.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/DataProductSummary/DataProductSummary.component.tsx index 401bde4d32a..66ea58468b9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/DataProductSummary/DataProductSummary.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/DataProductSummary/DataProductSummary.component.tsx @@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next'; import { DataProduct } from '../../../../generated/entity/domains/dataProduct'; import { getEntityName } from '../../../../utils/EntityUtils'; import { OwnerLabel } from '../../../common/OwnerLabel/OwnerLabel.component'; +import RichTextEditorPreviewer from '../../../common/rich-text-editor/RichTextEditorPreviewer'; import SummaryPanelSkeleton from '../../../Skeleton/SummaryPanelSkeleton/SummaryPanelSkeleton.component'; interface DataProductSummaryProps { @@ -50,6 +51,32 @@ const DataProductSummary = ({ + + + + {t('label.description')} + + + +
+ {entityDetails.description?.trim() ? ( + + ) : ( + + {t('label.no-data-found')} + + )} +
+ +
+ + + = { }; export const MOCK_EXPLORE_TAB_ITEMS = [ + { + key: 'data_product_search_index', + label: 'data_product_search_index', + count: 0, + }, { key: 'table_search_index', label: 'table_search_index', diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/explore.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Explore/explore.interface.ts index 0869c6fb46b..9d1825699cb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/explore.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/explore.interface.ts @@ -46,6 +46,7 @@ export type UrlParams = { }; export type ExploreSearchIndex = + | SearchIndex.DATA_PRODUCT | SearchIndex.TABLE | SearchIndex.PIPELINE | SearchIndex.DASHBOARD diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx index 9a42309e7a4..8fa869fab11 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx @@ -101,7 +101,8 @@ const ExploreSearchCard: React.FC = forwardRef< if ( source.entityType !== EntityType.GLOSSARY_TERM && - source.entityType !== EntityType.TAG + source.entityType !== EntityType.TAG && + source.entityType !== EntityType.DATA_PRODUCT ) { _otherDetails.push({ key: 'Tier', diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.component.tsx index f613c84b5d9..57647fe040c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.component.tsx @@ -76,7 +76,6 @@ const ExploreV1: React.FC = ({ quickFilters, }) => { const { t } = useTranslation(); - // const { tab } = useParams<{ tab: string }>(); const [selectedQuickFilters, setSelectedQuickFilters] = useState< ExploreQuickFilterField[] >([] as ExploreQuickFilterField[]); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.test.tsx index 6261b089227..61235824d6e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreV1.test.tsx @@ -67,6 +67,7 @@ const props = { tabItems: MOCK_EXPLORE_TAB_ITEMS, activeTabKey: SearchIndex.TABLE, tabCounts: { + data_product_search_index: 0, table_search_index: 20, topic_search_index: 10, dashboard_search_index: 14, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/FeedEditor/FeedEditor.tsx b/openmetadata-ui/src/main/resources/ui/src/components/FeedEditor/FeedEditor.tsx index f5b6f129584..8c3816f82ef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/FeedEditor/FeedEditor.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/FeedEditor/FeedEditor.tsx @@ -101,10 +101,15 @@ export const FeedEditor = forwardRef( renderLoading: () => `${t('label.loading')}...`, renderItem: (item: Record) => { if (!item.type) { - return `
+ const userResult = `
${item.avatarEle} ${item.name}
`; + + const userWrapper = document.createElement('div'); + userWrapper.innerHTML = userResult; + + return userWrapper; } const breadcrumbsData = item.breadcrumbs @@ -127,7 +132,7 @@ export const FeedEditor = forwardRef( ? `${item.type}` : ''; - return `
+ const result = `
${icon}
${breadcrumbEle} @@ -137,6 +142,11 @@ export const FeedEditor = forwardRef(
`; + + const wrapper = document.createElement('div'); + wrapper.innerHTML = result; + + return wrapper; }, }, markdownOptions: {}, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/GlossaryTermsV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/GlossaryTermsV1.component.tsx index e400ec84ed7..cb6c838b344 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/GlossaryTermsV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/GlossaryTermsV1.component.tsx @@ -25,6 +25,7 @@ import { ChangeDescription } from '../../../generated/entity/type'; import { searchData } from '../../../rest/miscAPI'; import { getCountBadge, getFeedCounts } from '../../../utils/CommonUtils'; import { getEntityVersionByField } from '../../../utils/EntityVersionUtils'; +import { getQueryFilterToExcludeTerm } from '../../../utils/GlossaryUtils'; import { getGlossaryTermsVersionsPath } from '../../../utils/RouterUtils'; import { getEncodedFqn } from '../../../utils/StringsUtils'; import { ActivityFeedTab } from '../../ActivityFeed/ActivityFeedTab/ActivityFeedTab.component'; @@ -321,6 +322,9 @@ const GlossaryTermsV1 = ({ setAssetModelVisible(false)} onSave={handleAssetSave} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.test.tsx index 177a71ba628..18731075055 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.test.tsx @@ -12,8 +12,6 @@ */ import { render, screen } from '@testing-library/react'; import React from 'react'; -import AppState from '../../AppState'; -import { User } from '../../generated/entity/teams/user'; import { getEntityPermissionByFqn, getEntityPermissionById, @@ -37,13 +35,25 @@ jest.mock('../../rest/permissionAPI', () => ({ .mockImplementation(() => Promise.resolve({})), })); +jest.mock('react-router-dom', () => ({ + useHistory: jest.fn().mockReturnValue({ push: jest.fn(), listen: jest.fn() }), +})); + +let currentUser: { id: string; name: string } | null = { + id: '123', + name: 'Test User', +}; + +jest.mock('../authentication/auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn().mockImplementation(() => ({ + currentUser, + })), + }; +}); + describe('PermissionProvider', () => { it('Should render children and call apis when current user is present', async () => { - const currentUser = { id: '123', name: 'Test User' }; - const getUserDetailsSpy = jest - .spyOn(AppState, 'getCurrentUserDetails') - .mockReturnValue(currentUser as User); - render(
Children
@@ -57,15 +67,10 @@ describe('PermissionProvider', () => { expect(getResourcePermission).not.toHaveBeenCalled(); expect(await screen.findByTestId('children')).toBeInTheDocument(); - - getUserDetailsSpy.mockRestore(); }); it('Should not call apis when current user is undefined', async () => { - const getUserDetailsSpy = jest - .spyOn(AppState, 'getCurrentUserDetails') - .mockReturnValue(undefined); - + currentUser = null; render(
Children
@@ -77,7 +82,5 @@ describe('PermissionProvider', () => { expect(getEntityPermissionById).not.toHaveBeenCalled(); expect(getEntityPermissionByFqn).not.toHaveBeenCalled(); expect(getResourcePermission).not.toHaveBeenCalled(); - - getUserDetailsSpy.mockRestore(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.tsx index 7d7e4bfa029..4e73a80b8d4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/PermissionProvider/PermissionProvider.tsx @@ -24,7 +24,6 @@ import React, { useState, } from 'react'; import { useHistory } from 'react-router-dom'; -import AppState from '../../AppState'; import Loader from '../../components/Loader/Loader'; import { REDIRECT_PATHNAME } from '../../constants/constants'; import { @@ -41,6 +40,7 @@ import { getOperationPermissions, getUIPermission, } from '../../utils/PermissionsUtils'; +import { useAuthContext } from '../authentication/auth-provider/AuthProvider'; import { EntityPermissionMap, PermissionContextType, @@ -67,6 +67,7 @@ const PermissionProvider: FC = ({ children }) => { const [permissions, setPermissions] = useState( {} as UIPermission ); + const { currentUser } = useAuthContext(); const cookieStorage = new CookieStorage(); const history = useHistory(); const [loading, setLoading] = useState(false); @@ -78,11 +79,6 @@ const PermissionProvider: FC = ({ children }) => { {} as UIPermission ); - // Update current user details of AppState change - const currentUser = useMemo(() => { - return AppState.getCurrentUserDetails(); - }, [AppState.userDetails, AppState.nonSecureUserDetails]); - const redirectToStoredPath = useCallback(() => { const urlPathname = cookieStorage.getItem(REDIRECT_PATHNAME); if (urlPathname) { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Widgets/FeedsWidget/feeds-widget.less b/openmetadata-ui/src/main/resources/ui/src/components/Widgets/FeedsWidget/feeds-widget.less index c5da7d52d40..f12fb49899a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Widgets/FeedsWidget/feeds-widget.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/Widgets/FeedsWidget/feeds-widget.less @@ -29,7 +29,7 @@ } .ant-tabs-nav { padding: 8px 16px 0 28px; - margin-bottom: 0; + margin-bottom: 0 !important; } .widget-manage-dropdown .ant-dropdown-trigger { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx index 511fae173e5..ce516d6d565 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx @@ -84,25 +84,21 @@ const EntitySummaryDetails = ({ /> ); - const { - isEntityDetails, - userDetails, - isTier, - isOwner, + const { isEntityDetails, userDetails, isTier, isOwner, isTeamOwner } = + useMemo(() => { + const userDetails = getTeamsUser(data); - isTeamOwner, - } = useMemo(() => { - const userDetails = getTeamsUser(data); - - return { - isEntityCard: data?.isEntityCard, - isEntityDetails: data?.isEntityDetails, - userDetails, - isTier: data.key === 'Tier', - isOwner: data.key === 'Owner', - isTeamOwner: isString(data.value) ? data.value.includes('teams/') : false, - }; - }, [data]); + return { + isEntityCard: data?.isEntityCard, + isEntityDetails: data?.isEntityDetails, + userDetails, + isTier: data.key === 'Tier', + isOwner: data.key === 'Owner', + isTeamOwner: isString(data.value) + ? data.value.includes('teams/') + : false, + }; + }, [data]); switch (data.key) { case 'Owner': @@ -129,7 +125,11 @@ const EntitySummaryDetails = ({ )} {isTeamOwner ? ( - + ) : ( - +