Commit 62391b52 authored by Eulyeon Ko's avatar Eulyeon Ko

Remove duplicate users and filter out nulls

Two temporary FE workarounds are added for these issues:
https://gitlab.com/gitlab-org/gitlab/-/issues/329750
https://gitlab.com/gitlab-org/gitlab/-/issues/327822
parent 4d9aabd2
......@@ -88,6 +88,7 @@ export default {
},
},
searchUsers: {
errorPolicy: 'all',
query: searchUsers,
variables() {
return {
......@@ -97,10 +98,32 @@ export default {
};
},
update(data) {
return data.workspace?.users?.nodes.map(({ user }) => user) || [];
if (!data.workspace?.users?.nodes) return [];
// TODO this de-duplication is temporary (BE fix required)
// Also remove the error policy and related test (mockdata)
// https://gitlab.com/gitlab-org/gitlab/-/issues/327822
const users = data.workspace?.users?.nodes.filter((x) => x).map(({ user }) => user);
return users.reduce((acc, cur) => {
return acc.find((u) => u.id === cur.id) ? acc : [...acc, cur];
}, []);
},
debounce: ASSIGNEES_DEBOUNCE_DELAY,
error() {
error({ graphQLErrors }) {
// TODO This error suppression is temporary (BE fix required)
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750
if (
graphQLErrors.length === 1 &&
graphQLErrors[0]?.message === 'Cannot return null for non-nullable field GroupMember.user'
) {
// eslint-disable-next-line no-console
console.error(
"Suppressing the error 'Cannot return null for non-nullable field GroupMember.user'. Please see https://gitlab.com/gitlab-org/gitlab/-/issues/329750",
);
this.isSearching = false;
return;
}
this.$emit('error');
this.isSearching = false;
},
......
......@@ -404,6 +404,21 @@ export const projectMembersResponse = {
__typename: 'Project',
users: {
nodes: [
// Remove nulls https://gitlab.com/gitlab-org/gitlab/-/issues/329750
null,
null,
{
user: {
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
status: null,
},
},
// This is a duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822
{
user: {
id: 'gid://gitlab/User/1',
......@@ -454,6 +469,16 @@ export const participantsQueryResponse = {
iid: '1',
participants: {
nodes: [
{
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
status: null,
},
// this is a duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822
{
id: 'gid://gitlab/User/1',
avatarUrl:
......
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