Commit 72ff7966 authored by Peter Leitzen's avatar Peter Leitzen
Browse files

Move finding autocompletion targets into AutocompleteService

parent 0ac62f61f35c
class Projects::AutocompleteSourcesController < Projects::ApplicationController
before_action :load_autocomplete_service, except: [:members]
before_action :load_autocomplete_service
def members
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
......@@ -32,13 +32,6 @@ def load_autocomplete_service
end
def target
case params[:type]&.downcase
when 'issue'
IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:type_id]) || @project.issues.build
when 'mergerequest'
MergeRequestsFinder.new(current_user, project_id: @project.id).find_by(iid: params[:type_id]) || @project.merge_requests.build
when 'commit'
@project.commit(params[:type_id])
end
@autocomplete_service.target(params[:type], params[:type_id])
end
end
......@@ -51,5 +51,16 @@ def commands(noteable, type)
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
end
def target(type, type_id)
case type&.downcase
when 'issue'
IssuesFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.issues.build
when 'mergerequest'
MergeRequestsFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.merge_requests.build
when 'commit'
project.commit(type_id)
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment