2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-19 14:06:16 -05:00
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class GroupBoards < ::API::Base
|
2018-02-19 14:06:16 -05:00
|
|
|
include BoardsResponses
|
|
|
|
include PaginationParams
|
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
prepend_mod_with('API::BoardsResponses') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-10-27 11:13:41 -04:00
|
|
|
feature_category :team_planning
|
2022-05-13 11:07:43 -04:00
|
|
|
urgency :low
|
2020-10-29 08:08:50 -04:00
|
|
|
|
2021-01-12 07:10:49 -05:00
|
|
|
before { authenticate! }
|
2018-02-19 14:06:16 -05:00
|
|
|
|
|
|
|
helpers do
|
|
|
|
def board_parent
|
|
|
|
user_group
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a group'
|
|
|
|
end
|
2018-11-08 07:18:17 -05:00
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2018-02-19 14:06:16 -05:00
|
|
|
segment ':id/boards' do
|
2021-01-12 07:10:49 -05:00
|
|
|
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
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:read_issue_board, user_group)
|
2021-01-12 07:10:49 -05:00
|
|
|
present paginate(board_parent.boards.with_associations), with: Entities::Board
|
|
|
|
end
|
|
|
|
|
2018-02-19 14:06:16 -05:00
|
|
|
desc 'Find a group board' do
|
|
|
|
detail 'This feature was introduced in 10.6'
|
2021-01-12 07:10:49 -05:00
|
|
|
success Entities::Board
|
2018-02-19 14:06:16 -05:00
|
|
|
end
|
|
|
|
get '/:board_id' do
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:read_issue_board, user_group)
|
2021-01-12 07:10:49 -05:00
|
|
|
present board, with: Entities::Board
|
2018-02-19 14:06:16 -05:00
|
|
|
end
|
|
|
|
|
2021-01-12 07:10:49 -05:00
|
|
|
desc 'Update a group board' do
|
|
|
|
detail 'This feature was introduced in 11.0'
|
2018-02-19 14:06:16 -05:00
|
|
|
success Entities::Board
|
|
|
|
end
|
|
|
|
params do
|
2021-01-12 07:10:49 -05:00
|
|
|
use :update_params
|
2018-02-19 14:06:16 -05:00
|
|
|
end
|
2021-01-12 07:10:49 -05:00
|
|
|
put '/:board_id' do
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:admin_issue_board, board_parent)
|
2021-01-12 07:10:49 -05:00
|
|
|
|
|
|
|
update_board
|
2018-02-19 14:06:16 -05:00
|
|
|
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
|
2018-03-05 09:39:24 -05:00
|
|
|
detail 'Does not include backlog and closed lists. This feature was introduced in 10.6'
|
2018-02-19 14:06:16 -05:00
|
|
|
success Entities::List
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get '/lists' do
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:read_issue_board, user_group)
|
2018-02-19 14:06:16 -05:00
|
|
|
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
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:read_issue_board, user_group)
|
2018-02-19 14:06:16 -05:00
|
|
|
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-08-07 13:29:06 -04:00
|
|
|
use :list_creation_params
|
2018-02-19 14:06:16 -05:00
|
|
|
end
|
|
|
|
post '/lists' do
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:admin_issue_board_list, user_group)
|
2018-02-19 14:06:16 -05:00
|
|
|
|
|
|
|
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])
|
|
|
|
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:admin_issue_board_list, user_group)
|
2018-02-19 14:06:16 -05:00
|
|
|
|
|
|
|
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
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize!(:admin_issue_board_list, user_group)
|
2018-02-19 14:06:16 -05:00
|
|
|
list = board_lists.find(params[:list_id])
|
|
|
|
|
|
|
|
destroy_list(list)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|