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>2022-04-20 13:00:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /app/graphql/mutations
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/ci/job/retry.rb18
-rw-r--r--app/graphql/mutations/ci/pipeline/cancel.rb2
-rw-r--r--app/graphql/mutations/environments/canary_ingress/update.rb13
-rw-r--r--app/graphql/mutations/notes/update/note.rb3
-rw-r--r--app/graphql/mutations/saved_replies/base.rb2
-rw-r--r--app/graphql/mutations/saved_replies/destroy.rb23
-rw-r--r--app/graphql/mutations/saved_replies/update.rb2
-rw-r--r--app/graphql/mutations/todos/mark_all_done.rb29
-rw-r--r--app/graphql/mutations/user_preferences/update.rb17
-rw-r--r--app/graphql/mutations/work_items/create.rb2
-rw-r--r--app/graphql/mutations/work_items/create_from_task.rb2
-rw-r--r--app/graphql/mutations/work_items/delete.rb2
-rw-r--r--app/graphql/mutations/work_items/update.rb2
13 files changed, 101 insertions, 16 deletions
diff --git a/app/graphql/mutations/ci/job/retry.rb b/app/graphql/mutations/ci/job/retry.rb
index 9af357ab216..50e9c51c9e7 100644
--- a/app/graphql/mutations/ci/job/retry.rb
+++ b/app/graphql/mutations/ci/job/retry.rb
@@ -17,11 +17,19 @@ module Mutations
job = authorized_find!(id: id)
project = job.project
- ::Ci::RetryBuildService.new(project, current_user).execute(job)
- {
- job: job,
- errors: errors_on_object(job)
- }
+ response = ::Ci::RetryJobService.new(project, current_user).execute(job)
+
+ if response.success?
+ {
+ job: response[:job],
+ errors: []
+ }
+ else
+ {
+ job: nil,
+ errors: [response.message]
+ }
+ end
end
end
end
diff --git a/app/graphql/mutations/ci/pipeline/cancel.rb b/app/graphql/mutations/ci/pipeline/cancel.rb
index 3fb34a37cfc..3ec6eee9f54 100644
--- a/app/graphql/mutations/ci/pipeline/cancel.rb
+++ b/app/graphql/mutations/ci/pipeline/cancel.rb
@@ -13,6 +13,8 @@ module Mutations
if pipeline.cancelable?
pipeline.cancel_running
+ pipeline.cancel
+
{ success: true, errors: [] }
else
{ success: false, errors: ['Pipeline is not cancelable'] }
diff --git a/app/graphql/mutations/environments/canary_ingress/update.rb b/app/graphql/mutations/environments/canary_ingress/update.rb
index e4ba08e6dcc..ce24b8842c6 100644
--- a/app/graphql/mutations/environments/canary_ingress/update.rb
+++ b/app/graphql/mutations/environments/canary_ingress/update.rb
@@ -5,6 +5,7 @@ module Mutations
module CanaryIngress
class Update < ::Mutations::BaseMutation
graphql_name 'EnvironmentsCanaryIngressUpdate'
+ description '**Deprecated** This endpoint is planned to be removed along with certificate-based clusters. [See this epic](https://gitlab.com/groups/gitlab-org/configure/-/epics/8) for more information.'
authorize :update_environment
@@ -18,7 +19,13 @@ module Mutations
required: true,
description: 'Weight of the Canary Ingress.'
+ REMOVAL_ERR_MSG = 'This endpoint was deactivated as part of the certificate-based' \
+ 'kubernetes integration removal. See Epic:' \
+ 'https://gitlab.com/groups/gitlab-org/configure/-/epics/8'
+
def resolve(id:, **kwargs)
+ return { errors: [REMOVAL_ERR_MSG] } if cert_based_clusters_ff_disabled?
+
environment = authorized_find!(id: id)
result = ::Environments::CanaryIngress::UpdateService
@@ -33,6 +40,12 @@ module Mutations
id = ::Types::GlobalIDType[::Environment].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
+
+ private
+
+ def cert_based_clusters_ff_disabled?
+ Feature.disabled?(:certificate_based_clusters, default_enabled: :yaml, type: :ops)
+ end
end
end
end
diff --git a/app/graphql/mutations/notes/update/note.rb b/app/graphql/mutations/notes/update/note.rb
index c7ee0148f94..a483294169f 100644
--- a/app/graphql/mutations/notes/update/note.rb
+++ b/app/graphql/mutations/notes/update/note.rb
@@ -15,7 +15,8 @@ module Mutations
argument :confidential,
GraphQL::Types::Boolean,
required: false,
- description: 'Confidentiality flag of a note. Default is false.'
+ description: 'Confidentiality flag of a note. Default is false.',
+ deprecated: { reason: 'No longer allowed to update confidentiality of notes', milestone: '14.10' }
private
diff --git a/app/graphql/mutations/saved_replies/base.rb b/app/graphql/mutations/saved_replies/base.rb
index 468263b0f9d..59871df687f 100644
--- a/app/graphql/mutations/saved_replies/base.rb
+++ b/app/graphql/mutations/saved_replies/base.rb
@@ -5,7 +5,7 @@ module Mutations
class Base < BaseMutation
field :saved_reply, Types::SavedReplyType,
null: true,
- description: 'Updated saved reply.'
+ description: 'Saved reply after mutation.'
private
diff --git a/app/graphql/mutations/saved_replies/destroy.rb b/app/graphql/mutations/saved_replies/destroy.rb
new file mode 100644
index 00000000000..7cd0f21ad45
--- /dev/null
+++ b/app/graphql/mutations/saved_replies/destroy.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Mutations
+ module SavedReplies
+ class Destroy < Base
+ graphql_name 'SavedReplyDestroy'
+
+ authorize :destroy_saved_replies
+
+ argument :id, Types::GlobalIDType[::Users::SavedReply],
+ required: true,
+ description: copy_field_description(Types::SavedReplyType, :id)
+
+ def resolve(id:)
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless feature_enabled?
+
+ saved_reply = authorized_find!(id)
+ result = ::Users::SavedReplies::DestroyService.new(saved_reply: saved_reply).execute
+ present_result(result)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/saved_replies/update.rb b/app/graphql/mutations/saved_replies/update.rb
index bacc6ceb39e..d9368de7547 100644
--- a/app/graphql/mutations/saved_replies/update.rb
+++ b/app/graphql/mutations/saved_replies/update.rb
@@ -23,7 +23,7 @@ module Mutations
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless feature_enabled?
saved_reply = authorized_find!(id)
- result = ::Users::SavedReplies::UpdateService.new(current_user: current_user, saved_reply: saved_reply, name: name, content: content).execute
+ result = ::Users::SavedReplies::UpdateService.new(saved_reply: saved_reply, name: name, content: content).execute
present_result(result)
end
end
diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb
index 7dd06cc8293..67a822c1067 100644
--- a/app/graphql/mutations/todos/mark_all_done.rb
+++ b/app/graphql/mutations/todos/mark_all_done.rb
@@ -7,14 +7,22 @@ module Mutations
authorize :update_user
+ TodoableID = Types::GlobalIDType[Todoable]
+
+ argument :target_id,
+ TodoableID,
+ required: false,
+ description: "Global ID of the to-do item's parent. Issues, merge requests, designs, and epics are supported. " \
+ "If argument is omitted, all pending to-do items of the current user are marked as done."
+
field :todos, [::Types::TodoType],
null: false,
description: 'Updated to-do items.'
- def resolve
+ def resolve(**args)
authorize!(current_user)
- updated_ids = mark_all_todos_done
+ updated_ids = mark_all_todos_done(**args)
{
todos: Todo.id_in(updated_ids),
@@ -24,10 +32,23 @@ module Mutations
private
- def mark_all_todos_done
+ def mark_all_todos_done(**args)
return [] unless current_user
- todos = TodosFinder.new(current_user).execute
+ finder_params = { state: :pending }
+
+ if args[:target_id].present?
+ target = Gitlab::Graphql::Lazy.force(
+ GitlabSchema.find_by_gid(TodoableID.coerce_isolated_input(args[:target_id]))
+ )
+
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, "Resource not available: #{args[:target_id]}" if target.nil?
+
+ finder_params[:type] = target.class.name
+ finder_params[:target_id] = target.id
+ end
+
+ todos = TodosFinder.new(current_user, finder_params).execute
TodoService.new.resolve_todos(todos, current_user, resolved_by_action: :api_all_done)
end
diff --git a/app/graphql/mutations/user_preferences/update.rb b/app/graphql/mutations/user_preferences/update.rb
index c92c6d725b7..eface536a87 100644
--- a/app/graphql/mutations/user_preferences/update.rb
+++ b/app/graphql/mutations/user_preferences/update.rb
@@ -14,6 +14,15 @@ module Mutations
null: true,
description: 'User preferences after mutation.'
+ def ready?(**args)
+ if disabled_sort_value?(args)
+ raise Gitlab::Graphql::Errors::ArgumentError,
+ 'Feature flag `incident_escalations` must be enabled to use this sort order.'
+ end
+
+ super
+ end
+
def resolve(**attributes)
user_preferences = current_user.user_preference
user_preferences.update(attributes)
@@ -23,6 +32,14 @@ module Mutations
errors: errors_on_object(user_preferences)
}
end
+
+ private
+
+ def disabled_sort_value?(args)
+ return false unless [:escalation_status_asc, :escalation_status_desc].include?(args[:issues_sort])
+
+ Feature.disabled?(:incident_escalations, default_enabled: :yaml)
+ end
end
end
end
diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb
index 48f0f470988..c29dbb899b5 100644
--- a/app/graphql/mutations/work_items/create.rb
+++ b/app/graphql/mutations/work_items/create.rb
@@ -33,7 +33,7 @@ module Mutations
def resolve(project_path:, **attributes)
project = authorized_find!(project_path)
- unless Feature.enabled?(:work_items, project, default_enabled: :yaml)
+ unless project.work_items_feature_flag_enabled?
return { errors: ['`work_items` feature flag disabled for this project'] }
end
diff --git a/app/graphql/mutations/work_items/create_from_task.rb b/app/graphql/mutations/work_items/create_from_task.rb
index 16d1e646167..278c1bc65a9 100644
--- a/app/graphql/mutations/work_items/create_from_task.rb
+++ b/app/graphql/mutations/work_items/create_from_task.rb
@@ -31,7 +31,7 @@ module Mutations
def resolve(id:, work_item_data:)
work_item = authorized_find!(id: id)
- unless Feature.enabled?(:work_items, work_item.project, default_enabled: :yaml)
+ unless work_item.project.work_items_feature_flag_enabled?
return { errors: ['`work_items` feature flag disabled for this project'] }
end
diff --git a/app/graphql/mutations/work_items/delete.rb b/app/graphql/mutations/work_items/delete.rb
index f32354878ec..3d72ebbd95d 100644
--- a/app/graphql/mutations/work_items/delete.rb
+++ b/app/graphql/mutations/work_items/delete.rb
@@ -20,7 +20,7 @@ module Mutations
def resolve(id:)
work_item = authorized_find!(id: id)
- unless Feature.enabled?(:work_items, work_item.project, default_enabled: :yaml)
+ unless work_item.project.work_items_feature_flag_enabled?
return { errors: ['`work_items` feature flag disabled for this project'] }
end
diff --git a/app/graphql/mutations/work_items/update.rb b/app/graphql/mutations/work_items/update.rb
index 2700cbdb709..091237d6fa0 100644
--- a/app/graphql/mutations/work_items/update.rb
+++ b/app/graphql/mutations/work_items/update.rb
@@ -28,7 +28,7 @@ module Mutations
def resolve(id:, **attributes)
work_item = authorized_find!(id: id)
- unless Feature.enabled?(:work_items, work_item.project, default_enabled: :yaml)
+ unless work_item.project.work_items_feature_flag_enabled?
return { errors: ['`work_items` feature flag disabled for this project'] }
end