Commit fda71786 authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Nicolò Maria Mezzopera

Fix assignees search to show only project members

parent 440396b3
query usersSearch($search: String!) {
users(search: $search) {
nodes {
username
name
webUrl
avatarUrl
id
}
}
}
#import "../fragments/user.fragment.graphql"
query usersSearch($search: String!) {
users(search: $search) {
nodes {
...User
query usersSearch($search: String!, $fullPath: ID!) {
issuable: project(fullPath: $fullPath) {
users: projectMembers(search: $search) {
nodes {
user {
...User
}
}
}
}
}
......@@ -104,11 +104,22 @@ export default {
query: searchUsers,
variables() {
return {
fullPath: this.fullPath,
search: this.search,
};
},
update(data) {
return data.users?.nodes || [];
const searchResults = data.issuable?.users?.nodes.map(({ user }) => user) || [];
const mergedSearchResults = this.participants.reduce((acc, current) => {
if (
!acc.some((user) => current.username === user.username) &&
(current.name.includes(this.search) || current.username.includes(this.search))
) {
acc.push(current);
}
return acc;
}, searchResults);
return mergedSearchResults;
},
debounce: 250,
skip() {
......@@ -185,7 +196,7 @@ export default {
return this.selected.some(isCurrentUser) || this.participants.some(isCurrentUser);
},
noUsersFound() {
return !this.isSearchEmpty && this.unselectedFiltered.length === 0;
return !this.isSearchEmpty && this.searchUsers.length === 0;
},
showCurrentUser() {
return !this.isCurrentUserInParticipants && (this.isSearchEmpty || this.isSearching);
......
---
title: Fix assignees search to show only project members
merge_request: 55396
author:
type: fixed
......@@ -130,23 +130,29 @@ export const issuableQueryResponse = {
export const searchQueryResponse = {
data: {
users: {
nodes: [
{
id: '1',
avatarUrl: '/avatar',
name: 'root',
username: 'root',
webUrl: 'root',
},
{
id: '3',
avatarUrl: '/avatar',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
},
],
issuable: {
users: {
nodes: [
{
user: {
id: '1',
avatarUrl: '/avatar',
name: 'root',
username: 'root',
webUrl: 'root',
},
},
{
user: {
id: '3',
avatarUrl: '/avatar',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
},
},
],
},
},
},
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment