mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-26 09:55:52 +00:00
MINOR: fix organization data show in teams data after search (#18427)
* fix organization data show in teams data after search * remove unsued code
This commit is contained in:
parent
ed9b66c5c5
commit
5b49db2c07
@ -16,20 +16,20 @@ import { EntityTypeEndpoint } from '../../support/entity/Entity.interface';
|
|||||||
import { TeamClass } from '../../support/team/TeamClass';
|
import { TeamClass } from '../../support/team/TeamClass';
|
||||||
import { UserClass } from '../../support/user/UserClass';
|
import { UserClass } from '../../support/user/UserClass';
|
||||||
import {
|
import {
|
||||||
createNewPage,
|
createNewPage,
|
||||||
descriptionBox,
|
descriptionBox,
|
||||||
getApiContext,
|
getApiContext,
|
||||||
redirectToHomePage,
|
redirectToHomePage,
|
||||||
toastNotification,
|
toastNotification,
|
||||||
uuid,
|
uuid
|
||||||
} from '../../utils/common';
|
} from '../../utils/common';
|
||||||
import { addMultiOwner } from '../../utils/entity';
|
import { addMultiOwner } from '../../utils/entity';
|
||||||
import { settingClick } from '../../utils/sidebar';
|
import { settingClick } from '../../utils/sidebar';
|
||||||
import {
|
import {
|
||||||
createTeam,
|
createTeam,
|
||||||
hardDeleteTeam,
|
hardDeleteTeam,
|
||||||
searchTeam,
|
searchTeam,
|
||||||
softDeleteTeam,
|
softDeleteTeam
|
||||||
} from '../../utils/team';
|
} from '../../utils/team';
|
||||||
|
|
||||||
// use the admin user to login
|
// use the admin user to login
|
||||||
@ -440,6 +440,9 @@ test.describe('Teams Page', () => {
|
|||||||
for (const team of [team1, team2, team3]) {
|
for (const team of [team1, team2, team3]) {
|
||||||
await searchTeam(page, team.responseData?.['displayName']);
|
await searchTeam(page, team.responseData?.['displayName']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should not find the organization team and show errorPlaceholder
|
||||||
|
await searchTeam(page, 'Organization', true);
|
||||||
} finally {
|
} finally {
|
||||||
await team1.delete(apiContext);
|
await team1.delete(apiContext);
|
||||||
await team2.delete(apiContext);
|
await team2.delete(apiContext);
|
||||||
|
@ -251,11 +251,19 @@ export const removeOrganizationPolicyAndRole = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const searchTeam = async (page: Page, teamName: string) => {
|
export const searchTeam = async (
|
||||||
|
page: Page,
|
||||||
|
teamName: string,
|
||||||
|
searchWillBeEmpty?: boolean
|
||||||
|
) => {
|
||||||
const searchResponse = page.waitForResponse('/api/v1/search/query?q=**');
|
const searchResponse = page.waitForResponse('/api/v1/search/query?q=**');
|
||||||
|
|
||||||
await page.fill('[data-testid="searchbar"]', teamName);
|
await page.fill('[data-testid="searchbar"]', teamName);
|
||||||
await searchResponse;
|
await searchResponse;
|
||||||
|
|
||||||
await expect(page.locator('table')).toContainText(teamName);
|
if (searchWillBeEmpty) {
|
||||||
|
await expect(page.getByTestId('search-error-placeholder')).toBeVisible();
|
||||||
|
} else {
|
||||||
|
await expect(page.locator('table')).toContainText(teamName);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ import { ReactComponent as ImportIcon } from '../../../../assets/svg/ic-import.s
|
|||||||
import { ReactComponent as IconRestore } from '../../../../assets/svg/ic-restore.svg';
|
import { ReactComponent as IconRestore } from '../../../../assets/svg/ic-restore.svg';
|
||||||
import { ReactComponent as IconOpenLock } from '../../../../assets/svg/open-lock.svg';
|
import { ReactComponent as IconOpenLock } from '../../../../assets/svg/open-lock.svg';
|
||||||
import { ReactComponent as IconTeams } from '../../../../assets/svg/teams.svg';
|
import { ReactComponent as IconTeams } from '../../../../assets/svg/teams.svg';
|
||||||
import { ROUTES } from '../../../../constants/constants';
|
import { PAGE_SIZE, ROUTES } from '../../../../constants/constants';
|
||||||
import {
|
import {
|
||||||
GLOSSARIES_DOCS,
|
GLOSSARIES_DOCS,
|
||||||
ROLE_DOCS,
|
ROLE_DOCS,
|
||||||
@ -55,6 +55,7 @@ import { usePermissionProvider } from '../../../../context/PermissionProvider/Pe
|
|||||||
import { ResourceEntity } from '../../../../context/PermissionProvider/PermissionProvider.interface';
|
import { ResourceEntity } from '../../../../context/PermissionProvider/PermissionProvider.interface';
|
||||||
import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum';
|
import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum';
|
||||||
import { EntityAction, EntityType } from '../../../../enums/entity.enum';
|
import { EntityAction, EntityType } from '../../../../enums/entity.enum';
|
||||||
|
import { SearchIndex } from '../../../../enums/search.enum';
|
||||||
import { OwnerType } from '../../../../enums/user.enum';
|
import { OwnerType } from '../../../../enums/user.enum';
|
||||||
import { Operation } from '../../../../generated/entity/policies/policy';
|
import { Operation } from '../../../../generated/entity/policies/policy';
|
||||||
import { Team, TeamType } from '../../../../generated/entity/teams/team';
|
import { Team, TeamType } from '../../../../generated/entity/teams/team';
|
||||||
@ -68,7 +69,7 @@ import { useApplicationStore } from '../../../../hooks/useApplicationStore';
|
|||||||
import useCustomLocation from '../../../../hooks/useCustomLocation/useCustomLocation';
|
import useCustomLocation from '../../../../hooks/useCustomLocation/useCustomLocation';
|
||||||
import AddAttributeModal from '../../../../pages/RolesPage/AddAttributeModal/AddAttributeModal';
|
import AddAttributeModal from '../../../../pages/RolesPage/AddAttributeModal/AddAttributeModal';
|
||||||
import { ImportType } from '../../../../pages/TeamsPage/ImportTeamsPage/ImportTeamsPage.interface';
|
import { ImportType } from '../../../../pages/TeamsPage/ImportTeamsPage/ImportTeamsPage.interface';
|
||||||
import { getSearchedTeams } from '../../../../rest/miscAPI';
|
import { searchQuery } from '../../../../rest/searchAPI';
|
||||||
import { exportTeam, restoreTeam } from '../../../../rest/teamsAPI';
|
import { exportTeam, restoreTeam } from '../../../../rest/teamsAPI';
|
||||||
import { Transi18next } from '../../../../utils/CommonUtils';
|
import { Transi18next } from '../../../../utils/CommonUtils';
|
||||||
import { getEntityName } from '../../../../utils/EntityUtils';
|
import { getEntityName } from '../../../../utils/EntityUtils';
|
||||||
@ -267,10 +268,38 @@ const TeamDetailsV1 = ({
|
|||||||
|
|
||||||
const searchTeams = async (text: string) => {
|
const searchTeams = async (text: string) => {
|
||||||
try {
|
try {
|
||||||
const res = await getSearchedTeams(text, 1, '');
|
const res = await searchQuery({
|
||||||
const data = res.data.hits.hits.map((value) => value._source as Team);
|
query: `*${text}*`,
|
||||||
|
pageNumber: 1,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
queryFilter: {
|
||||||
|
query: {
|
||||||
|
bool: {
|
||||||
|
must_not: [
|
||||||
|
{
|
||||||
|
term: {
|
||||||
|
'name.keyword': 'Organization',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
searchIndex: SearchIndex.TEAM,
|
||||||
|
});
|
||||||
|
|
||||||
setChildTeamList(data);
|
const data = res.hits.hits.map((value) => value._source as Team);
|
||||||
|
|
||||||
|
setChildTeamList(
|
||||||
|
data.map((team) => {
|
||||||
|
return {
|
||||||
|
...team,
|
||||||
|
// search data will contain children empty array, so we need to remove it
|
||||||
|
// to avoid expand handler to show in ui
|
||||||
|
children: isEmpty(team.children) ? undefined : team.children,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setChildTeamList([]);
|
setChildTeamList([]);
|
||||||
}
|
}
|
||||||
|
@ -132,31 +132,6 @@ export const getTeamsByQuery = async (params: {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchedUsers = (
|
|
||||||
queryString: string,
|
|
||||||
from: number,
|
|
||||||
size = 10
|
|
||||||
) => {
|
|
||||||
return searchData(queryString, from, size, '', '', '', SearchIndex.USER);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSearchedTeams = (
|
|
||||||
queryString: string,
|
|
||||||
from: number,
|
|
||||||
filter?: string,
|
|
||||||
size = 10
|
|
||||||
) => {
|
|
||||||
return searchData(
|
|
||||||
queryString,
|
|
||||||
from,
|
|
||||||
size,
|
|
||||||
filter ?? '',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
SearchIndex.TEAM
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getUserAndTeamSearch = (
|
export const getUserAndTeamSearch = (
|
||||||
term: string,
|
term: string,
|
||||||
userOnly = false,
|
userOnly = false,
|
||||||
|
@ -15,14 +15,8 @@ import { AxiosError } from 'axios';
|
|||||||
import { compare } from 'fast-json-patch';
|
import { compare } from 'fast-json-patch';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { OidcUser } from '../components/Auth/AuthProviders/AuthProvider.interface';
|
import { OidcUser } from '../components/Auth/AuthProviders/AuthProvider.interface';
|
||||||
import { WILD_CARD_CHAR } from '../constants/char.constants';
|
|
||||||
import { SettledStatus } from '../enums/Axios.enum';
|
|
||||||
import { SearchIndex } from '../enums/search.enum';
|
|
||||||
import { SearchResponse } from '../interface/search.interface';
|
|
||||||
import { getSearchedTeams, getSearchedUsers } from '../rest/miscAPI';
|
|
||||||
import { updateUserDetail } from '../rest/userAPI';
|
import { updateUserDetail } from '../rest/userAPI';
|
||||||
import { User } from './../generated/entity/teams/user';
|
import { User } from './../generated/entity/teams/user';
|
||||||
import { formatTeamsResponse, formatUsersResponse } from './APIUtils';
|
|
||||||
import { getImages } from './CommonUtils';
|
import { getImages } from './CommonUtils';
|
||||||
import i18n from './i18next/LocalUtil';
|
import i18n from './i18next/LocalUtil';
|
||||||
import {
|
import {
|
||||||
@ -70,45 +64,6 @@ export const matchUserDetails = (
|
|||||||
return isMatch;
|
return isMatch;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const searchFormattedUsersAndTeams = async (
|
|
||||||
searchQuery = WILD_CARD_CHAR,
|
|
||||||
from = 1
|
|
||||||
) => {
|
|
||||||
try {
|
|
||||||
const promises = [
|
|
||||||
getSearchedUsers(searchQuery, from),
|
|
||||||
getSearchedTeams(searchQuery, from, 'teamType:Group'),
|
|
||||||
];
|
|
||||||
|
|
||||||
const [resUsers, resTeams] = await Promise.allSettled(promises);
|
|
||||||
|
|
||||||
const users =
|
|
||||||
resUsers.status === SettledStatus.FULFILLED
|
|
||||||
? formatUsersResponse(
|
|
||||||
(resUsers.value.data as SearchResponse<SearchIndex.USER>).hits.hits
|
|
||||||
)
|
|
||||||
: [];
|
|
||||||
const teams =
|
|
||||||
resTeams.status === SettledStatus.FULFILLED
|
|
||||||
? formatTeamsResponse(
|
|
||||||
(resTeams.value.data as SearchResponse<SearchIndex.TEAM>).hits.hits
|
|
||||||
)
|
|
||||||
: [];
|
|
||||||
const usersTotal =
|
|
||||||
resUsers.status === SettledStatus.FULFILLED
|
|
||||||
? resUsers.value.data.hits.total.value
|
|
||||||
: 0;
|
|
||||||
const teamsTotal =
|
|
||||||
resTeams.status === SettledStatus.FULFILLED
|
|
||||||
? resTeams.value.data.hits.total.value
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
return { users, teams, usersTotal, teamsTotal };
|
|
||||||
} catch (error) {
|
|
||||||
return { users: [], teams: [], usersTotal: 0, teamsTotal: 0 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getUserWithImage = (user: User) => {
|
export const getUserWithImage = (user: User) => {
|
||||||
const profile =
|
const profile =
|
||||||
getImageWithResolutionAndFallback(
|
getImageWithResolutionAndFallback(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user