Feature #35137

Display a message indicating that there is no data

Added by Yuichi HARADA 25 days ago. Updated 21 days ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


It is suggested to display a message indicating that there is no data when trying to import a file that has no data.

message-no-data.png (88.1 KB) Yuichi HARADA, 2021-04-21 06:38

35137.patch Magnifier (2.95 KB) Yuichi HARADA, 2021-04-21 07:06


#1 Updated by Yuichi HARADA 25 days ago

I created a patch. You get a message when you try to import a file that has only a header row.

diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 721d08fa2..2b9edfc31 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -50,7 +50,11 @@ class ImportsController < ApplicationController

   def settings
     if request.post? && @import.parse_file
-      redirect_to import_mapping_path(@import)
+      if @import.total_items == 0
+        flash.now[:error] = l(:error_no_data_import_file)
+      else
+        redirect_to import_mapping_path(@import)
+      end

   rescue CSV::MalformedCSVError, EncodingError => e
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9d779a2fe..c948d40ff 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -223,6 +223,7 @@ en:
   error_invalid_file_encoding: "The file is not a valid %{encoding} encoded file" 
   error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below (%{value})" 
   error_can_not_read_import_file: "An error occurred while reading the file to import" 
+  error_no_data_import_file: "There is no data to import into the file" 
   error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed" 
   error_ldap_bind_credentials: "Invalid LDAP Account/Password" 
   error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue" 

Also available in: Atom PDF