Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/boards/lists/update.rb')
-rw-r--r--app/graphql/mutations/boards/lists/update.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/graphql/mutations/boards/lists/update.rb b/app/graphql/mutations/boards/lists/update.rb
new file mode 100644
index 00000000000..7efed3058b3
--- /dev/null
+++ b/app/graphql/mutations/boards/lists/update.rb
@@ -0,0 +1,52 @@
+# 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)
+ raise_resource_not_available_error! unless can_read_list?(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 can_read_list?(list)
+ return false unless list.present?
+
+ Ability.allowed?(current_user, :read_list, list.board)
+ end
+ end
+ end
+ end
+end