mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-31 04:14:34 +00:00
fix(ui): ui fixes for search dropdown suggestions API for owner and tag quick filters (#9961)
* Made changes for default options API calls for owner dropdown Fixed glossary suggestions not showing for tag quick filters * Fixed cypress tests
This commit is contained in:
parent
e2d94a66e4
commit
d9ea00b2f2
@ -11,14 +11,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { COMMON_DROPDOWN_ITEMS } from '../constants/advancedSearchQuickFilters.constants';
|
||||
import { interceptURL, verifyResponseStatusCode } from './common';
|
||||
|
||||
export const openFilterDropdown = (asset, filter) => {
|
||||
interceptURL(
|
||||
'GET',
|
||||
`http://localhost:8585/api/v1/search/aggregate?index=${asset.searchIndex}&field=${filter.key}`,
|
||||
'aggregateAPI'
|
||||
);
|
||||
let aggregateAPIURL =
|
||||
filter.key === COMMON_DROPDOWN_ITEMS[0].key
|
||||
? `/api/v1/search/aggregate?index=${filter.filterSearchIndex}&field=${filter.aggregateKey}`
|
||||
: `/api/v1/search/aggregate?index=${asset.searchIndex}&field=${filter.key}`;
|
||||
|
||||
interceptURL('GET', aggregateAPIURL, 'aggregateAPI');
|
||||
|
||||
// Click on desired dropdown
|
||||
cy.get(`[data-testid="search-dropdown-${filter.label}"]`)
|
||||
@ -37,12 +39,21 @@ export const searchAndClickOnOption = (
|
||||
checkedAfterClick
|
||||
) => {
|
||||
// Search for filter
|
||||
|
||||
interceptURL(
|
||||
'GET',
|
||||
`/api/v1/search/suggest?*q=${encodeURI(optionName)}*`,
|
||||
'suggestAPI'
|
||||
);
|
||||
|
||||
cy.get('[data-testid="search-input"]')
|
||||
.should('exist')
|
||||
.and('be.visible')
|
||||
.clear()
|
||||
.type(optionName);
|
||||
|
||||
verifyResponseStatusCode('@suggestAPI', 200);
|
||||
|
||||
cy.get(`[data-testid="${optionTestId}"]`)
|
||||
.should('exist')
|
||||
.and('be.visible')
|
||||
|
@ -17,6 +17,8 @@ export const COMMON_DROPDOWN_ITEMS = [
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'owner.displayName',
|
||||
aggregateKey: 'displayName.keyword',
|
||||
filterSearchIndex: 'user_search_index%2Cteam_search_index',
|
||||
selectOption1: 'admin',
|
||||
selectOptionTestId1: 'admin',
|
||||
selectOption2: 'Aaron Singh',
|
||||
@ -25,6 +27,7 @@ export const COMMON_DROPDOWN_ITEMS = [
|
||||
{
|
||||
label: 'Tag',
|
||||
key: 'tags.tagFQN',
|
||||
filterSearchIndex: 'tag_search_index%2Cglossary_search_index',
|
||||
selectOption1: 'PersonalData.Personal',
|
||||
selectOptionTestId1: 'PersonalData.Personal',
|
||||
selectOption2: 'PII.Sensitive',
|
||||
|
@ -54,7 +54,7 @@ QUICK_FILTERS_BY_ASSETS.map((asset) => {
|
||||
|
||||
searchAndClickOnOption(optionName1, optionTestId1, true);
|
||||
|
||||
let querySearchURL = `http://localhost:8585/api/v1/search/query?*index=${
|
||||
let querySearchURL = `/api/v1/search/query?*index=${
|
||||
asset.searchIndex
|
||||
}*query_filter=*should*${filter.key}*${encodeURI(optionName1)}*`;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import { Divider, Space } from 'antd';
|
||||
import { AxiosError } from 'axios';
|
||||
import { SearchIndex } from 'enums/search.enum';
|
||||
import { isEqual, isUndefined, uniqWith } from 'lodash';
|
||||
import React, { FC, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -22,7 +23,10 @@ import {
|
||||
getTagSuggestions,
|
||||
getUserSuggestions,
|
||||
} from 'rest/miscAPI';
|
||||
import { MISC_FIELDS } from '../../constants/AdvancedSearch.constants';
|
||||
import {
|
||||
MISC_FIELDS,
|
||||
OWNER_QUICK_FILTER_DEFAULT_OPTIONS_KEY,
|
||||
} from '../../constants/AdvancedSearch.constants';
|
||||
import {
|
||||
getAdvancedField,
|
||||
getOptionsObject,
|
||||
@ -43,19 +47,34 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
|
||||
const [options, setOptions] = useState<SearchDropdownOption[]>();
|
||||
const [isOptionsLoading, setIsOptionsLoading] = useState<boolean>(false);
|
||||
|
||||
const fetchDefaultOptions = async (
|
||||
index: SearchIndex | SearchIndex[],
|
||||
key: string
|
||||
) => {
|
||||
const res = await getAdvancedFieldDefaultOptions(index, key);
|
||||
|
||||
const buckets = res.data.aggregations[`sterms#${key}`].buckets;
|
||||
|
||||
const optionsArray = buckets.map((option) => ({
|
||||
key: option.key,
|
||||
label: option.key,
|
||||
}));
|
||||
|
||||
setOptions(uniqWith(optionsArray, isEqual));
|
||||
};
|
||||
|
||||
const getInitialOptions = async (key: string) => {
|
||||
setIsOptionsLoading(true);
|
||||
setOptions([]);
|
||||
try {
|
||||
const res = await getAdvancedFieldDefaultOptions(index, key);
|
||||
const buckets = res.data.aggregations[`sterms#${key}`].buckets;
|
||||
|
||||
const optionsArray = buckets.map((option) => ({
|
||||
key: option.key,
|
||||
label: option.label ?? option.key,
|
||||
}));
|
||||
|
||||
setOptions(uniqWith(optionsArray, isEqual));
|
||||
if (key === MISC_FIELDS[0]) {
|
||||
await fetchDefaultOptions(
|
||||
[SearchIndex.USER, SearchIndex.TEAM],
|
||||
OWNER_QUICK_FILTER_DEFAULT_OPTIONS_KEY
|
||||
);
|
||||
} else {
|
||||
await fetchDefaultOptions(index, key);
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorToast(error as AxiosError);
|
||||
} finally {
|
||||
|
@ -457,3 +457,5 @@ export const getQbConfigs: (searchIndex: SearchIndex) => BasicConfig = (
|
||||
};
|
||||
|
||||
export const MISC_FIELDS = ['owner.displayName', 'tags.tagFQN'];
|
||||
|
||||
export const OWNER_QUICK_FILTER_DEFAULT_OPTIONS_KEY = 'displayName.keyword';
|
||||
|
@ -183,7 +183,7 @@ export const getTeamsByQuery = async (params: {
|
||||
export const getTagSuggestions = (term: string) => {
|
||||
const params = {
|
||||
q: term,
|
||||
index: `${SearchIndex.TAG},${SearchIndex.TAG}`,
|
||||
index: `${SearchIndex.TAG},${SearchIndex.GLOSSARY}`,
|
||||
};
|
||||
|
||||
return APIClient.get<RawSuggestResponse<SearchIndex.TAG>>(`/search/suggest`, {
|
||||
@ -249,7 +249,7 @@ export const getAdvancedFieldOptions = (
|
||||
};
|
||||
|
||||
export const getAdvancedFieldDefaultOptions = (
|
||||
index: SearchIndex,
|
||||
index: SearchIndex | SearchIndex[],
|
||||
field: string
|
||||
) => {
|
||||
const params = { index, field };
|
||||
|
Loading…
x
Reference in New Issue
Block a user