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>2020-09-19 04:45:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/graphql/mutations
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
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.rb1
-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/award_emojis/toggle.rb2
-rw-r--r--app/graphql/mutations/base_mutation.rb4
-rw-r--r--app/graphql/mutations/boards/destroy.rb37
-rw-r--r--app/graphql/mutations/boards/issues/issue_move_list.rb8
-rw-r--r--app/graphql/mutations/boards/lists/base.rb2
-rw-r--r--app/graphql/mutations/boards/lists/create.rb9
-rw-r--r--app/graphql/mutations/ci/base.rb17
-rw-r--r--app/graphql/mutations/ci/pipeline_cancel.rb22
-rw-r--r--app/graphql/mutations/ci/pipeline_destroy.rb22
-rw-r--r--app/graphql/mutations/ci/pipeline_retry.rb27
-rw-r--r--app/graphql/mutations/concerns/mutations/authorizes_project.rb17
-rw-r--r--app/graphql/mutations/design_management/move.rb4
-rw-r--r--app/graphql/mutations/issues/set_severity.rb25
-rw-r--r--app/graphql/mutations/merge_requests/set_wip.rb4
-rw-r--r--app/graphql/mutations/metrics/dashboard/annotations/delete.rb2
-rw-r--r--app/graphql/mutations/snippets/create.rb13
-rw-r--r--app/graphql/mutations/snippets/update.rb13
22 files changed, 208 insertions, 29 deletions
diff --git a/app/graphql/mutations/alert_management/alerts/set_assignees.rb b/app/graphql/mutations/alert_management/alerts/set_assignees.rb
index 1e0c9fdeeaf..517c20a85d0 100644
--- a/app/graphql/mutations/alert_management/alerts/set_assignees.rb
+++ b/app/graphql/mutations/alert_management/alerts/set_assignees.rb
@@ -20,6 +20,8 @@ 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)
+
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 3dba96e43f1..2a1056e8f64 100644
--- a/app/graphql/mutations/alert_management/alerts/todo/create.rb
+++ b/app/graphql/mutations/alert_management/alerts/todo/create.rb
@@ -11,6 +11,8 @@ 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)
+
prepare_response(result)
end
diff --git a/app/graphql/mutations/alert_management/base.rb b/app/graphql/mutations/alert_management/base.rb
index 0de4b9409e4..0ccfcf34180 100644
--- a/app/graphql/mutations/alert_management/base.rb
+++ b/app/graphql/mutations/alert_management/base.rb
@@ -3,6 +3,7 @@
module Mutations
module AlertManagement
class Base < BaseMutation
+ include Gitlab::Utils::UsageData
include ResolvesProject
argument :project_path, GraphQL::ID_TYPE,
diff --git a/app/graphql/mutations/alert_management/create_alert_issue.rb b/app/graphql/mutations/alert_management/create_alert_issue.rb
index adb048a4479..2ddb94700c2 100644
--- a/app/graphql/mutations/alert_management/create_alert_issue.rb
+++ b/app/graphql/mutations/alert_management/create_alert_issue.rb
@@ -9,6 +9,8 @@ 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)
+
prepare_response(alert, result)
end
diff --git a/app/graphql/mutations/alert_management/update_alert_status.rb b/app/graphql/mutations/alert_management/update_alert_status.rb
index ed61555fbd6..1e14bae048a 100644
--- a/app/graphql/mutations/alert_management/update_alert_status.rb
+++ b/app/graphql/mutations/alert_management/update_alert_status.rb
@@ -13,6 +13,8 @@ module Mutations
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
result = update_status(alert, args[:status])
+ track_usage_event(:incident_management_alert_status_changed, current_user.id)
+
prepare_response(result)
end
diff --git a/app/graphql/mutations/award_emojis/toggle.rb b/app/graphql/mutations/award_emojis/toggle.rb
index a7714e695d2..679ec7a14ff 100644
--- a/app/graphql/mutations/award_emojis/toggle.rb
+++ b/app/graphql/mutations/award_emojis/toggle.rb
@@ -5,7 +5,7 @@ module Mutations
class Toggle < Base
graphql_name 'AwardEmojiToggle'
- field :toggledOn, GraphQL::BOOLEAN_TYPE, null: false,
+ field :toggled_on, GraphQL::BOOLEAN_TYPE, null: false,
description: 'Indicates the status of the emoji. ' \
'True if the toggle awarded the emoji, and false if the toggle removed the emoji.'
diff --git a/app/graphql/mutations/base_mutation.rb b/app/graphql/mutations/base_mutation.rb
index 68e7853a9b1..577f10545b3 100644
--- a/app/graphql/mutations/base_mutation.rb
+++ b/app/graphql/mutations/base_mutation.rb
@@ -17,6 +17,10 @@ module Mutations
context[:current_user]
end
+ def api_user?
+ context[:is_sessionless_user]
+ end
+
# Returns Array of errors on an ActiveRecord object
def errors_on_object(record)
record.errors.full_messages
diff --git a/app/graphql/mutations/boards/destroy.rb b/app/graphql/mutations/boards/destroy.rb
new file mode 100644
index 00000000000..7c381113d38
--- /dev/null
+++ b/app/graphql/mutations/boards/destroy.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Boards
+ class Destroy < ::Mutations::BaseMutation
+ graphql_name 'DestroyBoard'
+
+ field :board,
+ Types::BoardType,
+ null: true,
+ description: 'The board after mutation'
+ argument :id,
+ ::Types::GlobalIDType[::Board],
+ required: true,
+ description: 'The global ID of the board to destroy'
+
+ authorize :admin_board
+
+ def resolve(id:)
+ board = authorized_find!(id: id)
+
+ response = ::Boards::DestroyService.new(board.resource_parent, current_user).execute(board)
+
+ {
+ board: response.success? ? nil : board,
+ errors: response.errors
+ }
+ end
+
+ private
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::Board)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/boards/issues/issue_move_list.rb b/app/graphql/mutations/boards/issues/issue_move_list.rb
index d4bf47af4cf..813b6d3cb2a 100644
--- a/app/graphql/mutations/boards/issues/issue_move_list.rb
+++ b/app/graphql/mutations/boards/issues/issue_move_list.rb
@@ -29,11 +29,11 @@ module Mutations
argument :move_before_id, GraphQL::ID_TYPE,
required: false,
- description: 'ID of issue before which the current issue will be positioned at'
+ description: 'ID of issue that should be placed before the current issue'
argument :move_after_id, GraphQL::ID_TYPE,
required: false,
- description: 'ID of issue after which the current issue will be positioned at'
+ description: 'ID of issue that should be placed after the current issue'
def ready?(**args)
if move_arguments(args).blank?
@@ -50,6 +50,8 @@ module Mutations
end
def resolve(board:, **args)
+ Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/247861')
+
raise_resource_not_available_error! unless board
authorize_board!(board)
@@ -89,3 +91,5 @@ module Mutations
end
end
end
+
+Mutations::Boards::Issues::IssueMoveList.prepend_if_ee('EE::Mutations::Boards::Issues::IssueMoveList')
diff --git a/app/graphql/mutations/boards/lists/base.rb b/app/graphql/mutations/boards/lists/base.rb
index 34b271ba3b8..d244d6bf8dd 100644
--- a/app/graphql/mutations/boards/lists/base.rb
+++ b/app/graphql/mutations/boards/lists/base.rb
@@ -8,7 +8,7 @@ module Mutations
argument :board_id, ::Types::GlobalIDType[::Board],
required: true,
- description: 'The Global ID of the issue board to mutate'
+ description: 'Global ID of the issue board to mutate'
field :list,
Types::BoardListType,
diff --git a/app/graphql/mutations/boards/lists/create.rb b/app/graphql/mutations/boards/lists/create.rb
index 4f545709ee9..3fe1052315f 100644
--- a/app/graphql/mutations/boards/lists/create.rb
+++ b/app/graphql/mutations/boards/lists/create.rb
@@ -12,7 +12,7 @@ module Mutations
argument :label_id, ::Types::GlobalIDType[::Label],
required: false,
- description: 'ID of an existing label'
+ description: 'Global ID of an existing label'
def ready?(**args)
if args.slice(*mutually_exclusive_args).size != 1
@@ -39,6 +39,7 @@ module Mutations
private
+ # Overridden in EE
def authorize_list_type_resource!(board, params)
return unless params[:label_id]
@@ -57,13 +58,15 @@ module Mutations
create_list_service.execute(board)
end
+ # Overridden in EE
def create_list_params(args)
params = args.slice(*mutually_exclusive_args).with_indifferent_access
- params[:label_id] = GitlabSchema.parse_gid(params[:label_id]).model_id if params[:label_id]
+ params[:label_id] &&= ::GitlabSchema.parse_gid(params[:label_id], expected_type: ::Label).model_id
params
end
+ # Overridden in EE
def mutually_exclusive_args
[:backlog, :label_id]
end
@@ -71,3 +74,5 @@ module Mutations
end
end
end
+
+Mutations::Boards::Lists::Create.prepend_if_ee('::EE::Mutations::Boards::Lists::Create')
diff --git a/app/graphql/mutations/ci/base.rb b/app/graphql/mutations/ci/base.rb
new file mode 100644
index 00000000000..09df4487a50
--- /dev/null
+++ b/app/graphql/mutations/ci/base.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ class Base < BaseMutation
+ argument :id, ::Types::GlobalIDType[::Ci::Pipeline],
+ required: true,
+ description: 'The id of the pipeline to mutate'
+
+ private
+
+ def find_object(id:)
+ GlobalID::Locator.locate(id)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/pipeline_cancel.rb b/app/graphql/mutations/ci/pipeline_cancel.rb
new file mode 100644
index 00000000000..bc881e2ac02
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_cancel.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ class PipelineCancel < Base
+ graphql_name 'PipelineCancel'
+
+ authorize :update_pipeline
+
+ def resolve(id:)
+ pipeline = authorized_find!(id: id)
+
+ if pipeline.cancelable?
+ pipeline.cancel_running
+ { success: true, errors: [] }
+ else
+ { success: false, errors: ['Pipeline is not cancelable'] }
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/pipeline_destroy.rb b/app/graphql/mutations/ci/pipeline_destroy.rb
new file mode 100644
index 00000000000..bb24d416583
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_destroy.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ class PipelineDestroy < Base
+ graphql_name 'PipelineDestroy'
+
+ authorize :destroy_pipeline
+
+ def resolve(id:)
+ pipeline = authorized_find!(id: id)
+ project = pipeline.project
+
+ result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
+ {
+ success: result.success?,
+ errors: result.errors
+ }
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/pipeline_retry.rb b/app/graphql/mutations/ci/pipeline_retry.rb
new file mode 100644
index 00000000000..0669bfc449c
--- /dev/null
+++ b/app/graphql/mutations/ci/pipeline_retry.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ class PipelineRetry < Base
+ graphql_name 'PipelineRetry'
+
+ field :pipeline,
+ Types::Ci::PipelineType,
+ null: true,
+ description: 'The pipeline after mutation'
+
+ authorize :update_pipeline
+
+ def resolve(id:)
+ pipeline = authorized_find!(id: id)
+ project = pipeline.project
+
+ ::Ci::RetryPipelineService.new(project, current_user).execute(pipeline)
+ {
+ pipeline: pipeline,
+ errors: errors_on_object(pipeline)
+ }
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/concerns/mutations/authorizes_project.rb b/app/graphql/mutations/concerns/mutations/authorizes_project.rb
new file mode 100644
index 00000000000..87341525d6c
--- /dev/null
+++ b/app/graphql/mutations/concerns/mutations/authorizes_project.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Mutations
+ module AuthorizesProject
+ include ResolvesProject
+
+ def authorized_find_project!(full_path:)
+ authorized_find!(full_path: full_path)
+ end
+
+ private
+
+ def find_object(full_path:)
+ resolve_project(full_path: full_path)
+ end
+ end
+end
diff --git a/app/graphql/mutations/design_management/move.rb b/app/graphql/mutations/design_management/move.rb
index 0b654447844..6126af8b68b 100644
--- a/app/graphql/mutations/design_management/move.rb
+++ b/app/graphql/mutations/design_management/move.rb
@@ -20,10 +20,6 @@ module Mutations
null: true,
description: "The current state of the collection"
- def ready(*)
- raise ::Gitlab::Graphql::Errors::ResourceNotAvailable unless ::Feature.enabled?(:reorder_designs, default_enabled: true)
- end
-
def resolve(**args)
service = ::DesignManagement::MoveDesignsService.new(current_user, parameters(args))
diff --git a/app/graphql/mutations/issues/set_severity.rb b/app/graphql/mutations/issues/set_severity.rb
new file mode 100644
index 00000000000..bc386e07178
--- /dev/null
+++ b/app/graphql/mutations/issues/set_severity.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Issues
+ class SetSeverity < Base
+ graphql_name 'IssueSetSeverity'
+
+ argument :severity, Types::IssuableSeverityEnum, required: true,
+ description: 'Set the incident severity level.'
+
+ def resolve(project_path:, iid:, severity:)
+ issue = authorized_find!(project_path: project_path, iid: iid)
+ project = issue.project
+
+ ::Issues::UpdateService.new(project, current_user, severity: severity)
+ .execute(issue)
+
+ {
+ issue: issue,
+ errors: errors_on_object(issue)
+ }
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/merge_requests/set_wip.rb b/app/graphql/mutations/merge_requests/set_wip.rb
index 5d2077c12f2..0b5c20de377 100644
--- a/app/graphql/mutations/merge_requests/set_wip.rb
+++ b/app/graphql/mutations/merge_requests/set_wip.rb
@@ -9,8 +9,8 @@ module Mutations
GraphQL::BOOLEAN_TYPE,
required: true,
description: <<~DESC
- Whether or not to set the merge request as a WIP.
- DESC
+ Whether or not to set the merge request as a WIP.
+ DESC
def resolve(project_path:, iid:, wip: nil)
merge_request = authorized_find!(project_path: project_path, iid: iid)
diff --git a/app/graphql/mutations/metrics/dashboard/annotations/delete.rb b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb
index fb828ba0e2f..6e183e78d9b 100644
--- a/app/graphql/mutations/metrics/dashboard/annotations/delete.rb
+++ b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb
@@ -12,7 +12,7 @@ module Mutations
argument :id,
GraphQL::ID_TYPE,
required: true,
- description: 'The global id of the annotation to delete'
+ description: 'The global ID of the annotation to delete'
def resolve(id:)
annotation = authorized_find!(id: id)
diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb
index a068fd806f5..a8aeb15afcd 100644
--- a/app/graphql/mutations/snippets/create.rb
+++ b/app/graphql/mutations/snippets/create.rb
@@ -16,14 +16,6 @@ module Mutations
required: true,
description: 'Title of the snippet'
- argument :file_name, GraphQL::STRING_TYPE,
- required: false,
- description: 'File name of the snippet'
-
- argument :content, GraphQL::STRING_TYPE,
- required: false,
- description: 'Content of the snippet'
-
argument :description, GraphQL::STRING_TYPE,
required: false,
description: 'Description of the snippet'
@@ -59,6 +51,11 @@ module Mutations
snippet = service_response.payload[:snippet]
+ # Only when the user is not an api user and the operation was successful
+ if !api_user? && service_response.success?
+ ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user)
+ end
+
{
snippet: service_response.success? ? snippet : nil,
errors: errors_on_object(snippet)
diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb
index 6ff632ec008..d0db5fa2eb9 100644
--- a/app/graphql/mutations/snippets/update.rb
+++ b/app/graphql/mutations/snippets/update.rb
@@ -14,14 +14,6 @@ module Mutations
required: false,
description: 'Title of the snippet'
- argument :file_name, GraphQL::STRING_TYPE,
- required: false,
- description: 'File name of the snippet'
-
- argument :content, GraphQL::STRING_TYPE,
- required: false,
- description: 'Content of the snippet'
-
argument :description, GraphQL::STRING_TYPE,
required: false,
description: 'Description of the snippet'
@@ -42,6 +34,11 @@ module Mutations
update_params(args)).execute(snippet)
snippet = result.payload[:snippet]
+ # Only when the user is not an api user and the operation was successful
+ if !api_user? && result.success?
+ ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user)
+ end
+
{
snippet: result.success? ? snippet : snippet.reset,
errors: errors_on_object(snippet)