2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-13 03:33:09 +00:00
|
|
|
class Projects::AutocompleteSourcesController < Projects::ApplicationController
|
2018-08-09 09:04:12 +00:00
|
|
|
before_action :load_autocomplete_service, except: [:members]
|
2016-10-13 03:33:09 +00:00
|
|
|
|
|
|
|
def members
|
2017-11-28 03:51:03 +00:00
|
|
|
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
|
2016-10-13 03:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def issues
|
|
|
|
render json: @autocomplete_service.issues
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_requests
|
|
|
|
render json: @autocomplete_service.merge_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
def labels
|
2018-07-06 03:37:58 +00:00
|
|
|
render json: @autocomplete_service.labels_as_hash(target)
|
2016-10-13 03:33:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def milestones
|
|
|
|
render json: @autocomplete_service.milestones
|
|
|
|
end
|
|
|
|
|
|
|
|
def commands
|
2017-11-28 03:51:03 +00:00
|
|
|
render json: @autocomplete_service.commands(target, params[:type])
|
2016-10-13 03:33:09 +00:00
|
|
|
end
|
|
|
|
|
2018-10-05 09:42:38 +00:00
|
|
|
def snippets
|
|
|
|
render json: @autocomplete_service.snippets
|
|
|
|
end
|
|
|
|
|
2016-10-13 03:33:09 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def load_autocomplete_service
|
|
|
|
@autocomplete_service = ::Projects::AutocompleteService.new(@project, current_user)
|
|
|
|
end
|
|
|
|
|
2017-11-28 03:51:03 +00:00
|
|
|
def target
|
2018-08-09 09:04:12 +00:00
|
|
|
QuickActions::TargetService
|
|
|
|
.new(project, current_user)
|
|
|
|
.execute(params[:type], params[:type_id])
|
2016-10-13 03:33:09 +00:00
|
|
|
end
|
|
|
|
end
|