2020-03-31 11:07:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module JiraImport
|
|
|
|
class Start < BaseMutation
|
2021-01-26 13:09:30 -05:00
|
|
|
include FindsProject
|
2020-03-31 11:07:53 -04:00
|
|
|
|
|
|
|
graphql_name 'JiraImportStart'
|
|
|
|
|
2021-01-26 13:09:30 -05:00
|
|
|
authorize :admin_project
|
|
|
|
|
2020-03-31 11:07:53 -04:00
|
|
|
field :jira_import,
|
|
|
|
Types::JiraImportType,
|
|
|
|
null: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The Jira import data after mutation.'
|
2020-03-31 11:07:53 -04:00
|
|
|
|
|
|
|
argument :project_path, GraphQL::ID_TYPE,
|
|
|
|
required: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The project to import the Jira project into.'
|
2020-03-31 11:07:53 -04:00
|
|
|
argument :jira_project_key, GraphQL::STRING_TYPE,
|
|
|
|
required: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'Project key of the importer Jira project.'
|
2020-03-31 11:07:53 -04:00
|
|
|
argument :jira_project_name, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'Project name of the importer Jira project.'
|
2020-06-29 17:09:07 -04:00
|
|
|
argument :users_mapping,
|
|
|
|
[Types::JiraUsersMappingInputType],
|
|
|
|
required: false,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The mapping of Jira to GitLab users.'
|
2020-03-31 11:07:53 -04:00
|
|
|
|
2020-06-29 17:09:07 -04:00
|
|
|
def resolve(project_path:, jira_project_key:, users_mapping:)
|
2021-01-26 13:09:30 -05:00
|
|
|
project = authorized_find!(project_path)
|
2020-06-29 17:09:07 -04:00
|
|
|
mapping = users_mapping.to_ary.map { |map| map.to_hash }
|
2020-03-31 11:07:53 -04:00
|
|
|
|
|
|
|
service_response = ::JiraImport::StartImportService
|
2020-06-29 17:09:07 -04:00
|
|
|
.new(context[:current_user], project, jira_project_key, mapping)
|
2020-03-31 11:07:53 -04:00
|
|
|
.execute
|
2020-04-09 08:09:24 -04:00
|
|
|
jira_import = service_response.success? ? service_response.payload[:import_data] : nil
|
2020-06-08 20:08:47 -04:00
|
|
|
|
2020-03-31 11:07:53 -04:00
|
|
|
{
|
2020-04-09 08:09:24 -04:00
|
|
|
jira_import: jira_import,
|
2020-06-08 20:08:47 -04:00
|
|
|
errors: service_response.errors
|
2020-03-31 11:07:53 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|