debian-mirror-gitlab/app/controllers/autocomplete_controller.rb

49 lines
1.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
class AutocompleteController < ApplicationController
2019-05-18 00:54:41 +05:30
skip_before_action :authenticate_user!, only: [:users, :award_emojis, :merge_request_target_branches]
2015-09-11 14:41:01 +05:30
2015-04-26 12:48:37 +05:30
def users
2018-11-20 20:47:30 +05:30
project = Autocomplete::ProjectFinder
.new(current_user, params)
.execute
2018-11-20 20:47:30 +05:30
group = Autocomplete::GroupFinder
.new(current_user, project, params)
.execute
2018-11-20 20:47:30 +05:30
users = Autocomplete::UsersFinder
.new(params: params, current_user: current_user, project: project, group: group)
.execute
2018-03-17 18:26:18 +05:30
2018-11-20 20:47:30 +05:30
render json: UserSerializer.new.represent(users)
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
2018-11-20 20:47:30 +05:30
def user
2018-12-13 13:39:08 +05:30
user = UserFinder.new(params[:id]).find_by_id!
2015-12-23 02:04:40 +05:30
2018-11-20 20:47:30 +05:30
render json: UserSerializer.new.represent(user)
2015-12-23 02:04:40 +05:30
end
2016-09-13 17:45:13 +05:30
2018-11-20 20:47:30 +05:30
# Displays projects to use for the dropdown when moving a resource from one
# project to another.
def projects
projects = Autocomplete::MoveToProjectFinder
.new(current_user, params)
.execute
2018-03-17 18:26:18 +05:30
2018-11-20 20:47:30 +05:30
render json: MoveToProjectSerializer.new.represent(projects)
2016-09-13 17:45:13 +05:30
end
2018-11-20 20:47:30 +05:30
def award_emojis
render json: AwardedEmojiFinder.new(current_user).execute
2016-09-13 17:45:13 +05:30
end
2019-05-18 00:54:41 +05:30
def merge_request_target_branches
merge_requests = MergeRequestsFinder.new(current_user, params).execute
target_branches = merge_requests.recent_target_branches
render json: target_branches.map { |target_branch| { title: target_branch } }
end
2015-04-26 12:48:37 +05:30
end