Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5ceabb04
Commit
5ceabb04
authored
May 04, 2021
by
Eulyeon Ko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviewer suggestions
- Gather the de-duplication logic together - DRY mock user data
parent
62391b52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
86 deletions
+47
-86
app/assets/javascripts/vue_shared/components/user_select/user_select.vue
...scripts/vue_shared/components/user_select/user_select.vue
+19
-18
spec/frontend/sidebar/mock_data.js
spec/frontend/sidebar/mock_data.js
+28
-68
No files found.
app/assets/javascripts/vue_shared/components/user_select/user_select.vue
View file @
5ceabb04
...
...
@@ -88,6 +88,8 @@ export default {
},
},
searchUsers
:
{
// TODO Remove error policy
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750
errorPolicy
:
'
all
'
,
query
:
searchUsers
,
variables
()
{
...
...
@@ -98,15 +100,9 @@ export default {
};
},
update
(
data
)
{
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
];
},
[]);
// TODO Remove null filter (BE fix required)
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750
return
data
.
workspace
?.
users
?.
nodes
.
filter
((
x
)
=>
x
).
map
(({
user
})
=>
user
)
||
[];
},
debounce
:
ASSIGNEES_DEBOUNCE_DELAY
,
error
({
graphQLErrors
})
{
...
...
@@ -140,15 +136,20 @@ export default {
if
(
!
this
.
participants
)
{
return
[];
}
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
;
},
this
.
searchUsers
);
const
filteredParticipants
=
this
.
participants
.
filter
(
(
user
)
=>
user
.
name
.
includes
(
this
.
search
)
||
user
.
username
.
includes
(
this
.
search
),
);
// TODO this de-duplication is temporary (BE fix required)
// https://gitlab.com/gitlab-org/gitlab/-/issues/327822
const
mergedSearchResults
=
filteredParticipants
.
concat
(
this
.
searchUsers
)
.
reduce
(
(
acc
,
current
)
=>
(
acc
.
some
((
user
)
=>
current
.
id
===
user
.
id
)
?
acc
:
[...
acc
,
current
]),
[],
);
return
this
.
moveCurrentUserToStart
(
mergedSearchResults
);
},
isSearchEmpty
()
{
...
...
spec/frontend/sidebar/mock_data.js
View file @
5ceabb04
...
...
@@ -366,6 +366,25 @@ export const subscriptionNullResponse = {
},
};
const
mockUser1
=
{
id
:
'
gid://gitlab/User/1
'
,
avatarUrl
:
'
https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80
\
u0026d=identicon
'
,
name
:
'
Administrator
'
,
username
:
'
root
'
,
webUrl
:
'
/root
'
,
status
:
null
,
};
const
mockUser2
=
{
id
:
'
gid://gitlab/User/4
'
,
avatarUrl
:
'
/avatar2
'
,
name
:
'
rookie
'
,
username
:
'
rookie
'
,
webUrl
:
'
rookie
'
,
status
:
null
,
};
export
const
searchResponse
=
{
data
:
{
workspace
:
{
...
...
@@ -373,24 +392,10 @@ export const searchResponse = {
users
:
{
nodes
:
[
{
user
:
{
id
:
'
1
'
,
avatarUrl
:
'
/avatar
'
,
name
:
'
root
'
,
username
:
'
root
'
,
webUrl
:
'
root
'
,
status
:
null
,
},
user
:
mockUser1
,
},
{
user
:
{
id
:
'
2
'
,
avatarUrl
:
'
/avatar2
'
,
name
:
'
rookie
'
,
username
:
'
rookie
'
,
webUrl
:
'
rookie
'
,
status
:
null
,
},
user
:
mockUser2
,
},
],
},
...
...
@@ -407,39 +412,10 @@ export const projectMembersResponse = {
// 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
'
,
avatarUrl
:
'
https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80
\
u0026d=identicon
'
,
name
:
'
Administrator
'
,
username
:
'
root
'
,
webUrl
:
'
/root
'
,
status
:
null
,
},
},
{
user
:
{
id
:
'
2
'
,
avatarUrl
:
'
/avatar2
'
,
name
:
'
rookie
'
,
username
:
'
rookie
'
,
webUrl
:
'
rookie
'
,
status
:
null
,
},
},
// Remove duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822
mockUser1
,
mockUser1
,
mockUser2
,
{
user
:
{
id
:
'
gid://gitlab/User/2
'
,
...
...
@@ -469,25 +445,9 @@ 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
:
'
https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80
\
u0026d=identicon
'
,
name
:
'
Administrator
'
,
username
:
'
root
'
,
webUrl
:
'
/root
'
,
status
:
null
,
},
// Remove duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822
mockUser1
,
mockUser1
,
{
id
:
'
gid://gitlab/User/2
'
,
avatarUrl
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment