2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
module API
|
2021-01-03 14:25:43 +05:30
|
|
|
class GroupBoards < ::API::Base
|
2018-03-27 19:54:05 +05:30
|
|
|
include BoardsResponses
|
|
|
|
include PaginationParams
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
prepend_if_ee('EE::API::BoardsResponses') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
feature_category :boards
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
before do
|
|
|
|
authenticate!
|
|
|
|
end
|
|
|
|
|
|
|
|
helpers do
|
|
|
|
def board_parent
|
|
|
|
user_group
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a group'
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2018-03-27 19:54:05 +05:30
|
|
|
segment ':id/boards' do
|
|
|
|
desc 'Find a group board' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success ::API::Entities::Board
|
|
|
|
end
|
|
|
|
get '/:board_id' do
|
2020-03-09 13:42:32 +05:30
|
|
|
authorize!(:read_board, user_group)
|
2018-03-27 19:54:05 +05:30
|
|
|
present board, with: ::API::Entities::Board
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get all group boards' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success Entities::Board
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get '/' do
|
2020-03-09 13:42:32 +05:30
|
|
|
authorize!(:read_board, user_group)
|
2019-09-30 21:07:59 +05:30
|
|
|
present paginate(board_parent.boards.with_associations), with: Entities::Board
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :board_id, type: Integer, desc: 'The ID of a board'
|
|
|
|
end
|
|
|
|
segment ':id/boards/:board_id' do
|
|
|
|
desc 'Get the lists of a group board' do
|
|
|
|
detail 'Does not include backlog and closed lists. This feature was introduced in 10.6'
|
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get '/lists' do
|
2020-03-09 13:42:32 +05:30
|
|
|
authorize!(:read_board, user_group)
|
2018-03-27 19:54:05 +05:30
|
|
|
present paginate(board_lists), with: Entities::List
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get a list of a group board' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :list_id, type: Integer, desc: 'The ID of a list'
|
|
|
|
end
|
|
|
|
get '/lists/:list_id' do
|
2020-03-09 13:42:32 +05:30
|
|
|
authorize!(:read_board, user_group)
|
2018-03-27 19:54:05 +05:30
|
|
|
present board_lists.find(params[:list_id]), with: Entities::List
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Create a new board list' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
2018-11-18 11:00:15 +05:30
|
|
|
use :list_creation_params
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
post '/lists' do
|
2018-11-18 11:00:15 +05:30
|
|
|
authorize_list_type_resource!
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
authorize!(:admin_list, user_group)
|
|
|
|
|
|
|
|
create_list
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Moves a board list to a new position' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :list_id, type: Integer, desc: 'The ID of a list'
|
|
|
|
requires :position, type: Integer, desc: 'The position of the list'
|
|
|
|
end
|
|
|
|
put '/lists/:list_id' do
|
|
|
|
list = board_lists.find(params[:list_id])
|
|
|
|
|
|
|
|
authorize!(:admin_list, user_group)
|
|
|
|
|
|
|
|
move_list(list)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Delete a board list' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :list_id, type: Integer, desc: 'The ID of a board list'
|
|
|
|
end
|
|
|
|
delete "/lists/:list_id" do
|
|
|
|
authorize!(:admin_list, user_group)
|
|
|
|
list = board_lists.find(params[:list_id])
|
|
|
|
|
|
|
|
destroy_list(list)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|