Prechádzať zdrojové kódy

add uppy.opts.infoTimeout (#2619)

Artur Paikin 4 rokov pred
rodič
commit
f169943664

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

@@ -109,7 +109,8 @@ class Uppy {
       onBeforeFileAdded: (currentFile, files) => currentFile,
       onBeforeUpload: (files) => files,
       store: DefaultStore(),
-      logger: justErrorsLogger
+      logger: justErrorsLogger,
+      infoTimeout: 5000
     }
 
     // Merge default options with the ones set by user,
@@ -543,7 +544,7 @@ class Uppy {
     // Sometimes informer has to be shown manually by the developer,
     // for example, in `onBeforeFileAdded`.
     if (showInformer) {
-      this.info({ message: message, details: details }, 'error', 5000)
+      this.info({ message: message, details: details }, 'error', this.opts.infoTimeout)
     }
 
     if (throwErr) {
@@ -733,7 +734,7 @@ class Uppy {
       this.info({
         message: this.i18n('addBulkFilesFailed', { smart_count: errors.length }),
         details: message
-      }, 'error', 5000)
+      }, 'error', this.opts.infoTimeout)
 
       const err = new Error(message)
       err.errors = errors

+ 1 - 0
packages/@uppy/core/types/index.d.ts

@@ -98,6 +98,7 @@ declare module Uppy {
     }) => { [key: string]: UppyFile<TMeta> } | boolean
     locale?: Locale
     store?: Store
+    infoTimeout?: number
   }
 
   interface UploadResult<

+ 8 - 2
website/src/docs/uppy.md

@@ -86,7 +86,8 @@ const uppy = new Uppy({
   onBeforeUpload: (files) => {},
   locale: {},
   store: new DefaultStore(),
-  logger: justErrorsLogger
+  logger: justErrorsLogger,
+  infoTimeout: 5000
 })
 ```
 
@@ -334,7 +335,6 @@ locale: {
 
 We are using a forked [Polyglot.js](https://github.com/airbnb/polyglot.js/blob/master/index.js#L37-L60).
 
-
 ### `store: defaultStore()`
 
 The Store that is used to keep track of internal state. By [default](/docs/stores/#DefaultStore), a simple object is used.
@@ -343,6 +343,12 @@ This option can be used to plug Uppy state into an external state management lib
 
 <!-- TODO document store API -->
 
+### `infoTimeout`
+
+**default:** 5000
+
+Set the time during which the Informer message will be visible with messages about errors, restrictions, etc.
+
 ## File Objects
 
 Uppy internally uses file objects that abstract over local files and files from remote providers, and that contain additional data like user-specified metadata and upload progress information.