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>2023-02-20 16:49:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 16:49:51 +0300
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/services/work_items/export_csv_service.rb
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/services/work_items/export_csv_service.rb')
-rw-r--r--app/services/work_items/export_csv_service.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/services/work_items/export_csv_service.rb b/app/services/work_items/export_csv_service.rb
new file mode 100644
index 00000000000..9bef75e2c40
--- /dev/null
+++ b/app/services/work_items/export_csv_service.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module WorkItems
+ class ExportCsvService < ExportCsv::BaseService
+ NotAvailableError = StandardError.new('This feature is currently behind a feature flag and it is not available.')
+
+ def csv_data
+ raise NotAvailableError unless Feature.enabled?(:import_export_work_items_csv, resource_parent)
+
+ super
+ end
+
+ def email(mail_to_user)
+ # TODO - will be implemented as part of https://gitlab.com/gitlab-org/gitlab/-/issues/379082
+ end
+
+ private
+
+ def associations_to_preload
+ [:work_item_type, :author]
+ end
+
+ def header_to_value_hash
+ {
+ 'Id' => 'iid',
+ 'Title' => 'title',
+ 'Type' => ->(work_item) { work_item.work_item_type.name },
+ 'Author' => 'author_name',
+ 'Author Username' => ->(work_item) { work_item.author.username },
+ 'Created At (UTC)' => ->(work_item) { work_item.created_at.to_s(:csv) }
+ }
+ end
+ end
+end