Build noteables in AutocompleteSourcesController#target

This commit is contained in:
Peter Leitzen 2018-07-21 10:11:07 +02:00
parent 4779c43ef9
commit d23fbbc692
2 changed files with 3 additions and 11 deletions

View File

@ -34,9 +34,9 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController
def target
case params[:type]&.downcase
when 'issue'
IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:type_id])
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])
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

View File

@ -47,15 +47,7 @@ module Projects
end
def commands(noteable, type)
noteable ||=
case type
when 'Issue'
@project.issues.build
when 'MergeRequest'
@project.merge_requests.build
end
return [] unless noteable&.is_a?(Issuable)
return [] unless noteable
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
end