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>2023-01-18 22:00:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 22:00:14 +0300
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/graphql/mutations
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/achievements/create.rb54
-rw-r--r--app/graphql/mutations/boards/lists/base_update.rb2
-rw-r--r--app/graphql/mutations/ci/job/play.rb12
-rw-r--r--app/graphql/mutations/ci/project_ci_cd_settings_update.rb2
-rw-r--r--app/graphql/mutations/clusters/agents/create.rb2
-rw-r--r--app/graphql/mutations/commits/create.rb2
-rw-r--r--app/graphql/mutations/concerns/mutations/work_items/widgetable.rb2
-rw-r--r--app/graphql/mutations/jira_import/start.rb2
-rw-r--r--app/graphql/mutations/members/groups/bulk_update.rb85
-rw-r--r--app/graphql/mutations/merge_requests/accept.rb4
-rw-r--r--app/graphql/mutations/notes/create/note.rb2
-rw-r--r--app/graphql/mutations/packages/bulk_destroy.rb5
-rw-r--r--app/graphql/mutations/releases/create.rb2
13 files changed, 161 insertions, 15 deletions
diff --git a/app/graphql/mutations/achievements/create.rb b/app/graphql/mutations/achievements/create.rb
new file mode 100644
index 00000000000..6cfe6c0e643
--- /dev/null
+++ b/app/graphql/mutations/achievements/create.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Achievements
+ class Create < BaseMutation
+ graphql_name 'AchievementsCreate'
+
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
+ field :achievement,
+ ::Types::Achievements::AchievementType,
+ null: true,
+ description: 'Achievement created.'
+
+ argument :namespace_id, ::Types::GlobalIDType[::Namespace],
+ required: true,
+ description: 'Namespace for the achievement.'
+
+ argument :name, GraphQL::Types::String,
+ required: true,
+ description: 'Name for the achievement.'
+
+ argument :avatar, ApolloUploadServer::Upload,
+ required: false,
+ description: 'Avatar for the achievement.'
+
+ argument :description, GraphQL::Types::String,
+ required: false,
+ description: 'Description of or notes for the achievement.'
+
+ argument :revokeable, GraphQL::Types::Boolean,
+ required: true,
+ description: 'Revokeability for the achievement.'
+
+ authorize :admin_achievement
+
+ def resolve(args)
+ namespace = authorized_find!(id: args[:namespace_id])
+
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, '`achievements` feature flag is disabled.' \
+ if Feature.disabled?(:achievements, namespace)
+
+ result = ::Achievements::CreateService.new(namespace: namespace,
+ current_user: current_user,
+ params: args).execute
+ { achievement: result.payload, errors: result.errors }
+ end
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::Namespace)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/boards/lists/base_update.rb b/app/graphql/mutations/boards/lists/base_update.rb
index 7962d9c85d4..c6e6b1c9bfe 100644
--- a/app/graphql/mutations/boards/lists/base_update.rb
+++ b/app/graphql/mutations/boards/lists/base_update.rb
@@ -10,7 +10,7 @@ module Mutations
argument :collapsed, GraphQL::Types::Boolean,
required: false,
- description: 'Indicates if the list is collapsed for this user.'
+ description: 'Indicates if the list is collapsed for the user.'
def resolve(list: nil, **args)
if list.nil? || !can_read_list?(list)
diff --git a/app/graphql/mutations/ci/job/play.rb b/app/graphql/mutations/ci/job/play.rb
index 99f62ea3e70..8bb69119a44 100644
--- a/app/graphql/mutations/ci/job/play.rb
+++ b/app/graphql/mutations/ci/job/play.rb
@@ -11,13 +11,21 @@ module Mutations
null: true,
description: 'Job after the mutation.'
+ argument :variables, [::Types::Ci::VariableInputType],
+ required: false,
+ default_value: [],
+ replace_null_with_default: true,
+ description: 'Variables to use when playing a manual job.'
+
authorize :update_build
- def resolve(id:)
+ def resolve(id:, variables:)
job = authorized_find!(id: id)
project = job.project
+ variables = variables.map(&:to_h)
+
+ ::Ci::PlayBuildService.new(project, current_user).execute(job, variables)
- ::Ci::PlayBuildService.new(project, current_user).execute(job)
{
job: job,
errors: errors_on_object(job)
diff --git a/app/graphql/mutations/ci/project_ci_cd_settings_update.rb b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb
index 27b066ffcf6..934d62e92cf 100644
--- a/app/graphql/mutations/ci/project_ci_cd_settings_update.rb
+++ b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb
@@ -15,7 +15,7 @@ module Mutations
argument :keep_latest_artifact, GraphQL::Types::Boolean,
required: false,
- description: 'Indicates if the latest artifact should be kept for this project.'
+ description: 'Indicates if the latest artifact should be kept for the project.'
argument :job_token_scope_enabled, GraphQL::Types::Boolean,
required: false,
diff --git a/app/graphql/mutations/clusters/agents/create.rb b/app/graphql/mutations/clusters/agents/create.rb
index deaa9c2d656..8be1e0e524a 100644
--- a/app/graphql/mutations/clusters/agents/create.rb
+++ b/app/graphql/mutations/clusters/agents/create.rb
@@ -12,7 +12,7 @@ module Mutations
argument :project_path, GraphQL::Types::ID,
required: true,
- description: 'Full path of the associated project for this cluster agent.'
+ description: 'Full path of the associated project for the cluster agent.'
argument :name, GraphQL::Types::String,
required: true,
diff --git a/app/graphql/mutations/commits/create.rb b/app/graphql/mutations/commits/create.rb
index 00ec64becc8..02e1e4c78bf 100644
--- a/app/graphql/mutations/commits/create.rb
+++ b/app/graphql/mutations/commits/create.rb
@@ -58,7 +58,7 @@ module Mutations
commit_message: message,
branch_name: branch,
start_branch: args[:start_branch] || branch,
- actions: actions.map { |action| action.to_h }
+ actions: actions.map(&:to_h)
}
result = ::Files::MultiService.new(project, current_user, attributes).execute
diff --git a/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb b/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb
index 445b2eb6441..508e1627032 100644
--- a/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb
+++ b/app/graphql/mutations/concerns/mutations/work_items/widgetable.rb
@@ -18,7 +18,7 @@ module Mutations
# Cannot use prepare to use `.to_h` on each input due to
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87472#note_945199865
- widget_params.transform_values { |values| values.to_h }
+ widget_params.transform_values(&:to_h)
end
end
end
diff --git a/app/graphql/mutations/jira_import/start.rb b/app/graphql/mutations/jira_import/start.rb
index ea071c45bcf..2ba20e163a5 100644
--- a/app/graphql/mutations/jira_import/start.rb
+++ b/app/graphql/mutations/jira_import/start.rb
@@ -30,7 +30,7 @@ module Mutations
def resolve(project_path:, jira_project_key:, users_mapping:)
project = authorized_find!(project_path)
- mapping = users_mapping.to_ary.map { |map| map.to_hash }
+ mapping = users_mapping.to_ary.map(&:to_hash)
service_response = ::JiraImport::StartImportService
.new(context[:current_user], project, jira_project_key, mapping)
diff --git a/app/graphql/mutations/members/groups/bulk_update.rb b/app/graphql/mutations/members/groups/bulk_update.rb
new file mode 100644
index 00000000000..d0b19bd9634
--- /dev/null
+++ b/app/graphql/mutations/members/groups/bulk_update.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Members
+ module Groups
+ class BulkUpdate < ::Mutations::BaseMutation
+ graphql_name 'GroupMemberBulkUpdate'
+
+ include Gitlab::Utils::StrongMemoize
+
+ authorize :admin_group_member
+
+ field :group_members,
+ [Types::GroupMemberType],
+ null: true,
+ description: 'Group members after mutation.'
+
+ argument :group_id,
+ ::Types::GlobalIDType[::Group],
+ required: true,
+ description: 'Global ID of the group.'
+
+ argument :user_ids,
+ [::Types::GlobalIDType[::User]],
+ required: true,
+ description: 'Global IDs of the group members.'
+
+ argument :access_level,
+ ::Types::MemberAccessLevelEnum,
+ required: true,
+ description: 'Access level to update the members to.'
+
+ argument :expires_at,
+ Types::TimeType,
+ required: false,
+ description: 'Date and time the membership expires.'
+
+ MAX_MEMBERS_UPDATE_LIMIT = 50
+ MAX_MEMBERS_UPDATE_ERROR = "Count of members to be updated should be less than #{MAX_MEMBERS_UPDATE_LIMIT}."
+ INVALID_MEMBERS_ERROR = 'Only access level of direct members can be updated.'
+
+ def resolve(group_id:, **args)
+ result = ::Members::UpdateService.new(current_user, args.except(:user_ids)).execute(@updatable_group_members)
+
+ {
+ group_members: result[:members],
+ errors: Array.wrap(result[:message])
+ }
+ rescue Gitlab::Access::AccessDeniedError
+ {
+ errors: ["Unable to update members, please check user permissions."]
+ }
+ end
+
+ private
+
+ def ready?(**args)
+ group = authorized_find!(group_id: args[:group_id])
+ user_ids = args.fetch(:user_ids, {}).map(&:model_id)
+ @updatable_group_members = only_direct_group_members(group, user_ids)
+
+ if @updatable_group_members.size > MAX_MEMBERS_UPDATE_LIMIT
+ raise Gitlab::Graphql::Errors::InvalidMemberCountError, MAX_MEMBERS_UPDATE_ERROR
+ end
+
+ if @updatable_group_members.size != user_ids.size
+ raise Gitlab::Graphql::Errors::InvalidMembersError, INVALID_MEMBERS_ERROR
+ end
+
+ super
+ end
+
+ def find_object(group_id:)
+ GitlabSchema.object_from_id(group_id, expected_type: ::Group)
+ end
+
+ def only_direct_group_members(group, user_ids)
+ group
+ .members
+ .with_user(user_ids).to_a
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/merge_requests/accept.rb b/app/graphql/mutations/merge_requests/accept.rb
index ebd9e2b8fdd..64572091379 100644
--- a/app/graphql/mutations/merge_requests/accept.rb
+++ b/app/graphql/mutations/merge_requests/accept.rb
@@ -21,14 +21,14 @@ module Mutations
::Types::MergeStrategyEnum,
required: false,
as: :auto_merge_strategy,
- description: 'How to merge this merge request.'
+ description: 'How to merge the merge request.'
argument :commit_message, ::GraphQL::Types::String,
required: false,
description: 'Custom merge commit message.'
argument :sha, ::GraphQL::Types::String,
required: true,
- description: 'HEAD SHA at the time when this merge was requested.'
+ description: 'HEAD SHA at the time when the merge was requested.'
argument :squash_commit_message, ::GraphQL::Types::String,
required: false,
description: 'Custom squash commit message (if squash is true).'
diff --git a/app/graphql/mutations/notes/create/note.rb b/app/graphql/mutations/notes/create/note.rb
index 9b105b7fe1c..0f1be32d088 100644
--- a/app/graphql/mutations/notes/create/note.rb
+++ b/app/graphql/mutations/notes/create/note.rb
@@ -10,7 +10,7 @@ module Mutations
argument :discussion_id,
::Types::GlobalIDType[::Discussion],
required: false,
- description: 'Global ID of the discussion this note is in reply to.'
+ description: 'Global ID of the discussion the note is in reply to.'
argument :merge_request_diff_head_sha,
GraphQL::Types::String,
diff --git a/app/graphql/mutations/packages/bulk_destroy.rb b/app/graphql/mutations/packages/bulk_destroy.rb
index a0756d0c3f9..86f8de91e2b 100644
--- a/app/graphql/mutations/packages/bulk_destroy.rb
+++ b/app/graphql/mutations/packages/bulk_destroy.rb
@@ -16,11 +16,10 @@ module Mutations
def resolve(ids:)
raise_resource_not_available_error!(TOO_MANY_IDS_ERROR) if ids.size > MAX_PACKAGES
- ids = GitlabSchema.parse_gids(ids, expected_type: ::Packages::Package)
- .map(&:model_id)
+ model_ids = ids.map(&:model_id)
service = ::Packages::MarkPackagesForDestructionService.new(
- packages: packages_from(ids),
+ packages: packages_from(model_ids),
current_user: current_user
)
result = service.execute
diff --git a/app/graphql/mutations/releases/create.rb b/app/graphql/mutations/releases/create.rb
index ba1fa8d446c..15175aea9a5 100644
--- a/app/graphql/mutations/releases/create.rb
+++ b/app/graphql/mutations/releases/create.rb
@@ -30,7 +30,7 @@ module Mutations
required: false,
description: 'Description (also known as "release notes") of the release.'
- argument :released_at, Types::TimeType,
+ argument :released_at, Types::TimeType, # rubocop:disable Graphql/Descriptions
required: false,
description: 'Date and time for the release. Defaults to the current time. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). Only provide this field if creating an upcoming or historical release.'