debian-mirror-gitlab/app/services/projects/autocomplete_service.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
module Projects
class AutocompleteService < BaseService
2016-06-02 11:05:42 +05:30
def issues
2016-09-13 17:45:13 +05:30
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
2016-06-02 11:05:42 +05:30
def milestones
@project.milestones.active.reorder(due_date: :asc, title: :asc).select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
def merge_requests
2016-09-13 17:45:13 +05:30
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
2016-06-22 15:30:34 +05:30
def labels
2016-11-03 12:29:30 +05:30
LabelsFinder.new(current_user, project_id: project.id).execute.select([:title, :color])
2016-06-22 15:30:34 +05:30
end
2016-09-13 17:45:13 +05:30
def commands(noteable, type)
noteable ||=
case type
when 'Issue'
@project.issues.build
when 'MergeRequest'
@project.merge_requests.build
end
return [] unless noteable && noteable.is_a?(Issuable)
opts = {
project: project,
issuable: noteable,
current_user: current_user
}
SlashCommands::InterpretService.command_definitions.map do |definition|
next unless definition.available?(opts)
definition.to_h(opts)
end.compact
end
2015-04-26 12:48:37 +05:30
end
end