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')
-rw-r--r--app/graphql/mutations/alert_management/alerts/set_assignees.rb2
-rw-r--r--app/graphql/mutations/alert_management/alerts/todo/create.rb2
-rw-r--r--app/graphql/mutations/alert_management/base.rb18
-rw-r--r--app/graphql/mutations/alert_management/create_alert_issue.rb2
-rw-r--r--app/graphql/mutations/alert_management/update_alert_status.rb2
-rw-r--r--app/graphql/mutations/ci/pipeline_schedule/create.rb72
-rw-r--r--app/graphql/mutations/ci/pipeline_schedule/play.rb32
-rw-r--r--app/graphql/mutations/ci/pipeline_schedule/variable_input_type.rb19
-rw-r--r--app/graphql/mutations/ci/runner/update.rb2
-rw-r--r--app/graphql/mutations/clusters/agent_tokens/create.rb6
-rw-r--r--app/graphql/mutations/container_repositories/destroy.rb4
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/update.rb4
-rw-r--r--app/graphql/mutations/issues/link_alerts.rb26
-rw-r--r--app/graphql/mutations/issues/unlink_alert.rb33
-rw-r--r--app/graphql/mutations/notes/create/diff_note.rb8
-rw-r--r--app/graphql/mutations/notes/create/image_diff_note.rb6
-rw-r--r--app/graphql/mutations/notes/create/note.rb6
-rw-r--r--app/graphql/mutations/timelogs/create.rb8
-rw-r--r--app/graphql/mutations/todos/restore_many.rb6
-rw-r--r--app/graphql/mutations/work_items/create.rb2
20 files changed, 233 insertions, 27 deletions
diff --git a/app/graphql/mutations/alert_management/alerts/set_assignees.rb b/app/graphql/mutations/alert_management/alerts/set_assignees.rb
index c986111d290..500e2b868b1 100644
--- a/app/graphql/mutations/alert_management/alerts/set_assignees.rb
+++ b/app/graphql/mutations/alert_management/alerts/set_assignees.rb
@@ -20,7 +20,7 @@ module Mutations
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
result = set_assignees(alert, args[:assignee_usernames], args[:operation_mode])
- track_usage_event(:incident_management_alert_assigned, current_user.id)
+ track_alert_events('incident_management_alert_assigned', alert)
prepare_response(result)
end
diff --git a/app/graphql/mutations/alert_management/alerts/todo/create.rb b/app/graphql/mutations/alert_management/alerts/todo/create.rb
index 2a1056e8f64..999c0bec5af 100644
--- a/app/graphql/mutations/alert_management/alerts/todo/create.rb
+++ b/app/graphql/mutations/alert_management/alerts/todo/create.rb
@@ -11,7 +11,7 @@ module Mutations
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
result = ::AlertManagement::Alerts::Todo::CreateService.new(alert, current_user).execute
- track_usage_event(:incident_management_alert_todo, current_user.id)
+ track_alert_events('incident_management_alert_todo', alert)
prepare_response(result)
end
diff --git a/app/graphql/mutations/alert_management/base.rb b/app/graphql/mutations/alert_management/base.rb
index d01f200107c..2eef6bb9db7 100644
--- a/app/graphql/mutations/alert_management/base.rb
+++ b/app/graphql/mutations/alert_management/base.rb
@@ -39,6 +39,24 @@ module Mutations
::AlertManagement::AlertsFinder.new(current_user, project, args).execute.first
end
+
+ def track_alert_events(event, alert)
+ project = alert.project
+ namespace = project.namespace
+ track_usage_event(event, current_user.id)
+
+ return unless Feature.enabled?(:route_hll_to_snowplow_phase2, namespace)
+
+ Gitlab::Tracking.event(
+ self.class.to_s,
+ event,
+ project: project,
+ namespace: namespace,
+ user: current_user,
+ label: 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly',
+ context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event).to_context]
+ )
+ end
end
end
end
diff --git a/app/graphql/mutations/alert_management/create_alert_issue.rb b/app/graphql/mutations/alert_management/create_alert_issue.rb
index 77a7d7a4147..7c8de6365e7 100644
--- a/app/graphql/mutations/alert_management/create_alert_issue.rb
+++ b/app/graphql/mutations/alert_management/create_alert_issue.rb
@@ -9,7 +9,7 @@ module Mutations
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
result = create_alert_issue(alert, current_user)
- track_usage_event(:incident_management_incident_created, current_user.id)
+ track_alert_events('incident_management_incident_created', alert)
track_usage_event(:incident_management_alert_create_incident, current_user.id)
prepare_response(alert, result)
diff --git a/app/graphql/mutations/alert_management/update_alert_status.rb b/app/graphql/mutations/alert_management/update_alert_status.rb
index 21566c7d66f..be271a7d795 100644
--- a/app/graphql/mutations/alert_management/update_alert_status.rb
+++ b/app/graphql/mutations/alert_management/update_alert_status.rb
@@ -13,7 +13,7 @@ module Mutations
alert = authorized_find!(project_path: project_path, iid: iid)
result = update_status(alert, status)
- track_usage_event(:incident_management_alert_status_changed, current_user.id)
+ track_alert_events('incident_management_alert_status_changed', alert)
prepare_response(result)
end
diff --git a/app/graphql/mutations/ci/pipeline_schedule/create.rb b/app/graphql/mutations/ci/pipeline_schedule/create.rb
new file mode 100644
index 00000000000..65b355cd80f
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_schedule/create.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module PipelineSchedule
+ class Create < BaseMutation
+ graphql_name 'PipelineScheduleCreate'
+
+ include FindsProject
+
+ authorize :create_pipeline_schedule
+
+ argument :project_path, GraphQL::Types::ID,
+ required: true,
+ description: 'Full path of the project the pipeline schedule is associated with.'
+
+ argument :description, GraphQL::Types::String,
+ required: true,
+ description: 'Description of the pipeline schedule.'
+
+ argument :cron, GraphQL::Types::String,
+ required: true,
+ description: 'Cron expression of the pipeline schedule.'
+
+ argument :cron_timezone, GraphQL::Types::String,
+ required: false,
+ description:
+ <<-STR
+ Cron time zone supported by ActiveSupport::TimeZone.
+ For example: "Pacific Time (US & Canada)" (default: "UTC").
+ STR
+
+ argument :ref, GraphQL::Types::String,
+ required: true,
+ description: 'Ref of the pipeline schedule.'
+
+ argument :active, GraphQL::Types::Boolean,
+ required: false,
+ description: 'Indicates if the pipeline schedule should be active or not.'
+
+ argument :variables, [Mutations::Ci::PipelineSchedule::VariableInputType],
+ required: false,
+ description: 'Variables for the pipeline schedule.'
+
+ field :pipeline_schedule,
+ Types::Ci::PipelineScheduleType,
+ description: 'Created pipeline schedule.'
+
+ def resolve(project_path:, variables: [], **pipeline_schedule_attrs)
+ project = authorized_find!(project_path)
+
+ params = pipeline_schedule_attrs.merge(variables_attributes: variables.map(&:to_h))
+
+ schedule = ::Ci::CreatePipelineScheduleService
+ .new(project, current_user, params)
+ .execute
+
+ unless schedule.persisted?
+ return {
+ pipeline_schedule: nil, errors: schedule.errors.full_messages
+ }
+ end
+
+ {
+ pipeline_schedule: schedule,
+ errors: []
+ }
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/pipeline_schedule/play.rb b/app/graphql/mutations/ci/pipeline_schedule/play.rb
new file mode 100644
index 00000000000..056890852c9
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_schedule/play.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module PipelineSchedule
+ class Play < Base
+ graphql_name 'PipelineSchedulePlay'
+
+ authorize :play_pipeline_schedule
+
+ field :pipeline_schedule,
+ Types::Ci::PipelineScheduleType,
+ null: true,
+ description: 'Pipeline schedule after mutation.'
+
+ def resolve(id:)
+ schedule = authorized_find!(id: id)
+
+ job_id = ::Ci::PipelineScheduleService
+ .new(schedule.project, current_user)
+ .execute(schedule)
+
+ if job_id
+ { pipeline_schedule: schedule, errors: [] }
+ else
+ { pipeline_schedule: nil, errors: ['Unable to schedule a pipeline to run immediately.'] }
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/pipeline_schedule/variable_input_type.rb b/app/graphql/mutations/ci/pipeline_schedule/variable_input_type.rb
new file mode 100644
index 00000000000..54a6ad92448
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_schedule/variable_input_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module PipelineSchedule
+ class VariableInputType < Types::BaseInputObject
+ graphql_name 'PipelineScheduleVariableInput'
+
+ description 'Attributes for the pipeline schedule variable.'
+
+ argument :key, GraphQL::Types::String, required: true, description: 'Name of the variable.'
+
+ argument :value, GraphQL::Types::String, required: true, description: 'Value of the variable.'
+
+ argument :variable_type, Types::Ci::VariableTypeEnum, required: true, description: 'Type of the variable.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb
index 3c99cde60a4..4f0bf19f09c 100644
--- a/app/graphql/mutations/ci/runner/update.rb
+++ b/app/graphql/mutations/ci/runner/update.rb
@@ -54,7 +54,7 @@ module Mutations
argument :associated_projects, [::Types::GlobalIDType[::Project]],
required: false,
description: 'Projects associated with the runner. Available only for project runners.',
- prepare: -> (global_ids, ctx) { global_ids&.filter_map { |gid| gid.model_id.to_i } }
+ prepare: ->(global_ids, ctx) { global_ids&.filter_map { |gid| gid.model_id.to_i } }
field :runner,
Types::Ci::RunnerType,
diff --git a/app/graphql/mutations/clusters/agent_tokens/create.rb b/app/graphql/mutations/clusters/agent_tokens/create.rb
index a99a54fa5ed..c10e1633350 100644
--- a/app/graphql/mutations/clusters/agent_tokens/create.rb
+++ b/app/graphql/mutations/clusters/agent_tokens/create.rb
@@ -49,9 +49,9 @@ module Mutations
payload = result.payload
{
- secret: payload[:secret],
- token: payload[:token],
- errors: Array.wrap(result.message)
+ secret: payload[:secret],
+ token: payload[:token],
+ errors: Array.wrap(result.message)
}
end
diff --git a/app/graphql/mutations/container_repositories/destroy.rb b/app/graphql/mutations/container_repositories/destroy.rb
index fe1c3fe4e61..c3bd7acf444 100644
--- a/app/graphql/mutations/container_repositories/destroy.rb
+++ b/app/graphql/mutations/container_repositories/destroy.rb
@@ -22,10 +22,6 @@ module Mutations
container_repository.delete_scheduled!
- unless Feature.enabled?(:container_registry_delete_repository_with_cron_worker)
- DeleteContainerRepositoryWorker.perform_async(current_user.id, container_repository.id) # rubocop:disable CodeReuse/Worker
- end
-
track_event(:delete_repository, :container)
{
diff --git a/app/graphql/mutations/incident_management/timeline_event/update.rb b/app/graphql/mutations/incident_management/timeline_event/update.rb
index 1f53bdc19cb..b35feed3082 100644
--- a/app/graphql/mutations/incident_management/timeline_event/update.rb
+++ b/app/graphql/mutations/incident_management/timeline_event/update.rb
@@ -18,6 +18,10 @@ module Mutations
required: false,
description: 'Timestamp when the event occurred.'
+ argument :timeline_event_tag_names, [GraphQL::Types::String],
+ required: false,
+ description: copy_field_description(Types::IncidentManagement::TimelineEventType, :timeline_event_tags)
+
def resolve(id:, **args)
timeline_event = authorized_find!(id: id)
diff --git a/app/graphql/mutations/issues/link_alerts.rb b/app/graphql/mutations/issues/link_alerts.rb
new file mode 100644
index 00000000000..c45e90c598f
--- /dev/null
+++ b/app/graphql/mutations/issues/link_alerts.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Issues
+ class LinkAlerts < Base
+ graphql_name 'IssueLinkAlerts'
+
+ argument :alert_references, [GraphQL::Types::String],
+ required: true,
+ description: 'Alerts references to be linked to the incident.'
+
+ authorize :admin_issue
+
+ def resolve(project_path:, iid:, alert_references:)
+ issue = authorized_find!(project_path: project_path, iid: iid)
+
+ ::IncidentManagement::LinkAlerts::CreateService.new(issue, current_user, alert_references).execute
+
+ {
+ issue: issue,
+ errors: errors_on_object(issue)
+ }
+ end
+ end
+ end
+end
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
diff --git a/app/graphql/mutations/notes/create/diff_note.rb b/app/graphql/mutations/notes/create/diff_note.rb
index 7b8c06fd104..df2bd55106e 100644
--- a/app/graphql/mutations/notes/create/diff_note.rb
+++ b/app/graphql/mutations/notes/create/diff_note.rb
@@ -31,10 +31,10 @@ module Mutations
def create_note_params(noteable, args)
super(noteable, args).merge({
- type: 'DiffNote',
- position: position(noteable, args),
- merge_request_diff_head_sha: args[:position][:head_sha]
- })
+ type: 'DiffNote',
+ position: position(noteable, args),
+ merge_request_diff_head_sha: args[:position][:head_sha]
+ })
end
def position(noteable, args)
diff --git a/app/graphql/mutations/notes/create/image_diff_note.rb b/app/graphql/mutations/notes/create/image_diff_note.rb
index d94fd4d6ff8..3de93e4f5c1 100644
--- a/app/graphql/mutations/notes/create/image_diff_note.rb
+++ b/app/graphql/mutations/notes/create/image_diff_note.rb
@@ -15,9 +15,9 @@ module Mutations
def create_note_params(noteable, args)
super(noteable, args).merge({
- type: 'DiffNote',
- position: position(noteable, args)
- })
+ type: 'DiffNote',
+ position: position(noteable, args)
+ })
end
def position(noteable, args)
diff --git a/app/graphql/mutations/notes/create/note.rb b/app/graphql/mutations/notes/create/note.rb
index 4d6f056de09..9b105b7fe1c 100644
--- a/app/graphql/mutations/notes/create/note.rb
+++ b/app/graphql/mutations/notes/create/note.rb
@@ -31,9 +31,9 @@ module Mutations
end
super(noteable, args).merge({
- in_reply_to_discussion_id: discussion_id,
- merge_request_diff_head_sha: args[:merge_request_diff_head_sha]
- })
+ in_reply_to_discussion_id: discussion_id,
+ merge_request_diff_head_sha: args[:merge_request_diff_head_sha]
+ })
end
def authorize_discussion!(discussion)
diff --git a/app/graphql/mutations/timelogs/create.rb b/app/graphql/mutations/timelogs/create.rb
index bab7508454e..1be023eed8a 100644
--- a/app/graphql/mutations/timelogs/create.rb
+++ b/app/graphql/mutations/timelogs/create.rb
@@ -11,7 +11,7 @@ module Mutations
description: 'Amount of time spent.'
argument :spent_at,
- Types::DateType,
+ Types::TimeType,
required: true,
description: 'When the time was spent.'
@@ -28,8 +28,12 @@ module Mutations
authorize :create_timelog
def resolve(issuable_id:, time_spent:, spent_at:, summary:, **args)
- issuable = authorized_find!(id: issuable_id)
parsed_time_spent = Gitlab::TimeTrackingFormatter.parse(time_spent)
+ if parsed_time_spent.nil?
+ return { timelog: nil, errors: [_('Time spent must be formatted correctly. For example: 1h 30m.')] }
+ end
+
+ issuable = authorized_find!(id: issuable_id)
result = ::Timelogs::CreateService.new(
issuable, parsed_time_spent, spent_at, summary, current_user
diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb
index 20913a9e7da..f2f944860c2 100644
--- a/app/graphql/mutations/todos/restore_many.rb
+++ b/app/graphql/mutations/todos/restore_many.rb
@@ -23,9 +23,9 @@ module Mutations
updated_ids = restore(todos)
{
- updated_ids: updated_ids,
- todos: Todo.id_in(updated_ids),
- errors: errors_on_objects(todos)
+ updated_ids: updated_ids,
+ todos: Todo.id_in(updated_ids),
+ errors: errors_on_objects(todos)
}
end
diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb
index 793e5d3caf8..a4efffb69c1 100644
--- a/app/graphql/mutations/work_items/create.rb
+++ b/app/graphql/mutations/work_items/create.rb
@@ -73,3 +73,5 @@ module Mutations
end
end
end
+
+Mutations::WorkItems::Create.prepend_mod