mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 20:06:19 +00:00
Fix(Ui): Fixed the teams search irrelevant suggestions issue (#6516)
* Fixed the issue where teams suggestions when searched were not showing relevant results * Fixed isJoinable param issue
This commit is contained in:
parent
6e8da06b12
commit
13eabfe2db
@ -148,10 +148,16 @@ export const getTeamsByQuery = async (params: {
|
||||
q: string;
|
||||
from?: number;
|
||||
size?: number;
|
||||
isJoinable?: boolean;
|
||||
}) => {
|
||||
const response = await APIClient.get(`/search/query`, {
|
||||
params: { index: SearchIndex.TEAM, ...params },
|
||||
params: {
|
||||
index: SearchIndex.TEAM,
|
||||
...params,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
sort_field: 'name.keyword',
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
sort_order: 'asc',
|
||||
},
|
||||
});
|
||||
|
||||
return response.data;
|
||||
|
@ -14,10 +14,9 @@
|
||||
import { SelectableOption } from 'Models';
|
||||
import React, { useState } from 'react';
|
||||
import AsyncSelect from 'react-select/async';
|
||||
import { getSuggestedTeams, getTeamsByQuery } from '../../axiosAPIs/miscAPI';
|
||||
import { getTeamsByQuery } from '../../axiosAPIs/miscAPI';
|
||||
import { Team } from '../../generated/entity/teams/team';
|
||||
import { EntityReference } from '../../generated/type/entityReference';
|
||||
import { formatTeamsResponse } from '../../utils/APIUtils';
|
||||
import { getEntityName } from '../../utils/CommonUtils';
|
||||
import SVGIcons from '../../utils/SvgUtils';
|
||||
import { reactSingleSelectCustomStyle } from '../common/react-select-component/reactSelectCustomStyle';
|
||||
@ -49,11 +48,7 @@ const TeamsSelectable = ({
|
||||
};
|
||||
|
||||
const getOptions = (teams: Team[]) => {
|
||||
const filteredTeams = filterJoinable
|
||||
? teams.filter((team) => team.isJoinable)
|
||||
: teams;
|
||||
|
||||
return filteredTeams.map((team) => ({
|
||||
return teams.map((team) => ({
|
||||
label: getEntityName(team as EntityReference),
|
||||
value: team.id,
|
||||
}));
|
||||
@ -61,26 +56,19 @@ const TeamsSelectable = ({
|
||||
|
||||
const loadOptions = (text: string) => {
|
||||
return new Promise<SelectableOption[]>((resolve) => {
|
||||
if (text) {
|
||||
getSuggestedTeams(text).then((res) => {
|
||||
const teams: Team[] = formatTeamsResponse(
|
||||
res.data.suggest['metadata-suggest'][0].options
|
||||
);
|
||||
resolve(getOptions(teams));
|
||||
});
|
||||
} else {
|
||||
getTeamsByQuery({
|
||||
q: '*',
|
||||
from: 0,
|
||||
size: TEAM_OPTION_PAGE_LIMIT,
|
||||
isJoinable: filterJoinable,
|
||||
}).then((res) => {
|
||||
const teams: Team[] =
|
||||
res.hits.hits.map((t: { _source: Team }) => t._source) || [];
|
||||
showTeamsAlert && setNoTeam(teams.length === 0);
|
||||
resolve(getOptions(teams));
|
||||
});
|
||||
}
|
||||
const trimmedText = text.trim();
|
||||
getTeamsByQuery({
|
||||
q:
|
||||
(trimmedText ? `*${trimmedText}*` : '*') +
|
||||
(filterJoinable ? ` AND isJoinable:true` : ''),
|
||||
from: 0,
|
||||
size: TEAM_OPTION_PAGE_LIMIT,
|
||||
}).then((res) => {
|
||||
const teams: Team[] =
|
||||
res.hits.hits.map((t: { _source: Team }) => t._source) || [];
|
||||
showTeamsAlert && setNoTeam(teams.length === 0);
|
||||
resolve(getOptions(teams));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user