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" #import "../fragments/user.fragment.graphql"
query usersSearch($search: String!) { query usersSearch($search: String!, $fullPath: ID!) {
users(search: $search) { issuable: project(fullPath: $fullPath) {
users: projectMembers(search: $search) {
nodes { nodes {
user {
...User ...User
} }
} }
}
}
} }
...@@ -104,11 +104,22 @@ export default { ...@@ -104,11 +104,22 @@ export default {
query: searchUsers, query: searchUsers,
variables() { variables() {
return { return {
fullPath: this.fullPath,
search: this.search, search: this.search,
}; };
}, },
update(data) { 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, debounce: 250,
skip() { skip() {
...@@ -185,7 +196,7 @@ export default { ...@@ -185,7 +196,7 @@ export default {
return this.selected.some(isCurrentUser) || this.participants.some(isCurrentUser); return this.selected.some(isCurrentUser) || this.participants.some(isCurrentUser);
}, },
noUsersFound() { noUsersFound() {
return !this.isSearchEmpty && this.unselectedFiltered.length === 0; return !this.isSearchEmpty && this.searchUsers.length === 0;
}, },
showCurrentUser() { showCurrentUser() {
return !this.isCurrentUserInParticipants && (this.isSearchEmpty || this.isSearching); return !this.isCurrentUserInParticipants && (this.isSearchEmpty || this.isSearching);
......
---
title: Fix assignees search to show only project members
merge_request: 55396
author:
type: fixed
...@@ -130,25 +130,31 @@ export const issuableQueryResponse = { ...@@ -130,25 +130,31 @@ export const issuableQueryResponse = {
export const searchQueryResponse = { export const searchQueryResponse = {
data: { data: {
issuable: {
users: { users: {
nodes: [ nodes: [
{ {
user: {
id: '1', id: '1',
avatarUrl: '/avatar', avatarUrl: '/avatar',
name: 'root', name: 'root',
username: 'root', username: 'root',
webUrl: 'root', webUrl: 'root',
}, },
},
{ {
user: {
id: '3', id: '3',
avatarUrl: '/avatar', avatarUrl: '/avatar',
name: 'rookie', name: 'rookie',
username: 'rookie', username: 'rookie',
webUrl: 'rookie', webUrl: 'rookie',
}, },
},
], ],
}, },
}, },
},
}; };
export const updateIssueAssigneesMutationResponse = { export const updateIssueAssigneesMutationResponse = {
......
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