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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-15 03:06:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-15 03:06:05 +0300
commit386e5740f68fc7f49bc7692a28e927d6ea5ab056 (patch)
tree36c74aefd8101dbf439e11ba9bf1c0cf45f0ff16 /app/graphql/mutations
parentb1ffdbb7f92407ceef575e557af07a3e3d067edf (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/merge_requests/set_assignees.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/graphql/mutations/merge_requests/set_assignees.rb b/app/graphql/mutations/merge_requests/set_assignees.rb
new file mode 100644
index 00000000000..8f0025f0a58
--- /dev/null
+++ b/app/graphql/mutations/merge_requests/set_assignees.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+module Mutations
+ module MergeRequests
+ class SetAssignees < Base
+ graphql_name 'MergeRequestSetAssignees'
+
+ argument :assignee_usernames,
+ [GraphQL::STRING_TYPE],
+ required: true,
+ description: <<~DESC
+ The usernames to assign to the merge request. Replaces existing assignees by default.
+ DESC
+
+ argument :operation_mode,
+ Types::MutationOperationModeEnum,
+ required: false,
+ description: <<~DESC
+ The operation to perform. Defaults to REPLACE.
+ DESC
+
+ def resolve(project_path:, iid:, assignee_usernames:, operation_mode: Types::MutationOperationModeEnum.enum[:replace])
+ Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/issues/36098')
+
+ merge_request = authorized_find!(project_path: project_path, iid: iid)
+ project = merge_request.project
+
+ assignee_ids = []
+ assignee_ids += merge_request.assignees.map(&:id) if Types::MutationOperationModeEnum.enum.values_at(:remove, :append).include?(operation_mode)
+ user_ids = UsersFinder.new(current_user, username: assignee_usernames).execute.map(&:id)
+
+ if operation_mode == Types::MutationOperationModeEnum.enum[:remove]
+ assignee_ids -= user_ids
+ else
+ assignee_ids |= user_ids
+ end
+
+ ::MergeRequests::UpdateService.new(project, current_user, assignee_ids: assignee_ids)
+ .execute(merge_request)
+
+ {
+ merge_request: merge_request,
+ errors: merge_request.errors.full_messages
+ }
+ end
+ end
+ end
+end