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
|
2019-02-22 09:31:02 -05:00
|
|
|
before_action :authorize_read_milestone!, only: :milestones
|
|
|
|
|
2021-10-27 11:13:41 -04:00
|
|
|
feature_category :team_planning, [:issues, :labels, :milestones, :commands]
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :code_review, [:merge_requests]
|
|
|
|
feature_category :users, [:members]
|
|
|
|
feature_category :snippets, [:snippets]
|
|
|
|
|
2016-10-12 23:33:09 -04:00
|
|
|
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
|
2020-11-17 16:09:19 -05:00
|
|
|
@autocomplete_service ||= ::Projects::AutocompleteService.new(@project, current_user, params)
|
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
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Projects::AutocompleteSourcesController.prepend_mod_with('Projects::AutocompleteSourcesController')
|