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
2bedf6c9
Commit
2bedf6c9
authored
Sep 30, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Prevent assignment of groups using quick actions"
This reverts commit
d02ef2db
.
parent
2b719022
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
98 deletions
+23
-98
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+2
-5
app/assets/javascripts/vue_shared/components/gl_mentions.vue
app/assets/javascripts/vue_shared/components/gl_mentions.vue
+2
-7
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+1
-1
changelogs/unreleased/241738-prevent-assignment-to-groups.yml
...gelogs/unreleased/241738-prevent-assignment-to-groups.yml
+0
-5
ee/spec/features/issues/gfm_autocomplete_ee_spec.rb
ee/spec/features/issues/gfm_autocomplete_ee_spec.rb
+10
-44
spec/features/issues/gfm_autocomplete_spec.rb
spec/features/issues/gfm_autocomplete_spec.rb
+8
-19
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+0
-4
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+0
-13
No files found.
app/assets/javascripts/gfm_auto_complete.js
View file @
2bedf6c9
...
@@ -35,7 +35,6 @@ export function membersBeforeSave(members) {
...
@@ -35,7 +35,6 @@ export function membersBeforeSave(members) {
:
''
;
:
''
;
return
{
return
{
type
:
member
.
type
,
username
:
member
.
username
,
username
:
member
.
username
,
avatarTag
:
autoCompleteAvatar
.
length
===
1
?
txtAvatar
:
imgAvatar
,
avatarTag
:
autoCompleteAvatar
.
length
===
1
?
txtAvatar
:
imgAvatar
,
title
:
sanitize
(
title
),
title
:
sanitize
(
title
),
...
@@ -278,11 +277,9 @@ class GfmAutoComplete {
...
@@ -278,11 +277,9 @@ class GfmAutoComplete {
return
$
.
fn
.
atwho
.
default
.
callbacks
.
filter
(
query
,
data
,
searchKey
);
return
$
.
fn
.
atwho
.
default
.
callbacks
.
filter
(
query
,
data
,
searchKey
);
}
}
if
(
command
===
MEMBER_COMMAND
.
ASSIGN
||
command
===
MEMBER_COMMAND
.
REASSIGN
)
{
if
(
command
===
MEMBER_COMMAND
.
ASSIGN
)
{
// Only include members which are not assigned to Issuable currently
// Only include members which are not assigned to Issuable currently
return
data
.
filter
(
return
data
.
filter
(
member
=>
!
assignees
.
includes
(
member
.
search
));
member
=>
member
.
type
===
'
User
'
&&
!
assignees
.
includes
(
member
.
search
),
);
}
else
if
(
command
===
MEMBER_COMMAND
.
UNASSIGN
)
{
}
else
if
(
command
===
MEMBER_COMMAND
.
UNASSIGN
)
{
// Only include members which are assigned to Issuable currently
// Only include members which are assigned to Issuable currently
return
data
.
filter
(
member
=>
assignees
.
includes
(
member
.
search
));
return
data
.
filter
(
member
=>
assignees
.
includes
(
member
.
search
));
...
...
app/assets/javascripts/vue_shared/components/gl_mentions.vue
View file @
2bedf6c9
...
@@ -65,13 +65,8 @@ const autoCompleteMap = {
...
@@ -65,13 +65,8 @@ const autoCompleteMap = {
SidebarMediator
.
singleton
?.
store
?.
assignees
?.
map
(
assignee
=>
assignee
.
username
)
||
[];
SidebarMediator
.
singleton
?.
store
?.
assignees
?.
map
(
assignee
=>
assignee
.
username
)
||
[];
}
}
if
(
if
(
doesCurrentLineStartWith
(
'
/assign
'
,
fullText
,
selectionStart
))
{
doesCurrentLineStartWith
(
'
/assign
'
,
fullText
,
selectionStart
)
||
return
this
.
members
.
filter
(
member
=>
!
this
.
assignees
.
includes
(
member
.
username
));
doesCurrentLineStartWith
(
'
/reassign
'
,
fullText
,
selectionStart
)
)
{
return
this
.
members
.
filter
(
member
=>
member
.
type
===
'
User
'
&&
!
this
.
assignees
.
includes
(
member
.
username
),
);
}
}
if
(
doesCurrentLineStartWith
(
'
/unassign
'
,
fullText
,
selectionStart
))
{
if
(
doesCurrentLineStartWith
(
'
/unassign
'
,
fullText
,
selectionStart
))
{
...
...
app/services/quick_actions/interpret_service.rb
View file @
2bedf6c9
...
@@ -69,7 +69,7 @@ module QuickActions
...
@@ -69,7 +69,7 @@ module QuickActions
def
extract_users
(
params
)
def
extract_users
(
params
)
return
[]
if
params
.
nil?
return
[]
if
params
.
nil?
users
=
extract_references
(
params
,
:
mentioned_
user
)
users
=
extract_references
(
params
,
:user
)
if
users
.
empty?
if
users
.
empty?
users
=
users
=
...
...
changelogs/unreleased/241738-prevent-assignment-to-groups.yml
deleted
100644 → 0
View file @
2b719022
---
title
:
Prevent assignment of groups using quick actions
merge_request
:
42810
author
:
type
:
fixed
ee/spec/features/issues/gfm_autocomplete_ee_spec.rb
View file @
2bedf6c9
...
@@ -3,49 +3,30 @@
...
@@ -3,49 +3,30 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
'GFM autocomplete EE'
,
:js
do
RSpec
.
describe
'GFM autocomplete EE'
,
:js
do
let
_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
_it_be
(
:another_user
)
{
create
(
:user
,
name:
'another user'
,
username:
'another.user'
)
}
let
(
:another_user
)
{
create
(
:user
,
name:
'another user'
,
username:
'another.user'
)
}
let
_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
before
do
before_all
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
project
.
add_developer
(
another_user
)
group
.
add_developer
(
user
)
end
end
context
'assignees'
do
context
'assignees'
do
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
]
)
}
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
)
}
describe
'when tribute_autocomplete feature flag is off'
do
describe
'when tribute_autocomplete feature flag is off'
do
before
do
before
do
stub_feature_flags
(
tribute_autocomplete:
false
)
stub_feature_flags
(
tribute_autocomplete:
false
)
issue_assignee
.
update!
(
assignees:
[
user
])
sign_in
(
user
)
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue_assignee
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
wait_for_requests
end
end
it
'lists users who are currently not assigned to the issue when using /reassign'
do
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/reas'
)
end
find
(
'.atwho-view li'
,
text:
'/reassign'
)
note
.
native
.
send_keys
(
:tab
)
wait_for_requests
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
another_user
.
username
)
end
it
'only lists users who are currently assigned to the issue when using /unassign'
do
it
'only lists users who are currently assigned to the issue when using /unassign'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
...
@@ -67,29 +48,14 @@ RSpec.describe 'GFM autocomplete EE', :js do
...
@@ -67,29 +48,14 @@ RSpec.describe 'GFM autocomplete EE', :js do
before
do
before
do
stub_feature_flags
(
tribute_autocomplete:
true
)
stub_feature_flags
(
tribute_autocomplete:
true
)
issue_assignee
.
update!
(
assignees:
[
user
])
sign_in
(
user
)
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue_assignee
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
wait_for_requests
end
end
it
'lists users who are currently not assigned to the issue when using /reassign'
do
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/reas'
)
end
find
(
'.atwho-view li'
,
text:
'/reassign'
)
note
.
native
.
send_keys
(
:tab
)
note
.
native
.
send_keys
(
:right
)
wait_for_requests
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
to
have_content
(
another_user
.
username
)
end
it
'only lists users who are currently assigned to the issue when using /unassign'
do
it
'only lists users who are currently assigned to the issue when using /unassign'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
...
...
spec/features/issues/gfm_autocomplete_spec.rb
View file @
2bedf6c9
...
@@ -297,21 +297,18 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -297,21 +297,18 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
context
'assignees'
do
context
'assignees'
do
let
_it_be
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
]
)
}
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:unassigned_user
)
{
create
(
:user
)
}
let
(
:unassigned_user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
before
do
issue_assignee
.
update
(
assignees:
[
user
])
before_all
do
project
.
add_maintainer
(
unassigned_user
)
project
.
add_maintainer
(
unassigned_user
)
group
.
add_developer
(
user
)
end
end
it
'lists users who are currently not assigned to the issue when using /assign'
do
it
'lists users who are currently not assigned to the issue when using /assign'
do
visit
project_issue_path
(
project
,
issue_assignee
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/as'
)
note
.
native
.
send_keys
(
'/as'
)
...
@@ -323,7 +320,6 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -323,7 +320,6 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
unassigned_user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
unassigned_user
.
username
)
end
end
...
@@ -336,7 +332,6 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -336,7 +332,6 @@ RSpec.describe 'GFM autocomplete', :js do
textarea
.
native
.
send_keys
(
:tab
)
textarea
.
native
.
send_keys
(
:tab
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
unassigned_user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
unassigned_user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
user
.
username
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
user
.
username
)
end
end
end
end
...
@@ -669,21 +664,18 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -669,21 +664,18 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
context
'assignees'
do
context
'assignees'
do
let
_it_be
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
]
)
}
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
)
}
let
_it_be
(
:unassigned_user
)
{
create
(
:user
)
}
let
(
:unassigned_user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
before
do
issue_assignee
.
update
(
assignees:
[
user
])
before_all
do
project
.
add_maintainer
(
unassigned_user
)
project
.
add_maintainer
(
unassigned_user
)
group
.
add_developer
(
user
)
end
end
it
'lists users who are currently not assigned to the issue when using /assign'
do
it
'lists users who are currently not assigned to the issue when using /assign'
do
visit
project_issue_path
(
project
,
issue_assignee
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/as'
)
note
.
native
.
send_keys
(
'/as'
)
...
@@ -696,15 +688,12 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -696,15 +688,12 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
not_to
have_content
(
user
.
username
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
to
have_content
(
unassigned_user
.
username
)
expect
(
find
(
'.tribute-container ul'
,
visible:
true
)).
to
have_content
(
unassigned_user
.
username
)
end
end
it
'lists users who are currently not assigned to the issue when using /assign on the second line'
do
it
'lists users who are currently not assigned to the issue when using /assign on the second line'
do
visit
project_issue_path
(
project
,
issue_assignee
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/assign @user2'
)
note
.
native
.
send_keys
(
'/assign @user2'
)
...
...
spec/frontend/gfm_auto_complete_spec.js
View file @
2bedf6c9
...
@@ -491,7 +491,6 @@ describe('GfmAutoComplete', () => {
...
@@ -491,7 +491,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set the text avatar if avatar_url is null
'
,
()
=>
{
it
(
'
should set the text avatar if avatar_url is null
'
,
()
=>
{
expect
(
membersBeforeSave
([{
...
mockGroup
,
avatar_url
:
null
}])).
toEqual
([
expect
(
membersBeforeSave
([{
...
mockGroup
,
avatar_url
:
null
}])).
toEqual
([
{
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
username
:
'
my-group
'
,
avatarTag
:
'
<div class="avatar rect-avatar center avatar-inline s26">M</div>
'
,
avatarTag
:
'
<div class="avatar rect-avatar center avatar-inline s26">M</div>
'
,
title
:
'
My Group (2)
'
,
title
:
'
My Group (2)
'
,
...
@@ -504,7 +503,6 @@ describe('GfmAutoComplete', () => {
...
@@ -504,7 +503,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set the image avatar if avatar_url is given
'
,
()
=>
{
it
(
'
should set the image avatar if avatar_url is given
'
,
()
=>
{
expect
(
membersBeforeSave
([
mockGroup
])).
toEqual
([
expect
(
membersBeforeSave
([
mockGroup
])).
toEqual
([
{
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
username
:
'
my-group
'
,
avatarTag
:
avatarTag
:
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
...
@@ -518,7 +516,6 @@ describe('GfmAutoComplete', () => {
...
@@ -518,7 +516,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set mentions disabled icon if mentionsDisabled is set
'
,
()
=>
{
it
(
'
should set mentions disabled icon if mentionsDisabled is set
'
,
()
=>
{
expect
(
membersBeforeSave
([{
...
mockGroup
,
mentionsDisabled
:
true
}])).
toEqual
([
expect
(
membersBeforeSave
([{
...
mockGroup
,
mentionsDisabled
:
true
}])).
toEqual
([
{
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
username
:
'
my-group
'
,
avatarTag
:
avatarTag
:
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
...
@@ -537,7 +534,6 @@ describe('GfmAutoComplete', () => {
...
@@ -537,7 +534,6 @@ describe('GfmAutoComplete', () => {
]),
]),
).
toEqual
([
).
toEqual
([
{
{
type
:
'
User
'
,
username
:
'
my-user
'
,
username
:
'
my-user
'
,
avatarTag
:
avatarTag
:
'
<img src="./users.jpg" alt="my-user" class="avatar avatar-inline center s26"/>
'
,
'
<img src="./users.jpg" alt="my-user" class="avatar avatar-inline center s26"/>
'
,
...
...
spec/services/quick_actions/interpret_service_spec.rb
View file @
2bedf6c9
...
@@ -834,19 +834,6 @@ RSpec.describe QuickActions::InterpretService do
...
@@ -834,19 +834,6 @@ RSpec.describe QuickActions::InterpretService do
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
context
'assigning to a group'
do
let_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
before_all
do
group
.
add_developer
(
create
(
:user
))
end
it_behaves_like
'empty command'
,
"Failed to assign a user because no user was found."
do
let
(
:content
)
{
"/assign
#{
group
.
to_reference
}
"
}
let
(
:issuable
)
{
issue
}
end
end
context
'unassign command'
do
context
'unassign command'
do
let
(
:content
)
{
'/unassign'
}
let
(
:content
)
{
'/unassign'
}
...
...
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