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) {
:
''
;
return
{
type
:
member
.
type
,
username
:
member
.
username
,
avatarTag
:
autoCompleteAvatar
.
length
===
1
?
txtAvatar
:
imgAvatar
,
title
:
sanitize
(
title
),
...
...
@@ -278,11 +277,9 @@ class GfmAutoComplete {
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
return
data
.
filter
(
member
=>
member
.
type
===
'
User
'
&&
!
assignees
.
includes
(
member
.
search
),
);
return
data
.
filter
(
member
=>
!
assignees
.
includes
(
member
.
search
));
}
else
if
(
command
===
MEMBER_COMMAND
.
UNASSIGN
)
{
// Only include members which are assigned to Issuable currently
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 = {
SidebarMediator
.
singleton
?.
store
?.
assignees
?.
map
(
assignee
=>
assignee
.
username
)
||
[];
}
if
(
doesCurrentLineStartWith
(
'
/assign
'
,
fullText
,
selectionStart
)
||
doesCurrentLineStartWith
(
'
/reassign
'
,
fullText
,
selectionStart
)
)
{
return
this
.
members
.
filter
(
member
=>
member
.
type
===
'
User
'
&&
!
this
.
assignees
.
includes
(
member
.
username
),
);
if
(
doesCurrentLineStartWith
(
'
/assign
'
,
fullText
,
selectionStart
))
{
return
this
.
members
.
filter
(
member
=>
!
this
.
assignees
.
includes
(
member
.
username
));
}
if
(
doesCurrentLineStartWith
(
'
/unassign
'
,
fullText
,
selectionStart
))
{
...
...
app/services/quick_actions/interpret_service.rb
View file @
2bedf6c9
...
...
@@ -69,7 +69,7 @@ module QuickActions
def
extract_users
(
params
)
return
[]
if
params
.
nil?
users
=
extract_references
(
params
,
:
mentioned_
user
)
users
=
extract_references
(
params
,
:user
)
if
users
.
empty?
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 @@
require
'spec_helper'
RSpec
.
describe
'GFM autocomplete EE'
,
:js
do
let
_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
_it_be
(
:another_user
)
{
create
(
:user
,
name:
'another user'
,
username:
'another.user'
)
}
let
_it_be
(
:project
)
{
create
(
:project
)
}
let
_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
(
:another_user
)
{
create
(
:user
,
name:
'another user'
,
username:
'another.user'
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
before_all
do
before
do
project
.
add_maintainer
(
user
)
project
.
add_developer
(
another_user
)
group
.
add_developer
(
user
)
end
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
before
do
stub_feature_flags
(
tribute_autocomplete:
false
)
issue_assignee
.
update!
(
assignees:
[
user
])
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
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
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
...
...
@@ -67,29 +48,14 @@ RSpec.describe 'GFM autocomplete EE', :js do
before
do
stub_feature_flags
(
tribute_autocomplete:
true
)
issue_assignee
.
update!
(
assignees:
[
user
])
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
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
note
=
find
(
'#note-body'
)
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
end
context
'assignees'
do
let
_it_be
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
]
)
}
let
_it_be
(
:unassigned_user
)
{
create
(
:user
)
}
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
)
}
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
)
group
.
add_developer
(
user
)
end
it
'lists users who are currently not assigned to the issue when using /assign'
do
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/as'
)
...
...
@@ -323,7 +320,6 @@ RSpec.describe 'GFM autocomplete', :js do
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
(
unassigned_user
.
username
)
end
...
...
@@ -336,7 +332,6 @@ RSpec.describe 'GFM autocomplete', :js do
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'
)).
not_to
have_content
(
group
.
name
)
expect
(
find
(
'#at-view-users .atwho-view-ul'
)).
to
have_content
(
user
.
username
)
end
end
...
...
@@ -669,21 +664,18 @@ RSpec.describe 'GFM autocomplete', :js do
end
context
'assignees'
do
let
_it_be
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
,
assignees:
[
user
]
)
}
let
_it_be
(
:unassigned_user
)
{
create
(
:user
)
}
let
(
:issue_assignee
)
{
create
(
:issue
,
project:
project
)
}
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
)
group
.
add_developer
(
user
)
end
it
'lists users who are currently not assigned to the issue when using /assign'
do
visit
project_issue_path
(
project
,
issue_assignee
)
wait_for_requests
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/as'
)
...
...
@@ -696,15 +688,12 @@ RSpec.describe 'GFM autocomplete', :js do
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
(
unassigned_user
.
username
)
end
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
)
wait_for_requests
note
=
find
(
'#note-body'
)
page
.
within
'.timeline-content-form'
do
note
.
native
.
send_keys
(
'/assign @user2'
)
...
...
spec/frontend/gfm_auto_complete_spec.js
View file @
2bedf6c9
...
...
@@ -491,7 +491,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set the text avatar if avatar_url is null
'
,
()
=>
{
expect
(
membersBeforeSave
([{
...
mockGroup
,
avatar_url
:
null
}])).
toEqual
([
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
avatarTag
:
'
<div class="avatar rect-avatar center avatar-inline s26">M</div>
'
,
title
:
'
My Group (2)
'
,
...
...
@@ -504,7 +503,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set the image avatar if avatar_url is given
'
,
()
=>
{
expect
(
membersBeforeSave
([
mockGroup
])).
toEqual
([
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
avatarTag
:
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
...
...
@@ -518,7 +516,6 @@ describe('GfmAutoComplete', () => {
it
(
'
should set mentions disabled icon if mentionsDisabled is set
'
,
()
=>
{
expect
(
membersBeforeSave
([{
...
mockGroup
,
mentionsDisabled
:
true
}])).
toEqual
([
{
type
:
'
Group
'
,
username
:
'
my-group
'
,
avatarTag
:
'
<img src="./group.jpg" alt="my-group" class="avatar rect-avatar avatar-inline center s26"/>
'
,
...
...
@@ -537,7 +534,6 @@ describe('GfmAutoComplete', () => {
]),
).
toEqual
([
{
type
:
'
User
'
,
username
:
'
my-user
'
,
avatarTag
:
'
<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
let
(
:issuable
)
{
issue
}
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
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