2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-12 23:33:09 -04:00
|
|
|
class Projects::AutocompleteSourcesController < Projects::ApplicationController
|
|
|
|
def members
|
2017-11-27 22:51:03 -05:00
|
|
|
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def issues
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.issues
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_requests
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.merge_requests
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def labels
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.labels_as_hash(target)
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def milestones
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.milestones
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commands
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.commands(target, params[:type])
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
2018-10-05 05:42:38 -04:00
|
|
|
def snippets
|
2018-11-01 04:57:09 -04:00
|
|
|
render json: autocomplete_service.snippets
|
2018-10-05 05:42:38 -04:00
|
|
|
end
|
|
|
|
|
2016-10-12 23:33:09 -04:00
|
|
|
private
|
|
|
|
|
2018-11-01 04:57:09 -04:00
|
|
|
def autocomplete_service
|
|
|
|
@autocomplete_service ||= ::Projects::AutocompleteService.new(@project, current_user)
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
|
2017-11-27 22:51:03 -05:00
|
|
|
def target
|
2018-08-09 05:04:12 -04:00
|
|
|
QuickActions::TargetService
|
|
|
|
.new(project, current_user)
|
|
|
|
.execute(params[:type], params[:type_id])
|
2016-10-12 23:33:09 -04:00
|
|
|
end
|
|
|
|
end
|