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-06-08 18:08:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-08 18:08:20 +0300
commit5693fb6ba7d21ba7b79775543a3f195eb989664b (patch)
treea9038b20872f0f3bd35de034bfb40e533435bfa5 /app/graphql
parentf149549c3432ffb179f6904e4ba0ea64027202d0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/mutations/jira_import/import_users.rb44
-rw-r--r--app/graphql/types/jira_user_type.rb19
-rw-r--r--app/graphql/types/mutation_type.rb1
3 files changed, 64 insertions, 0 deletions
diff --git a/app/graphql/mutations/jira_import/import_users.rb b/app/graphql/mutations/jira_import/import_users.rb
new file mode 100644
index 00000000000..c7225e1a99c
--- /dev/null
+++ b/app/graphql/mutations/jira_import/import_users.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+module Mutations
+ module JiraImport
+ class ImportUsers < BaseMutation
+ include ResolvesProject
+
+ graphql_name 'JiraImportUsers'
+
+ field :jira_users,
+ [Types::JiraUserType],
+ null: true,
+ description: 'Users returned from Jira, matched by email and name if possible.'
+
+ argument :project_path, GraphQL::ID_TYPE,
+ required: true,
+ description: 'The project to import the Jira users into'
+ argument :start_at, GraphQL::INT_TYPE,
+ required: false,
+ description: 'The index of the record the import should started at, default 0 (50 records returned)'
+
+ def resolve(project_path:, start_at:)
+ project = authorized_find!(full_path: project_path)
+
+ service_response = ::JiraImport::UsersImporter.new(context[:current_user], project, start_at).execute
+
+ {
+ jira_users: service_response.payload,
+ errors: service_response.errors
+ }
+ end
+
+ private
+
+ 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/jira_user_type.rb b/app/graphql/types/jira_user_type.rb
new file mode 100644
index 00000000000..8aa21ce669b
--- /dev/null
+++ b/app/graphql/types/jira_user_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ # Authorization is at project level for owners or admins on mutation level
+ class JiraUserType < BaseObject
+ graphql_name 'JiraUser'
+
+ field :jira_account_id, GraphQL::STRING_TYPE, null: false,
+ description: 'Account id of the Jira user'
+ field :jira_display_name, GraphQL::STRING_TYPE, null: false,
+ description: 'Display name of the Jira user'
+ field :jira_email, GraphQL::STRING_TYPE, null: true,
+ description: 'Email of the Jira user, returned only for users with public emails'
+ field :gitlab_id, GraphQL::INT_TYPE, null: true,
+ description: 'Id of the matched GitLab user'
+ end
+ # rubocop: enable Graphql/AuthorizeTypes
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index a1dee351475..8d4368cc30a 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -48,6 +48,7 @@ module Types
mount_mutation Mutations::Snippets::Create
mount_mutation Mutations::Snippets::MarkAsSpam
mount_mutation Mutations::JiraImport::Start
+ mount_mutation Mutations::JiraImport::ImportUsers
mount_mutation Mutations::DesignManagement::Upload, calls_gitaly: true
mount_mutation Mutations::DesignManagement::Delete, calls_gitaly: true
mount_mutation Mutations::ContainerExpirationPolicies::Update