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/issues/unlink_alert.rb')
-rw-r--r--app/graphql/mutations/issues/unlink_alert.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/graphql/mutations/issues/unlink_alert.rb b/app/graphql/mutations/issues/unlink_alert.rb
new file mode 100644
index 00000000000..a11af4133cf
--- /dev/null
+++ b/app/graphql/mutations/issues/unlink_alert.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Issues
+ class UnlinkAlert < Base
+ graphql_name 'IssueUnlinkAlert'
+
+ argument :alert_id, ::Types::GlobalIDType[::AlertManagement::Alert],
+ required: true,
+ description: 'Global ID of the alert to unlink from the incident.'
+
+ authorize :admin_issue
+
+ def resolve(project_path:, iid:, alert_id:)
+ issue = authorized_find!(project_path: project_path, iid: iid)
+ alert = find_alert_by_gid(alert_id)
+
+ result = ::IncidentManagement::LinkAlerts::DestroyService.new(issue, current_user, alert).execute
+
+ {
+ issue: issue,
+ errors: result.errors
+ }
+ end
+
+ private
+
+ def find_alert_by_gid(alert_id)
+ ::Gitlab::Graphql::Lazy.force(GitlabSchema.object_from_id(alert_id, expected_type: ::AlertManagement::Alert))
+ end
+ end
+ end
+end