summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 15:07:53 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 15:07:53 +0000
commitd7a028e20d29b8c6d0e780ac168544dfbb712d3c (patch)
treef9fc9ea12e166aec6c4ffe476ba7a3566396b696 /app/graphql
parent0d0cddc9ce20c5a7d8a2723d0aa620ca184a711a (diff)
downloadgitlab-ce-d7a028e20d29b8c6d0e780ac168544dfbb712d3c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/mutations/jira_import/start.rb58
-rw-r--r--app/graphql/types/mutation_type.rb1
2 files changed, 59 insertions, 0 deletions
diff --git a/app/graphql/mutations/jira_import/start.rb b/app/graphql/mutations/jira_import/start.rb
new file mode 100644
index 00000000000..ffd3ce53b57
--- /dev/null
+++ b/app/graphql/mutations/jira_import/start.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+module Mutations
+ module JiraImport
+ class Start < BaseMutation
+ include Mutations::ResolvesProject
+
+ graphql_name 'JiraImportStart'
+
+ field :jira_import,
+ Types::JiraImportType,
+ null: true,
+ description: 'The Jira import data after mutation'
+
+ argument :project_path, GraphQL::ID_TYPE,
+ required: true,
+ description: 'The project to import the Jira project into'
+ argument :jira_project_key, GraphQL::STRING_TYPE,
+ required: true,
+ description: 'Project key of the importer Jira project'
+ argument :jira_project_name, GraphQL::STRING_TYPE,
+ required: false,
+ description: 'Project name of the importer Jira project'
+
+ def resolve(project_path:, jira_project_key:)
+ project = find_project!(project_path: project_path)
+
+ raise_resource_not_available_error! unless project
+
+ service_response = ::JiraImport::StartImportService
+ .new(context[:current_user], project, jira_project_key)
+ .execute
+ import_data = service_response.payload[:import_data]
+
+ {
+ jira_import: import_data.errors.blank? ? import_data.projects.last : nil,
+ errors: errors_on_object(import_data)
+ }
+ end
+
+ private
+
+ def find_project!(project_path:)
+ return unless project_path.present?
+
+ authorized_find!(full_path: project_path)
+ end
+
+ def find_object(full_path:)
+ resolve_project(full_path: full_path)
+ end
+
+ def authorized_resource?(project)
+ Ability.allowed?(context[:current_user], :admin_project, project)
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index d3c0d9732d2..ab25d5baf71 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -39,6 +39,7 @@ module Types
mount_mutation Mutations::Snippets::Update
mount_mutation Mutations::Snippets::Create
mount_mutation Mutations::Snippets::MarkAsSpam
+ mount_mutation Mutations::JiraImport::Start
end
end