diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-18 04:30:43 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:27 -0200 |
commit | a9938e227bfb0ee1908beb9238bb95fece72805e (patch) | |
tree | 382b64edd5b1302e788a0dc441ab00a8f29f7a08 | |
parent | f99744d00de10094d6e483776313c52d86437a9d (diff) | |
download | gitlab-ce-a9938e227bfb0ee1908beb9238bb95fece72805e.tar.gz |
Add support to group labels to SlashCommands::InterpretService
-rw-r--r-- | app/finders/labels_finder.rb | 2 | ||||
-rw-r--r-- | app/services/slash_commands/interpret_service.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb index 65db4184ecf..a5802171b6c 100644 --- a/app/finders/labels_finder.rb +++ b/app/finders/labels_finder.rb @@ -52,7 +52,7 @@ class LabelsFinder < UnionFinder end def title - params[:title].presence + params[:title].presence || params[:name].presence end def project diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb index e4ae3dec8aa..5a81194a5f4 100644 --- a/app/services/slash_commands/interpret_service.rb +++ b/app/services/slash_commands/interpret_service.rb @@ -116,8 +116,10 @@ module SlashCommands desc 'Add label(s)' params '~label1 ~"label 2"' condition do + available_labels = LabelsFinder.new(current_user, project_id: project.id).execute + current_user.can?(:"admin_#{issuable.to_ability_name}", project) && - project.labels.any? + available_labels.any? end command :label do |labels_param| label_ids = find_label_ids(labels_param) @@ -248,7 +250,7 @@ module SlashCommands def find_label_ids(labels_param) 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 end |