Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f47d1a39
Commit
f47d1a39
authored
Aug 07, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mutation to update board lists
- Add tests - Update schema - Update docs
parent
88ed3d28
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
344 additions
and
0 deletions
+344
-0
app/graphql/mutations/boards/lists/update.rb
app/graphql/mutations/boards/lists/update.rb
+51
-0
app/graphql/types/mutation_type.rb
app/graphql/types/mutation_type.rb
+1
-0
changelogs/unreleased/229764-graphql-reorder-lists-within-a-board.yml
...nreleased/229764-graphql-reorder-lists-within-a-board.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+46
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+149
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+10
-0
spec/graphql/mutations/boards/lists/update_spec.rb
spec/graphql/mutations/boards/lists/update_spec.rb
+44
-0
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
...equests/api/graphql/mutations/boards/lists/update_spec.rb
+38
-0
No files found.
app/graphql/mutations/boards/lists/update.rb
0 → 100644
View file @
f47d1a39
# frozen_string_literal: true
module
Mutations
module
Boards
module
Lists
class
Update
<
BaseMutation
graphql_name
'UpdateBoardList'
argument
:list_id
,
GraphQL
::
ID_TYPE
,
required:
true
,
loads:
Types
::
BoardListType
,
description:
'Global ID of the list.'
argument
:position
,
GraphQL
::
INT_TYPE
,
required:
false
,
description:
'Position of list within the board'
argument
:collapsed
,
GraphQL
::
BOOLEAN_TYPE
,
required:
false
,
description:
'Indicates if list is collapsed for this user'
field
:list
,
Types
::
BoardListType
,
null:
true
,
description:
'Mutated list'
def
resolve
(
list:
nil
,
**
args
)
authorize!
(
list
)
update_result
=
update_list
(
list
,
args
)
{
list:
update_result
[
:list
],
errors:
list
.
errors
.
full_messages
}
end
private
def
update_list
(
list
,
args
)
service
=
::
Boards
::
Lists
::
UpdateService
.
new
(
list
.
board
,
current_user
,
args
)
service
.
execute
(
list
)
end
def
authorize!
(
list
)
raise_resource_not_available_error!
unless
list
raise_resource_not_available_error!
unless
Ability
.
allowed?
(
current_user
,
:admin_list
,
list
.
board
)
end
end
end
end
end
app/graphql/types/mutation_type.rb
View file @
f47d1a39
...
...
@@ -16,6 +16,7 @@ module Types
mount_mutation
Mutations
::
AwardEmojis
::
Toggle
mount_mutation
Mutations
::
Boards
::
Issues
::
IssueMoveList
mount_mutation
Mutations
::
Boards
::
Lists
::
Create
mount_mutation
Mutations
::
Boards
::
Lists
::
Update
mount_mutation
Mutations
::
Branches
::
Create
,
calls_gitaly:
true
mount_mutation
Mutations
::
Commits
::
Create
,
calls_gitaly:
true
mount_mutation
Mutations
::
Discussions
::
ToggleResolve
...
...
changelogs/unreleased/229764-graphql-reorder-lists-within-a-board.yml
0 → 100644
View file @
f47d1a39
---
title
:
Add GraphQL mutation for updating board list position and collapsed/expanded state.
merge_request
:
38942
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
f47d1a39
...
...
@@ -9561,6 +9561,7 @@ type Mutation {
toggleAwardEmoji
(
input
:
ToggleAwardEmojiInput
!):
ToggleAwardEmojiPayload
@
deprecated
(
reason
:
"
Use
awardEmojiToggle
.
Deprecated
in
13.2"
)
updateAlertStatus
(
input
:
UpdateAlertStatusInput
!):
UpdateAlertStatusPayload
updateBoard
(
input
:
UpdateBoardInput
!):
UpdateBoardPayload
updateBoardList
(
input
:
UpdateBoardListInput
!):
UpdateBoardListPayload
updateContainerExpirationPolicy
(
input
:
UpdateContainerExpirationPolicyInput
!):
UpdateContainerExpirationPolicyPayload
updateEpic
(
input
:
UpdateEpicInput
!):
UpdateEpicPayload
...
...
@@ -15573,6 +15574,51 @@ input UpdateBoardInput {
weight
:
Int
}
"""
Autogenerated input type of UpdateBoardList
"""
input
UpdateBoardListInput
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
Indicates
if
list
is
collapsed
for
this
user
"""
collapsed
:
Boolean
"""
Global
ID
of
the
list
.
"""
listId
:
ID
!
"""
Position
of
list
within
the
board
"""
position
:
Int
}
"""
Autogenerated return type of UpdateBoardList
"""
type
UpdateBoardListPayload
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
Errors
encountered
during
execution
of
the
mutation
.
"""
errors
:
[
String
!]!
"""
Mutated
list
"""
list
:
BoardList
}
"""
Autogenerated return type of UpdateBoard
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
f47d1a39
...
...
@@ -28403,6 +28403,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateBoardList",
"description": null,
"args": [
{
"name": "input",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "UpdateBoardListInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "UpdateBoardListPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateContainerExpirationPolicy",
"description": null,
...
...
@@ -45857,6 +45884,128 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "UpdateBoardListInput",
"description": "Autogenerated input type of UpdateBoardList",
"fields": null,
"inputFields": [
{
"name": "listId",
"description": "Global ID of the list.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "position",
"description": "Position of list within the board",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "collapsed",
"description": "Indicates if list is collapsed for this user",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "UpdateBoardListPayload",
"description": "Autogenerated return type of UpdateBoardList",
"fields": [
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "errors",
"description": "Errors encountered during execution of the mutation.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "list",
"description": "Mutated list",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "BoardList",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "UpdateBoardPayload",
doc/api/graphql/reference/index.md
View file @
f47d1a39
...
...
@@ -2305,6 +2305,16 @@ Autogenerated return type of UpdateAlertStatus
|
`issue`
| Issue | The issue created after mutation |
|
`todo`
| Todo | The todo after mutation |
## UpdateBoardListPayload
Autogenerated return type of UpdateBoardList
| Name | Type | Description |
| --- | ---- | ---------- |
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
|
`list`
| BoardList | Mutated list |
## UpdateBoardPayload
Autogenerated return type of UpdateBoard
...
...
spec/graphql/mutations/boards/lists/update_spec.rb
0 → 100644
View file @
f47d1a39
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
Boards
::
Lists
::
Update
do
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:list
,
board:
board
)
}
let
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
current_user
},
field:
nil
)
}
let
(
:list_update_params
)
{
{
position:
1
,
collapsed:
true
}
}
before_all
do
group
.
add_reporter
(
reporter
)
group
.
add_guest
(
guest
)
list
.
update_preferences_for
(
reporter
,
collapsed:
false
)
end
subject
{
mutation
.
resolve
(
list:
list
,
**
list_update_params
)
}
describe
'#resolve'
do
context
'with permission to admin board lists'
do
let
(
:current_user
)
{
reporter
}
it
'updates the list as expected'
do
subject
reloaded_list
=
list
.
reload
expect
(
reloaded_list
.
position
).
to
eq
(
1
)
expect
(
reloaded_list
.
collapsed?
(
current_user
)).
to
eq
(
true
)
end
end
context
'without permission to admin board lists'
do
let
(
:current_user
)
{
guest
}
it
'fails'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
end
spec/requests/api/graphql/mutations/boards/lists/update_spec.rb
0 → 100644
View file @
f47d1a39
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Update of an existing board list'
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
,
position:
0
)
}
let_it_be
(
:list2
)
{
create
(
:list
,
board:
board
)
}
let_it_be
(
:input
)
{
{
list_id:
list
.
to_global_id
.
to_s
,
position:
1
,
collapsed:
true
}
}
let
(
:mutation
)
{
graphql_mutation
(
:update_board_list
,
input
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:update_board_list
)
}
context
'the user is not allowed to admin board lists'
do
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'The resource that you are attempting to access does not exist or you don\'t have permission to perform this action'
]
end
context
'when user has permissions to admin board lists'
do
before
do
group
.
add_reporter
(
current_user
)
list
.
update_preferences_for
(
current_user
,
collapsed:
false
)
end
it
'updates the list'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'list'
]).
to
include
(
'position'
=>
1
,
'collapsed'
=>
true
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment