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/admin/abuse_report_labels/create.rb')
-rw-r--r--app/graphql/mutations/admin/abuse_report_labels/create.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/graphql/mutations/admin/abuse_report_labels/create.rb b/app/graphql/mutations/admin/abuse_report_labels/create.rb
new file mode 100644
index 00000000000..6ec96297da4
--- /dev/null
+++ b/app/graphql/mutations/admin/abuse_report_labels/create.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Admin
+ module AbuseReportLabels
+ class Create < BaseMutation
+ graphql_name 'AbuseReportLabelCreate'
+
+ field :label, Types::LabelType, null: true, description: 'Label after mutation.'
+
+ argument :title, GraphQL::Types::String, required: true, description: 'Title of the label.'
+
+ argument :color, GraphQL::Types::String, required: false, default_value: Label::DEFAULT_COLOR,
+ see: {
+ 'List of color keywords at mozilla.org' =>
+ 'https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords'
+ },
+ description: <<~DESC
+ The color of the label given in 6-digit hex notation with leading '#' sign
+ (for example, `#FFAABB`) or one of the CSS color names.
+ DESC
+
+ def resolve(args)
+ raise_resource_not_available_error! unless current_user.can?(:admin_all_resources)
+
+ label = ::Admin::AbuseReportLabels::CreateService.new(args).execute
+
+ {
+ label: label.persisted? ? label : nil,
+ errors: errors_on_object(label)
+ }
+ end
+ end
+ end
+ end
+end