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

42 lines
1 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
2018-03-17 18:26:18 +05:30
skip_before_action :authenticate_user!, only: [:users, :award_emojis]
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
user = UserFinder.new(params).execute!
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
2015-04-26 12:48:37 +05:30
end