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
c4d18b05
Commit
c4d18b05
authored
Dec 10, 2018
by
Jarka Košanová
Committed by
Lin Jen-Shin
Jan 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use parent instead of project
Add support for group entities to quick actions
parent
0c1d6be1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
15 deletions
+47
-15
app/models/note.rb
app/models/note.rb
+4
-0
app/services/notes/quick_actions_service.rb
app/services/notes/quick_actions_service.rb
+1
-1
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+27
-14
spec/models/note_spec.rb
spec/models/note_spec.rb
+15
-0
No files found.
app/models/note.rb
View file @
c4d18b05
...
...
@@ -456,6 +456,10 @@ class Note < ActiveRecord::Base
Upload
.
find_by
(
model:
self
,
path:
paths
)
end
def
parent
project
end
private
def
keep_around_commit
...
...
app/services/notes/quick_actions_service.rb
View file @
c4d18b05
...
...
@@ -31,7 +31,7 @@ module Notes
return
if
command_params
.
empty?
return
unless
supported?
(
note
)
self
.
class
.
noteable_update_service
(
note
).
new
(
projec
t
,
current_user
,
command_params
).
execute
(
note
.
noteable
)
self
.
class
.
noteable_update_service
(
note
).
new
(
note
.
paren
t
,
current_user
,
command_params
).
execute
(
note
.
noteable
)
end
end
end
app/services/quick_actions/interpret_service.rb
View file @
c4d18b05
...
...
@@ -2,6 +2,7 @@
module
QuickActions
class
InterpretService
<
BaseService
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
QuickActions
::
Dsl
attr_reader
:issuable
...
...
@@ -210,15 +211,9 @@ module QuickActions
end
params
'~label1 ~"label 2"'
condition
do
if
project
available_labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
,
include_ancestor_groups:
true
)
.
execute
end
project
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
&&
available_labels
.
any?
parent
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
parent
)
&&
find_labels
.
any?
end
command
:label
do
|
labels_param
|
label_ids
=
find_label_ids
(
labels_param
)
...
...
@@ -245,7 +240,7 @@ module QuickActions
issuable
.
is_a?
(
Issuable
)
&&
issuable
.
persisted?
&&
issuable
.
labels
.
any?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
p
rojec
t
)
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
p
aren
t
)
end
command
:unlabel
do
|
labels_param
=
nil
|
if
labels_param
.
present?
...
...
@@ -674,9 +669,25 @@ module QuickActions
MilestonesFinder
.
new
(
params
.
merge
(
project_ids:
[
project
.
id
],
group_ids:
[
project
.
group
&
.
id
])).
execute
end
def
find_labels
(
labels_param
)
extract_references
(
labels_param
,
:label
)
|
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
,
name:
labels_param
.
split
,
include_ancestor_groups:
true
).
execute
def
parent
project
||
group
end
def
group
strong_memoize
(
:group
)
do
issuable
.
group
if
issuable
.
respond_to?
(
:group
)
end
end
def
find_labels
(
labels_params
=
nil
)
finder_params
=
{
include_ancestor_groups:
true
}
finder_params
[
:project_id
]
=
project
.
id
if
project
finder_params
[
:group_id
]
=
group
.
id
if
group
finder_params
[
:name
]
=
labels_params
.
split
if
labels_params
result
=
LabelsFinder
.
new
(
current_user
,
finder_params
).
execute
extract_references
(
labels_params
,
:label
)
|
result
end
def
find_label_references
(
labels_param
)
...
...
@@ -707,9 +718,11 @@ module QuickActions
# rubocop: disable CodeReuse/ActiveRecord
def
extract_references
(
arg
,
type
)
return
[]
unless
arg
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
ext
.
analyze
(
arg
,
author:
current_user
)
ext
.
analyze
(
arg
,
author:
current_user
,
group:
group
)
ext
.
references
(
type
)
end
...
...
spec/models/note_spec.rb
View file @
c4d18b05
...
...
@@ -890,4 +890,19 @@ describe Note do
end
end
end
describe
'#parent'
do
it
'returns project for project notes'
do
project
=
create
(
:project
)
note
=
create
(
:note_on_issue
,
project:
project
)
expect
(
note
.
parent
).
to
eq
(
project
)
end
it
'returns nil for personal snippet note'
do
note
=
create
(
:note_on_personal_snippet
)
expect
(
note
.
parent
).
to
be_nil
end
end
end
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