Преглед на файлове

core: Add noNewAlreadyUploading and noDuplicates (#2057)

* Add noNewAlreadyUploading and noDuplicates

* Update en_US.js

* fix test

* Update index.js

* Update en_US.js
Artur Paikin преди 5 години
родител
ревизия
d0f181caeb
променени са 3 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 4 2
      packages/@uppy/core/src/index.js
  2. 1 1
      packages/@uppy/core/src/index.test.js
  3. 2 0
      packages/@uppy/locales/src/en_US.js

+ 4 - 2
packages/@uppy/core/src/index.js

@@ -51,6 +51,8 @@ class Uppy {
         },
         exceedsSize: 'This file exceeds maximum allowed size of',
         youCanOnlyUploadFileTypes: 'You can only upload: %{types}',
+        noNewAlreadyUploading: 'Cannot add new files: already uploading',
+        noDuplicates: 'Cannot add the duplicate file \'%{fileName}\', it already exists',
         companionError: 'Connection with Companion failed',
         companionAuthError: 'Authorization required',
         companionUnauthorizeHint: 'To unauthorize to your %{provider} account, please go to %{url}',
@@ -488,7 +490,7 @@ class Uppy {
     const { allowNewUpload } = this.getState()
 
     if (allowNewUpload === false) {
-      this._showOrLogErrorAndThrow(new RestrictionError('Cannot add new files: already uploading.'), { file })
+      this._showOrLogErrorAndThrow(new RestrictionError(this.i18n('noNewAlreadyUploading')), { file })
     }
   }
 
@@ -528,7 +530,7 @@ class Uppy {
     const fileID = generateFileID(file)
 
     if (files[fileID]) {
-      this._showOrLogErrorAndThrow(new RestrictionError(`Cannot add the duplicate file '${fileName}', it already exists.`), { file })
+      this._showOrLogErrorAndThrow(new RestrictionError(this.i18n('noDuplicates', { fileName })), { file })
     }
 
     const meta = file.meta || {}

+ 1 - 1
packages/@uppy/core/src/index.test.js

@@ -740,7 +740,7 @@ describe('src/Core', () => {
             data: new File([sampleImage], { type: 'image/jpeg' })
           })
         }).toThrow(
-          /Cannot add new files: already uploading\./
+          /Cannot add new files: already uploading/
         )
       })
 

+ 2 - 0
packages/@uppy/locales/src/en_US.js

@@ -66,8 +66,10 @@ en_US.strings = {
   loading: 'Loading...',
   logOut: 'Log out',
   myDevice: 'My Device',
+  noDuplicates: 'Cannot add the duplicate file \'%{fileName}\', it already exists',
   noFilesFound: 'You have no files or folders here',
   noInternetConnection: 'No Internet connection',
+  noNewAlreadyUploading: 'Cannot add new files: already uploading',
   openFolderNamed: 'Open folder %{name}',
   pause: 'Pause',
   pauseUpload: 'Pause upload',