2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class Projects::AutocompleteSourcesController < Projects::ApplicationController
|
|
|
|
before_action :load_autocomplete_service, except: [:members]
|
|
|
|
|
|
|
|
def members
|
2018-03-17 18:26:18 +05:30
|
|
|
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def issues
|
|
|
|
render json: @autocomplete_service.issues
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_requests
|
|
|
|
render json: @autocomplete_service.merge_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
def labels
|
2018-11-08 19:23:39 +05:30
|
|
|
render json: @autocomplete_service.labels_as_hash(target)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def milestones
|
|
|
|
render json: @autocomplete_service.milestones
|
|
|
|
end
|
|
|
|
|
|
|
|
def commands
|
2018-03-17 18:26:18 +05:30
|
|
|
render json: @autocomplete_service.commands(target, params[:type])
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
def snippets
|
|
|
|
render json: @autocomplete_service.snippets
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def load_autocomplete_service
|
|
|
|
@autocomplete_service = ::Projects::AutocompleteService.new(@project, current_user)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def target
|
2018-11-20 20:47:30 +05:30
|
|
|
QuickActions::TargetService
|
|
|
|
.new(project, current_user)
|
|
|
|
.execute(params[:type], params[:type_id])
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|