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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a9938e22
Commit
a9938e22
authored
Oct 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to group labels to SlashCommands::InterpretService
parent
f99744d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
app/finders/labels_finder.rb
app/finders/labels_finder.rb
+1
-1
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+4
-2
No files found.
app/finders/labels_finder.rb
View file @
a9938e22
...
@@ -52,7 +52,7 @@ class LabelsFinder < UnionFinder
...
@@ -52,7 +52,7 @@ class LabelsFinder < UnionFinder
end
end
def
title
def
title
params
[
:title
].
presence
params
[
:title
].
presence
||
params
[
:name
].
presence
end
end
def
project
def
project
...
...
app/services/slash_commands/interpret_service.rb
View file @
a9938e22
...
@@ -116,8 +116,10 @@ module SlashCommands
...
@@ -116,8 +116,10 @@ module SlashCommands
desc
'Add label(s)'
desc
'Add label(s)'
params
'~label1 ~"label 2"'
params
'~label1 ~"label 2"'
condition
do
condition
do
available_labels
=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
&&
project
.
labels
.
any?
available_
labels
.
any?
end
end
command
:label
do
|
labels_param
|
command
:label
do
|
labels_param
|
label_ids
=
find_label_ids
(
labels_param
)
label_ids
=
find_label_ids
(
labels_param
)
...
@@ -248,7 +250,7 @@ module SlashCommands
...
@@ -248,7 +250,7 @@ module SlashCommands
def
find_label_ids
(
labels_param
)
def
find_label_ids
(
labels_param
)
label_ids_by_reference
=
extract_references
(
labels_param
,
:label
).
map
(
&
:id
)
label_ids_by_reference
=
extract_references
(
labels_param
,
:label
).
map
(
&
:id
)
labels_ids_by_name
=
@project
.
labels
.
where
(
name:
labels_param
.
split
)
.
select
(
:id
)
labels_ids_by_name
=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
,
name:
labels_param
.
split
).
execute
.
select
(
:id
)
label_ids_by_reference
|
labels_ids_by_name
label_ids_by_reference
|
labels_ids_by_name
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