Skip to content

Commit

Permalink
fix: assets fqn issue (#14140)
Browse files Browse the repository at this point in the history
* fix: assets fqn issue

* fix: unit tests

* fix: escape fqn in remaining areas
  • Loading branch information
karanh37 authored Nov 28, 2023
1 parent 5814148 commit b2a79d3
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {
setMsalInstance,
} from '../../../utils/AuthProvider.util';
import localState from '../../../utils/LocalStorageUtils';
import { escapeESReservedCharacters } from '../../../utils/StringsUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import {
fetchAllUsers,
Expand Down Expand Up @@ -429,7 +430,9 @@ export const AuthProvider = ({
// Parse and update the query parameter
const queryParams = Qs.parse(config.url.split('?')[1]);
// adding quotes for exact matching
const domainStatement = `(domain.fullyQualifiedName:${activeDomain})`;
const domainStatement = `(domain.fullyQualifiedName:${escapeESReservedCharacters(
activeDomain
)})`;
queryParams.q = queryParams.q ?? '';
queryParams.q += isEmpty(queryParams.q)
? domainStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import {
getDataProductVersionsPath,
getDomainPath,
} from '../../../utils/RouterUtils';
import { escapeESReservedCharacters } from '../../../utils/StringsUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import { EntityDetailsObjectInterface } from '../../Explore/ExplorePage.interface';
import StyleModal from '../../Modals/StyleModal/StyleModal.component';
Expand Down Expand Up @@ -202,13 +203,15 @@ const DataProductsDetailsPage = ({
}, [permissions, isVersionsView]);

const fetchDataProductAssets = async () => {
if (fqn) {
if (dataProduct) {
try {
const res = await searchData(
'',
1,
0,
`(dataProducts.fullyQualifiedName:${fqn})`,
`(dataProducts.fullyQualifiedName:"${escapeESReservedCharacters(
dataProduct.fullyQualifiedName
)}")`,
'',
'',
SearchIndex.ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import {
getDomainPath,
getDomainVersionsPath,
} from '../../../utils/RouterUtils';
import { escapeESReservedCharacters } from '../../../utils/StringsUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import DeleteWidgetModal from '../../common/DeleteWidget/DeleteWidgetModal';
import { EntityDetailsObjectInterface } from '../../Explore/ExplorePage.interface';
Expand Down Expand Up @@ -238,7 +239,9 @@ const DomainDetailsPage = ({
'',
1,
0,
`(domain.fullyQualifiedName:${domainFqn})`,
`(domain.fullyQualifiedName:${escapeESReservedCharacters(
domain.fullyQualifiedName
)})`,
'',
'',
SearchIndex.DATA_PRODUCT
Expand All @@ -258,7 +261,9 @@ const DomainDetailsPage = ({
'',
1,
0,
`(domain.fullyQualifiedName:${fqn})`,
`(domain.fullyQualifiedName:"${escapeESReservedCharacters(
domain.fullyQualifiedName
)}")`,
'',
'',
SearchIndex.ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import { SearchIndex } from '../../../../enums/search.enum';
import { DataProduct } from '../../../../generated/entity/domains/dataProduct';
import { searchData } from '../../../../rest/miscAPI';
import { formatDataProductResponse } from '../../../../utils/APIUtils';
import {
escapeESReservedCharacters,
getDecodedFqn,
} from '../../../../utils/StringsUtils';
import ErrorPlaceHolder from '../../../common/ErrorWithPlaceholder/ErrorPlaceHolder';
import EntitySummaryPanel from '../../../Explore/EntitySummaryPanel/EntitySummaryPanel.component';
import ExploreSearchCard from '../../../ExploreV1/ExploreSearchCard/ExploreSearchCard';
Expand Down Expand Up @@ -58,7 +62,9 @@ const DataProductsTab = forwardRef(
'',
1,
PAGE_SIZE_LARGE,
`(domain.fullyQualifiedName:${domainFqn})`,
`(domain.fullyQualifiedName:"${escapeESReservedCharacters(
getDecodedFqn(domainFqn)
)}")`,
'',
'',
SearchIndex.DATA_PRODUCT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { getCountBadge, getFeedCounts } from '../../../utils/CommonUtils';
import { getEntityVersionByField } from '../../../utils/EntityVersionUtils';
import { getQueryFilterToExcludeTerm } from '../../../utils/GlossaryUtils';
import { getGlossaryTermsVersionsPath } from '../../../utils/RouterUtils';
import { escapeESReservedCharacters } from '../../../utils/StringsUtils';
import { ActivityFeedTab } from '../../ActivityFeed/ActivityFeedTab/ActivityFeedTab.component';
import { AssetSelectionModal } from '../../Assets/AssetsSelectionModal/AssetSelectionModal';
import { CustomPropertyTable } from '../../common/CustomPropertyTable/CustomPropertyTable';
Expand Down Expand Up @@ -244,13 +245,15 @@ const GlossaryTermsV1 = ({
]);

const fetchGlossaryTermAssets = async () => {
if (glossaryFqn) {
if (glossaryTerm) {
try {
const res = await searchData(
'',
1,
0,
`(tags.tagFQN:"${glossaryFqn}")`,
`(tags.tagFQN:"${escapeESReservedCharacters(
glossaryTerm.fullyQualifiedName
)}")`,
'',
'',
SearchIndex.ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Test Glossary-term component', () => {
expect(tabs.map((tab) => tab.textContent)).toStrictEqual([
'label.overview',
'label.glossary-term-plural0',
'label.asset-plural0', // 1 added as its count for assets
'label.asset-plural1', // 1 added as its count for assets
'label.activity-feed-and-task-plural0',
'label.custom-property-plural',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ import {
} from '../../../SearchedData/SearchedData.interface';

import { FilterOutlined, PlusOutlined } from '@ant-design/icons';
import {
escapeESReservedCharacters,
getDecodedFqn,
} from '../../../../utils/StringsUtils';
import './assets-tabs.less';
import { AssetsOfEntity, AssetsTabsProps } from './AssetsTabs.interface';

Expand Down Expand Up @@ -149,10 +153,14 @@ const AssetsTabs = forwardRef(
const queryParam = useMemo(() => {
switch (type) {
case AssetsOfEntity.DOMAIN:
return `(domain.fullyQualifiedName:${fqn})`;
return `(domain.fullyQualifiedName:"${escapeESReservedCharacters(
entityFqn
)}")`;

case AssetsOfEntity.DATA_PRODUCT:
return `(dataProducts.fullyQualifiedName:${fqn})`;
return `(dataProducts.fullyQualifiedName:"${escapeESReservedCharacters(
entityFqn
)}")`;

case AssetsOfEntity.TEAM:
return `(owner.fullyQualifiedName:"${fqn}")`;
Expand All @@ -162,9 +170,9 @@ const AssetsTabs = forwardRef(
return queryFilter ?? '';

default:
return `(tags.tagFQN:"${fqn}")`;
return `(tags.tagFQN:"${escapeESReservedCharacters(entityFqn)}")`;
}
}, [type, fqn]);
}, [type, fqn, entityFqn]);

const fetchAssets = useCallback(
async ({
Expand Down Expand Up @@ -249,7 +257,7 @@ const AssetsTabs = forwardRef(

break;
case AssetsOfEntity.GLOSSARY:
data = await getGlossaryTermByFQN(fqn);
data = await getGlossaryTermByFQN(getDecodedFqn(fqn));

break;
default:
Expand Down

0 comments on commit b2a79d3

Please sign in to comment.