 Template.importingFilesItem.hideCancel = ->
   # We keep cancel shown even when canceled is set, until we get back
   # in the file upload method callback and set finished as well
-  @state in ['finished', 'errored']
+  @state in ['finished', 'errored', 'imported']
 
 Template.importingFilesItem.state = ->
-  return 'canceled' if @canceled
+  # Canceled could still be set, but state could be errored
+  # or imported if canceled was set to late in the process,
+  # in which case we want not to display it as canceled
+  return @state if @state in ['errored', 'imported']
+  # But otherwise if state is finished and canceled,
+  # we want to display it as canceled
+  return 'canceled' if @canceled and @state is 'finished'
   return @state
 
 Template.importingFilesItem.publication = ->

  #   importing: file currently being imported
  #   finished: file processing finished successfully, but it
  #             was not imported (import canceled or already exists)
  #   imported: file processing finished successfully and at was imported
  #   errored: file processing errored

  @Meta

# Local (client-only) document of importing files
class @ImportingFile extends BaseDocument
  # name: user's file name
  # status: current status or error message displayed to user
  # readProgress: progress of reading from file, in %
