debian-mirror-gitlab/app/controllers/projects/autocomplete_sources_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.8 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class Projects::AutocompleteSourcesController < Projects::ApplicationController
2019-03-13 22:55:13 +05:30
before_action :authorize_read_milestone!, only: :milestones
2022-04-04 11:22:00 +05:30
before_action :authorize_read_crm_contact!, only: :contacts
2019-03-13 22:55:13 +05:30
2022-04-04 11:22:00 +05:30
feature_category :team_planning, [:issues, :labels, :milestones, :commands, :contacts]
2021-01-03 14:25:43 +05:30
feature_category :code_review, [:merge_requests]
feature_category :users, [:members]
feature_category :snippets, [:snippets]
2022-07-16 23:28:13 +05:30
urgency :low, [:merge_requests, :members]
urgency :low, [:issues, :labels, :milestones, :commands, :contacts]
2022-01-26 12:08:38 +05:30
2017-08-17 22:00:37 +05:30
def members
2018-03-17 18:26:18 +05:30
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
2017-08-17 22:00:37 +05:30
end
def issues
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.issues
2017-08-17 22:00:37 +05:30
end
def merge_requests
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.merge_requests
2017-08-17 22:00:37 +05:30
end
def labels
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.labels_as_hash(target)
2017-08-17 22:00:37 +05:30
end
def milestones
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.milestones
2017-08-17 22:00:37 +05:30
end
def commands
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.commands(target, params[:type])
2017-08-17 22:00:37 +05:30
end
2018-12-05 23:21:45 +05:30
def snippets
2018-12-13 13:39:08 +05:30
render json: autocomplete_service.snippets
2018-12-05 23:21:45 +05:30
end
2022-04-04 11:22:00 +05:30
def contacts
2022-11-25 23:54:43 +05:30
render json: autocomplete_service.contacts(target)
2022-04-04 11:22:00 +05:30
end
2017-08-17 22:00:37 +05:30
private
2018-12-13 13:39:08 +05:30
def autocomplete_service
2021-01-29 00:20:46 +05:30
@autocomplete_service ||= ::Projects::AutocompleteService.new(@project, current_user, params)
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
def target
2022-11-25 23:54:43 +05:30
# type_id is not required in general
target_type = params.require(:type)
2018-11-20 20:47:30 +05:30
QuickActions::TargetService
.new(project, current_user)
2022-11-25 23:54:43 +05:30
.execute(target_type, params[:type_id])
2017-08-17 22:00:37 +05:30
end
2022-04-04 11:22:00 +05:30
def authorize_read_crm_contact!
render_404 unless can?(current_user, :read_crm_contact, project.root_ancestor)
end
2017-08-17 22:00:37 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Projects::AutocompleteSourcesController.prepend_mod_with('Projects::AutocompleteSourcesController')