diff options
author | Peter Leitzen <pl@neopoly.de> | 2018-07-21 10:11:07 +0200 |
---|---|---|
committer | Peter Leitzen <pl@neopoly.de> | 2018-08-10 16:45:11 +0200 |
commit | d23fbbc6928983582198092cf28a0cd46d30252f (patch) | |
tree | dd4f68905cbd71c1596e8fa823a898bdbfa537a5 /app | |
parent | 4779c43ef9c2c3d534effdbacf3af910ed3e3c3e (diff) | |
download | gitlab-ce-d23fbbc6928983582198092cf28a0cd46d30252f.tar.gz |
Build noteables in AutocompleteSourcesController#target
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/autocomplete_sources_controller.rb | 4 | ||||
-rw-r--r-- | app/services/projects/autocomplete_service.rb | 10 |
2 files changed, 3 insertions, 11 deletions
diff --git a/app/controllers/projects/autocomplete_sources_controller.rb b/app/controllers/projects/autocomplete_sources_controller.rb index 07627ffb69f..eaaac5ca940 100644 --- a/app/controllers/projects/autocomplete_sources_controller.rb +++ b/app/controllers/projects/autocomplete_sources_controller.rb @@ -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 diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb index 10eb2cea4a2..5286b92ab6b 100644 --- a/app/services/projects/autocomplete_service.rb +++ b/app/services/projects/autocomplete_service.rb @@ -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 |