summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorChantal Rollison <crollison@gitlab.com>2018-09-28 06:47:58 -0700
committerChantal Rollison <crollison@gitlab.com>2018-10-03 09:13:42 -0700
commitdf6e9ed38e7fd4c985a4809b09eedc886ebe6a54 (patch)
tree8328708b8ac969768bfcbd505d3c51cbc885b3ce /app/services
parent274738391b23cb13f0c1be7a6d061a6909beb7a0 (diff)
downloadgitlab-ce-df6e9ed38e7fd4c985a4809b09eedc886ebe6a54.tar.gz
Create labels_as_hash_ concern, modify params for methodccr/48930_extract_logic_to_concern
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/autocomplete_service.rb29
1 files changed, 5 insertions, 24 deletions
diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb
index 5286b92ab6b..7b747171d9c 100644
--- a/app/services/projects/autocomplete_service.rb
+++ b/app/services/projects/autocomplete_service.rb
@@ -2,6 +2,7 @@
module Projects
class AutocompleteService < BaseService
+ include LabelsAsHash
def issues
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end
@@ -22,34 +23,14 @@ module Projects
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end
- def labels_as_hash(target = nil)
- available_labels = LabelsFinder.new(
- current_user,
- project_id: project.id,
- include_ancestor_groups: true
- ).execute
-
- label_hashes = available_labels.as_json(only: [:title, :color])
-
- if target&.respond_to?(:labels)
- already_set_labels = available_labels & target.labels
- if already_set_labels.present?
- titles = already_set_labels.map(&:title)
- label_hashes.each do |hash|
- if titles.include?(hash['title'])
- hash[:set] = true
- end
- end
- end
- end
-
- label_hashes
- end
-
def commands(noteable, type)
return [] unless noteable
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
end
+
+ def labels_as_hash(target)
+ super(target, project_id: project.id, include_ancestor_groups: true)
+ end
end
end