Class: Mutations::WorkItems::Export

Inherits:
BaseMutation
  • Object
show all
Includes:
FindsProject, SearchArguments, WorkItems::SharedFilterArguments
Defined in:
app/graphql/mutations/work_items/export.rb

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from SearchArguments

#ready?

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#check_export_available_for!(project) ⇒ Object



45
46
47
48
49
50
51
# File 'app/graphql/mutations/work_items/export.rb', line 45

def check_export_available_for!(project)
  return if Feature.enabled?(:import_export_work_items_csv, project)

  error = '`import_export_work_items_csv` feature flag is disabled.'

  raise Gitlab::Graphql::Errors::ResourceNotAvailable, error
end

#resolve(args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/graphql/mutations/work_items/export.rb', line 28

def resolve(args)
  project_path = args.delete(:project_path)
  project = authorized_find!(project_path)

  check_export_available_for!(project)

  # rubocop:disable CodeReuse/Worker
  IssuableExportCsvWorker.perform_async(:work_item, current_user.id, project.id, args)
  # rubocop:enable CodeReuse/Worker

  {
    message: format(_('Your CSV export request has succeeded. The result will be emailed to %{email}.'),
      email: current_user.notification_email_or_default),
    errors: []
  }
end