Przeglądaj źródła

Dashboard: Log warning instead of an error when trigger is not found (#2144)

* Log warning instead of an error when trigger is not found

* Only issue warning if opts.trigger is not set
Artur Paikin 5 lat temu
rodzic
commit
7021657459
1 zmienionych plików z 7 dodań i 7 usunięć
  1. 7 7
      packages/@uppy/dashboard/src/index.js

+ 7 - 7
packages/@uppy/dashboard/src/index.js

@@ -609,13 +609,13 @@ module.exports = class Dashboard extends Plugin {
 
   initEvents () {
     // Modal open button
-    const showModalTrigger = findAllDOMElements(this.opts.trigger)
-    if (!this.opts.inline && showModalTrigger) {
-      showModalTrigger.forEach(trigger => trigger.addEventListener('click', this.openModal))
-    }
-
-    if (!this.opts.inline && !showModalTrigger) {
-      this.uppy.log('Dashboard modal trigger not found. Make sure `trigger` is set in Dashboard options unless you are planning to call openModal() method yourself', 'error')
+    if (this.opts.trigger && !this.opts.inline) {
+      const showModalTrigger = findAllDOMElements(this.opts.trigger)
+      if (showModalTrigger) {
+        showModalTrigger.forEach(trigger => trigger.addEventListener('click', this.openModal))
+      } else {
+        this.uppy.log('Dashboard modal trigger not found. Make sure `trigger` is set in Dashboard options, unless you are planning to call `dashboard.openModal()` method yourself', 'warning')
+      }
     }
 
     this.startListeningToResize()