Commit f6cd7adb authored by Mathieu Parent's avatar Mathieu Parent Committed by Heinrich Lee Yu

Move "Update a group board API" endpoint to Core

The corresponding WebUI is already in Core.
parent d6ec8b7b
---
title: Expose hide_backlog_list and hide_closed_list to project and group boards REST API
merge_request: 49815
author: Mathieu Parent
type: added
......@@ -279,7 +279,7 @@ Example response:
}
```
## Update a group issue board **(PREMIUM)**
## Update a group issue board
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/5954) in GitLab 11.1.
......@@ -289,15 +289,17 @@ Updates a Group Issue Board.
PUT /groups/:id/boards/:board_id
```
| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user |
| `board_id` | integer | yes | The ID of a board |
| `name` | string | no | The new name of the board |
| `assignee_id` | integer | no | The assignee the board should be scoped to |
| `milestone_id` | integer | no | The milestone the board should be scoped to |
| `labels` | string | no | Comma-separated list of label names which the board should be scoped to |
| `weight` | integer | no | The weight range from 0 to 9, to which the board should be scoped to |
| Attribute | Type | Required | Description |
| ---------------------------- | -------------- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user |
| `board_id` | integer | yes | The ID of a board |
| `name` | string | no | The new name of the board |
| `hide_backlog_list` | boolean | no | Hide the Open list |
| `hide_closed_list` | boolean | no | Hide the Closed list |
| `assignee_id` **(PREMIUM)** | integer | no | The assignee the board should be scoped to |
| `milestone_id` **(PREMIUM)** | integer | no | The milestone the board should be scoped to |
| `labels` **(PREMIUM)** | string | no | Comma-separated list of label names which the board should be scoped to |
| `weight` **(PREMIUM)** | integer | no | The weight range from 0 to 9, to which the board should be scoped to |
```shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/boards/1?name=new_name&milestone_id=44&assignee_id=1&labels=GroupLabel&weight=4"
......
......@@ -16,9 +16,7 @@ module EE
exactly_one_of :label_id, :milestone_id, :iteration_id, :assignee_id
end
# Overrides API::BoardsResponses update_params
params :update_params do
optional :name, type: String, desc: 'The board name'
params :update_params_ee do
optional :assignee_id, type: Integer, desc: 'The ID of a user to associate with board'
optional :milestone_id, type: Integer, desc: 'The ID of a milestone to associate with board'
optional :labels, type: String, desc: 'Comma-separated list of label names'
......
......@@ -39,19 +39,6 @@ module EE
create_board
end
desc 'Update a group board' do
detail 'This feature was introduced in 11.0'
success ::API::Entities::Board
end
params do
use :update_params
end
put '/:board_id' do
authorize!(:admin_board, board_parent)
update_board
end
desc 'Delete a group board' do
detail 'This feature was introduced in 10.4'
success ::API::Entities::Board
......
......@@ -7,10 +7,10 @@ module API
prepend_if_ee('EE::API::BoardsResponses') # rubocop: disable Cop/InjectEnterpriseEditionModule
before { authenticate! }
feature_category :boards
before { authenticate! }
helpers do
def board_parent
user_project
......
......@@ -80,10 +80,20 @@ module API
requires :label_id, type: Integer, desc: 'The ID of an existing label'
end
params :update_params do
params :update_params_ce do
optional :name, type: String, desc: 'The board name'
optional :hide_backlog_list, type: Grape::API::Boolean, desc: 'Hide the Open list'
optional :hide_closed_list, type: Grape::API::Boolean, desc: 'Hide the Closed list'
end
params :update_params_ee do
# Configurable issue boards are not available in CE/EE Core.
# https://docs.gitlab.com/ee/user/project/issue_board.html#configurable-issue-boards
optional :name, type: String, desc: 'The board name'
end
params :update_params do
use :update_params_ce
use :update_params_ee
end
end
end
......
......@@ -5,6 +5,8 @@ module API
class Board < Grape::Entity
expose :id
expose :name
expose :hide_backlog_list
expose :hide_closed_list
expose :project, using: Entities::BasicProjectDetails
expose :lists, using: Entities::List do |board|
......
......@@ -9,9 +9,7 @@ module API
feature_category :boards
before do
authenticate!
end
before { authenticate! }
helpers do
def board_parent
......@@ -22,28 +20,40 @@ module API
params do
requires :id, type: String, desc: 'The ID of a group'
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do
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
authorize!(:read_board, user_group)
present paginate(board_parent.boards.with_associations), with: Entities::Board
end
desc 'Find a group board' do
detail 'This feature was introduced in 10.6'
success ::API::Entities::Board
success Entities::Board
end
get '/:board_id' do
authorize!(:read_board, user_group)
present board, with: ::API::Entities::Board
present board, with: Entities::Board
end
desc 'Get all group boards' do
detail 'This feature was introduced in 10.6'
desc 'Update a group board' do
detail 'This feature was introduced in 11.0'
success Entities::Board
end
params do
use :pagination
use :update_params
end
get '/' do
authorize!(:read_board, user_group)
present paginate(board_parent.boards.with_associations), with: Entities::Board
put '/:board_id' do
authorize!(:admin_board, board_parent)
update_board
end
end
......
......@@ -53,17 +53,6 @@ RSpec.describe API::Boards do
end
end
describe "PUT /projects/:id/boards/:board_id" do
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}" }
it 'updates the issue board' do
put api(url, user), params: { name: 'changed board name' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('changed board name')
end
end
describe "DELETE /projects/:id/boards/:board_id" do
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}" }
......
......@@ -44,16 +44,35 @@ RSpec.shared_examples 'group and project boards' do |route_definition, ee = fals
expect_schema_match_for(response, 'public_api/v4/boards', ee)
end
end
end
describe "GET #{route_definition}/:board_id" do
let(:url) { "#{root_url}/#{board.id}" }
describe "GET #{route_definition}/:board_id" do
let(:url) { "#{root_url}/#{board.id}" }
it 'get a single board by id' do
get api(url, user)
it 'get a single board by id' do
get api(url, user)
expect_schema_match_for(response, 'public_api/v4/board', ee)
end
end
expect_schema_match_for(response, 'public_api/v4/board', ee)
end
end
describe "PUT #{route_definition}/:board_id" do
let(:url) { "#{root_url}/#{board.id}" }
it 'updates the board name' do
put api(url, user), params: { name: 'changed board name' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('changed board name')
end
it 'updates the issue board booleans' do
put api(url, user), params: { hide_backlog_list: true, hide_closed_list: true }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['hide_backlog_list']).to eq(true)
expect(json_response['hide_closed_list']).to eq(true)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment