Add support to group labels to SlashCommands::InterpretService

parent f99744d0
...@@ -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
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment