mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 20:06:19 +00:00
Sort by display name in owner and mentions list (#14734)
* sort by display name in owner and mentions list * maintain sort order * fix cypress --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
parent
325267d7e0
commit
fd7a3f19ef
@ -15,7 +15,7 @@ import { interceptURL, verifyResponseStatusCode } from '../common';
|
|||||||
const userURL =
|
const userURL =
|
||||||
'/api/v1/search/query?q=**%20AND%20isBot:false&from=0&size=0&index=user_search_index';
|
'/api/v1/search/query?q=**%20AND%20isBot:false&from=0&size=0&index=user_search_index';
|
||||||
const teamURL =
|
const teamURL =
|
||||||
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=10&index=team_search_index';
|
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=10&index=team_search_index&sort_field=displayName.keyword&sort_order=asc';
|
||||||
|
|
||||||
export const validateOwnerAndTeamCounts = () => {
|
export const validateOwnerAndTeamCounts = () => {
|
||||||
cy.getAllLocalStorage().then((data) => {
|
cy.getAllLocalStorage().then((data) => {
|
||||||
@ -122,7 +122,7 @@ export const removeOwner = (ownerName: string) => {
|
|||||||
export const addTeamAsOwner = (teamName: string) => {
|
export const addTeamAsOwner = (teamName: string) => {
|
||||||
interceptURL(
|
interceptURL(
|
||||||
'GET',
|
'GET',
|
||||||
'/api/v1/search/query?q=*&from=0&size=*&index=team_search_index',
|
'/api/v1/search/query?q=*&from=0&size=*&index=team_search_index&sort_field=displayName.keyword&sort_order=asc',
|
||||||
'getTeams'
|
'getTeams'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ describe('Services page should work properly', () => {
|
|||||||
verifyResponseStatusCode('@pipelineServiceClient', 200);
|
verifyResponseStatusCode('@pipelineServiceClient', 200);
|
||||||
interceptURL(
|
interceptURL(
|
||||||
'GET',
|
'GET',
|
||||||
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=*&index=team_search_index',
|
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=*&index=team_search_index&sort_field=displayName.keyword&sort_order=asc',
|
||||||
'editOwner'
|
'editOwner'
|
||||||
);
|
);
|
||||||
cy.get('[data-testid="edit-owner"]')
|
cy.get('[data-testid="edit-owner"]')
|
||||||
|
@ -20,6 +20,7 @@ export interface MentionSuggestionsItem {
|
|||||||
type?: string;
|
type?: string;
|
||||||
avatarEle?: HTMLDivElement;
|
avatarEle?: HTMLDivElement;
|
||||||
breadcrumbs: Array<{ name: string }>;
|
breadcrumbs: Array<{ name: string }>;
|
||||||
|
displayName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FeedEditorProp extends HTMLAttributes<HTMLDivElement> {
|
export interface FeedEditorProp extends HTMLAttributes<HTMLDivElement> {
|
||||||
|
@ -87,30 +87,30 @@ export const FeedEditor = forwardRef<editorRef, FeedEditorProp>(
|
|||||||
const newMatches: MentionSuggestionsItem[] = [];
|
const newMatches: MentionSuggestionsItem[] = [];
|
||||||
try {
|
try {
|
||||||
// Fetch profile images in case of user listing
|
// Fetch profile images in case of user listing
|
||||||
const promises = matches.map(async (item) => {
|
const promises = matches.map(async (item, index) => {
|
||||||
if (item.type === 'user') {
|
if (item.type === 'user') {
|
||||||
return getUserByName(item.name, { fields: 'profile' }).then(
|
return getUserByName(item.name, { fields: 'profile' }).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
updateUserProfilePics({ id: item.name, user: res });
|
updateUserProfilePics({ id: item.name, user: res });
|
||||||
|
|
||||||
newMatches.push({
|
newMatches[index] = {
|
||||||
...item,
|
...item,
|
||||||
avatarEle: userMentionItemWithAvatar(
|
avatarEle: userMentionItemWithAvatar(
|
||||||
item,
|
item,
|
||||||
userProfilePics[item.name] ?? res
|
userProfilePics[item.name] ?? res
|
||||||
),
|
),
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (item.type === 'team') {
|
} else if (item.type === 'team') {
|
||||||
newMatches.push({
|
newMatches[index] = {
|
||||||
...item,
|
...item,
|
||||||
avatarEle: userMentionItemWithAvatar(item),
|
avatarEle: userMentionItemWithAvatar(item),
|
||||||
});
|
};
|
||||||
} else {
|
} else {
|
||||||
newMatches.push({
|
newMatches[index] = {
|
||||||
...item,
|
...item,
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -105,64 +105,33 @@ export const UserTeamSelectableList = ({
|
|||||||
const fetchTeamOptions = async (searchText: string, after?: string) => {
|
const fetchTeamOptions = async (searchText: string, after?: string) => {
|
||||||
const afterPage = isNaN(Number(after)) ? 1 : Number(after);
|
const afterPage = isNaN(Number(after)) ? 1 : Number(after);
|
||||||
|
|
||||||
if (searchText) {
|
try {
|
||||||
try {
|
const res = await searchData(
|
||||||
const res = await searchData(
|
searchText || '',
|
||||||
searchText,
|
afterPage,
|
||||||
afterPage,
|
PAGE_SIZE_MEDIUM,
|
||||||
PAGE_SIZE_MEDIUM,
|
'teamType:Group',
|
||||||
'teamType:Group',
|
'displayName.keyword',
|
||||||
'',
|
'asc',
|
||||||
'',
|
SearchIndex.TEAM
|
||||||
SearchIndex.TEAM
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const data = getEntityReferenceListFromEntities(
|
const data = getEntityReferenceListFromEntities(
|
||||||
formatTeamsResponse(res.data.hits.hits),
|
formatTeamsResponse(res.data.hits.hits),
|
||||||
EntityType.TEAM
|
EntityType.TEAM
|
||||||
);
|
);
|
||||||
|
|
||||||
setCount((pre) => ({ ...pre, team: res.data.hits.total.value }));
|
setCount((pre) => ({ ...pre, team: res.data.hits.total.value }));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
paging: {
|
paging: {
|
||||||
total: res.data.hits.total.value,
|
total: res.data.hits.total.value,
|
||||||
after: toString(afterPage + 1),
|
after: toString(afterPage + 1),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { data: [], paging: { total: 0 } };
|
return { data: [], paging: { total: 0 } };
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const { data } = await searchData(
|
|
||||||
'',
|
|
||||||
afterPage,
|
|
||||||
PAGE_SIZE_MEDIUM,
|
|
||||||
'teamType:Group',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
SearchIndex.TEAM
|
|
||||||
);
|
|
||||||
|
|
||||||
const filterData = getEntityReferenceListFromEntities(
|
|
||||||
formatTeamsResponse(data.hits.hits),
|
|
||||||
EntityType.TEAM
|
|
||||||
);
|
|
||||||
|
|
||||||
setCount((pre) => ({ ...pre, team: data.hits.total.value }));
|
|
||||||
|
|
||||||
return {
|
|
||||||
data: filterData,
|
|
||||||
paging: {
|
|
||||||
total: data.hits.total.value,
|
|
||||||
after: toString(afterPage + 1),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
return { data: [], paging: { total: 0 } };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,7 +69,11 @@ import {
|
|||||||
import { getRelativeCalendar } from './date-time/DateTimeUtils';
|
import { getRelativeCalendar } from './date-time/DateTimeUtils';
|
||||||
import EntityLink from './EntityLink';
|
import EntityLink from './EntityLink';
|
||||||
import entityUtilClassBase from './EntityUtilClassBase';
|
import entityUtilClassBase from './EntityUtilClassBase';
|
||||||
import { ENTITY_LINK_SEPARATOR, getEntityBreadcrumbs } from './EntityUtils';
|
import {
|
||||||
|
ENTITY_LINK_SEPARATOR,
|
||||||
|
getEntityBreadcrumbs,
|
||||||
|
getEntityName,
|
||||||
|
} from './EntityUtils';
|
||||||
import Fqn from './Fqn';
|
import Fqn from './Fqn';
|
||||||
import {
|
import {
|
||||||
getImageWithResolutionAndFallback,
|
getImageWithResolutionAndFallback,
|
||||||
@ -209,6 +213,7 @@ export async function suggestions(
|
|||||||
type:
|
type:
|
||||||
hit._index === SearchIndex.USER ? UserTeam.User : UserTeam.Team,
|
hit._index === SearchIndex.USER ? UserTeam.User : UserTeam.Team,
|
||||||
name: hit._source.name,
|
name: hit._source.name,
|
||||||
|
displayName: hit._source.displayName,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -221,7 +226,7 @@ export async function suggestions(
|
|||||||
hits.map(async (hit: any) => {
|
hits.map(async (hit: any) => {
|
||||||
const entityType = hit._source.entityType;
|
const entityType = hit._source.entityType;
|
||||||
const name = getEntityPlaceHolder(
|
const name = getEntityPlaceHolder(
|
||||||
`@${hit._source.name ?? hit._source.display_name}`,
|
`@${hit._source.name ?? hit._source.displayName}`,
|
||||||
hit._source.deleted
|
hit._source.deleted
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -235,6 +240,7 @@ export async function suggestions(
|
|||||||
type:
|
type:
|
||||||
hit._index === SearchIndex.USER ? UserTeam.User : UserTeam.Team,
|
hit._index === SearchIndex.USER ? UserTeam.User : UserTeam.Team,
|
||||||
name: hit._source.name,
|
name: hit._source.name,
|
||||||
|
displayName: hit._source.displayName,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -335,7 +341,9 @@ export const userMentionItemWithAvatar = (
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="d-flex items-center truncate w-56">{item.name}</span>
|
<span className="d-flex items-center truncate w-56">
|
||||||
|
{getEntityName(item)}
|
||||||
|
</span>
|
||||||
</div>,
|
</div>,
|
||||||
wrapper
|
wrapper
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user