2018-07-17 12:50:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-22 20:51:35 -05:00
|
|
|
module Projects
|
|
|
|
class AutocompleteService < BaseService
|
2018-09-28 09:47:58 -04:00
|
|
|
include LabelsAsHash
|
2015-01-22 20:51:35 -05:00
|
|
|
def issues
|
2016-08-12 21:17:18 -04:00
|
|
|
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
|
2015-01-22 20:51:35 -05:00
|
|
|
end
|
|
|
|
|
2016-04-04 22:37:50 -04:00
|
|
|
def milestones
|
2017-08-03 13:50:52 -04:00
|
|
|
finder_params = {
|
|
|
|
project_ids: [@project.id],
|
|
|
|
state: :active,
|
|
|
|
order: { due_date: :asc, title: :asc }
|
|
|
|
}
|
|
|
|
|
2018-06-16 02:37:07 -04:00
|
|
|
finder_params[:group_ids] = @project.group.self_and_ancestors_ids if @project.group
|
2017-08-03 13:50:52 -04:00
|
|
|
|
|
|
|
MilestonesFinder.new(finder_params).execute.select([:iid, :title])
|
2016-04-04 22:37:50 -04:00
|
|
|
end
|
|
|
|
|
2015-01-22 20:51:35 -05:00
|
|
|
def merge_requests
|
2016-08-12 21:17:18 -04:00
|
|
|
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
|
2015-01-22 20:51:35 -05:00
|
|
|
end
|
2016-05-03 07:07:06 -04:00
|
|
|
|
2016-08-12 21:17:18 -04:00
|
|
|
def commands(noteable, type)
|
2018-07-21 04:11:07 -04:00
|
|
|
return [] unless noteable
|
2016-08-12 21:17:18 -04:00
|
|
|
|
2018-02-23 09:23:09 -05:00
|
|
|
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
|
2016-06-30 11:34:19 -04:00
|
|
|
end
|
2018-09-28 09:47:58 -04:00
|
|
|
|
2018-10-05 05:42:38 -04:00
|
|
|
def snippets
|
|
|
|
SnippetsFinder.new(current_user, project: project).execute.select([:id, :title])
|
|
|
|
end
|
|
|
|
|
2018-09-28 09:47:58 -04:00
|
|
|
def labels_as_hash(target)
|
|
|
|
super(target, project_id: project.id, include_ancestor_groups: true)
|
|
|
|
end
|
2015-01-22 20:51:35 -05:00
|
|
|
end
|
|
|
|
end
|