Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/dashboard: propagate setOptions to StatusBar #5260

Open
wants to merge 6 commits into
base: 4.x
Choose a base branch
from
Open

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Jun 18, 2024

mifi added 3 commits June 18, 2024 11:53
(when react props change)

fixes #5248
introduced in 9a213b5
ruse dashboard
Copy link
Contributor

github-actions bot commented Jun 18, 2024

Diff output files
diff --git a/packages/@uppy/dashboard/lib/Dashboard.js b/packages/@uppy/dashboard/lib/Dashboard.js
index 1f2f804..2b4d6d6 100644
--- a/packages/@uppy/dashboard/lib/Dashboard.js
+++ b/packages/@uppy/dashboard/lib/Dashboard.js
@@ -85,6 +85,12 @@ var _getEditors = _classPrivateFieldLooseKey("getEditors");
 var _addSpecifiedPluginsFromOptions = _classPrivateFieldLooseKey("addSpecifiedPluginsFromOptions");
 var _autoDiscoverPlugins = _classPrivateFieldLooseKey("autoDiscoverPlugins");
 var _addSupportedPluginIfNoTarget = _classPrivateFieldLooseKey("addSupportedPluginIfNoTarget");
+var _getStatusBarOpts = _classPrivateFieldLooseKey("getStatusBarOpts");
+var _getThumbnailGeneratorOpts = _classPrivateFieldLooseKey("getThumbnailGeneratorOpts");
+var _getInformerOpts = _classPrivateFieldLooseKey("getInformerOpts");
+var _getStatusBarId = _classPrivateFieldLooseKey("getStatusBarId");
+var _getThumbnailGeneratorId = _classPrivateFieldLooseKey("getThumbnailGeneratorId");
+var _getInformerId = _classPrivateFieldLooseKey("getInformerId");
 export default class Dashboard extends UIPlugin {
   constructor(uppy, _opts) {
     var _opts$autoOpen, _this$opts4, _this$opts4$doneButto, _this$opts5, _this$opts5$onRequest;
@@ -94,6 +100,24 @@ export default class Dashboard extends UIPlugin {
       ..._opts,
       autoOpen,
     });
+    Object.defineProperty(this, _getInformerId, {
+      value: _getInformerId2,
+    });
+    Object.defineProperty(this, _getThumbnailGeneratorId, {
+      value: _getThumbnailGeneratorId2,
+    });
+    Object.defineProperty(this, _getStatusBarId, {
+      value: _getStatusBarId2,
+    });
+    Object.defineProperty(this, _getInformerOpts, {
+      value: _getInformerOpts2,
+    });
+    Object.defineProperty(this, _getThumbnailGeneratorOpts, {
+      value: _getThumbnailGeneratorOpts2,
+    });
+    Object.defineProperty(this, _getStatusBarOpts, {
+      value: _getStatusBarOpts2,
+    });
     Object.defineProperty(this, _disabledNodes, {
       writable: true,
       value: void 0,
@@ -982,32 +1006,22 @@ export default class Dashboard extends UIPlugin {
       }
       if (!this.opts.disableStatusBar) {
         this.uppy.use(StatusBar, {
-          id: `${this.id}:StatusBar`,
+          id: _classPrivateFieldLooseBase(this, _getStatusBarId)[_getStatusBarId](),
           target: this,
-          hideUploadButton: this.opts.hideUploadButton,
-          hideRetryButton: this.opts.hideRetryButton,
-          hidePauseResumeButton: this.opts.hidePauseResumeButton,
-          hideCancelButton: this.opts.hideCancelButton,
-          showProgressDetails: this.opts.showProgressDetails,
-          hideAfterFinish: this.opts.hideProgressAfterFinish,
-          locale: this.opts.locale,
-          doneButtonHandler: this.opts.doneButtonHandler,
+          ..._classPrivateFieldLooseBase(this, _getStatusBarOpts)[_getStatusBarOpts](),
         });
       }
       if (!this.opts.disableInformer) {
         this.uppy.use(Informer, {
-          id: `${this.id}:Informer`,
+          id: _classPrivateFieldLooseBase(this, _getInformerId)[_getInformerId](),
           target: this,
+          ..._classPrivateFieldLooseBase(this, _getInformerOpts)[_getInformerOpts](),
         });
       }
       if (!this.opts.disableThumbnailGenerator) {
         this.uppy.use(ThumbnailGenerator, {
-          id: `${this.id}:ThumbnailGenerator`,
-          thumbnailWidth: this.opts.thumbnailWidth,
-          thumbnailHeight: this.opts.thumbnailHeight,
-          thumbnailType: this.opts.thumbnailType,
-          waitForThumbnailsBeforeUpload: this.opts.waitForThumbnailsBeforeUpload,
-          lazy: !this.opts.waitForThumbnailsBeforeUpload,
+          id: _classPrivateFieldLooseBase(this, _getThumbnailGeneratorId)[_getThumbnailGeneratorId](),
+          ..._classPrivateFieldLooseBase(this, _getThumbnailGeneratorOpts)[_getThumbnailGeneratorOpts](),
         });
       }
       this.darkModeMediaQuery = typeof window !== "undefined" && window.matchMedia
@@ -1069,5 +1083,51 @@ export default class Dashboard extends UIPlugin {
       : _this$opts5.onRequestCloseModal = () => this.closeModal();
     this.i18nInit();
   }
+  setOptions(opts) {
+    var _this$uppy$getPlugin, _this$uppy$getPlugin2;
+    super.setOptions(opts);
+    (_this$uppy$getPlugin = this.uppy.getPlugin(_classPrivateFieldLooseBase(this, _getStatusBarId)[_getStatusBarId]()))
+        == null
+      || _this$uppy$getPlugin.setOptions(_classPrivateFieldLooseBase(this, _getStatusBarOpts)[_getStatusBarOpts]());
+    (_this$uppy$getPlugin2 = this.uppy.getPlugin(
+          _classPrivateFieldLooseBase(this, _getThumbnailGeneratorId)[_getThumbnailGeneratorId](),
+        )) == null
+      || _this$uppy$getPlugin2.setOptions(
+        _classPrivateFieldLooseBase(this, _getThumbnailGeneratorOpts)[_getThumbnailGeneratorOpts](),
+      );
+  }
+}
+function _getStatusBarOpts2() {
+  return {
+    hideUploadButton: this.opts.hideUploadButton,
+    hideRetryButton: this.opts.hideRetryButton,
+    hidePauseResumeButton: this.opts.hidePauseResumeButton,
+    hideCancelButton: this.opts.hideCancelButton,
+    showProgressDetails: this.opts.showProgressDetails,
+    hideAfterFinish: this.opts.hideProgressAfterFinish,
+    locale: this.opts.locale,
+    doneButtonHandler: this.opts.doneButtonHandler,
+  };
+}
+function _getThumbnailGeneratorOpts2() {
+  return {
+    thumbnailWidth: this.opts.thumbnailWidth,
+    thumbnailHeight: this.opts.thumbnailHeight,
+    thumbnailType: this.opts.thumbnailType,
+    waitForThumbnailsBeforeUpload: this.opts.waitForThumbnailsBeforeUpload,
+    lazy: !this.opts.waitForThumbnailsBeforeUpload,
+  };
+}
+function _getInformerOpts2() {
+  return {};
+}
+function _getStatusBarId2() {
+  return `${this.id}:StatusBar`;
+}
+function _getThumbnailGeneratorId2() {
+  return `${this.id}:ThumbnailGenerator`;
+}
+function _getInformerId2() {
+  return `${this.id}:Informer`;
 }
 Dashboard.VERSION = packageJson.version;
diff --git a/packages/@uppy/react/lib/nonHtmlPropsHaveChanged.js b/packages/@uppy/react/lib/nonHtmlPropsHaveChanged.js
index 57e0cdf..1d6700a 100644
--- a/packages/@uppy/react/lib/nonHtmlPropsHaveChanged.js
+++ b/packages/@uppy/react/lib/nonHtmlPropsHaveChanged.js
@@ -1,3 +1,5 @@
+import getHTMLProps from "./getHTMLProps";
 export default function nonHtmlPropsHaveChanged(props, prevProps) {
-  return Object.keys(props).some(key => !Object.hasOwn(props, key) && props[key] !== prevProps[key]);
+  const htmlProps = getHTMLProps(props);
+  return Object.keys(props).some(key => !Object.hasOwn(htmlProps, key) && props[key] !== prevProps[key]);
 }

Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking it up quickly

packages/@uppy/dashboard/src/Dashboard.tsx Show resolved Hide resolved
const [i, setI] = useState(0);

// https://github.com/transloadit/uppy/issues/5248
const handleDoneButtonClick = useCallback(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in e2e instead? We already have a react client there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimally yes it should 😇

Comment on lines +16 to +40
case '/dashboard.html': {
const restrictions = undefined
// const restrictions = { requiredMetaFields: ['caption'], maxNumberOfFiles: 3 }

const uppy = DashboardUppy({ restrictions })
.use(Dashboard, {
trigger: '#pick-files',
// inline: true,
target: '.foo',
metaFields: [
{ id: 'license', name: 'License', placeholder: 'specify license' },
{ id: 'caption', name: 'Caption', placeholder: 'add caption' },
],
showProgressDetails: true,
proudlyDisplayPoweredByUppy: true,
note: `${JSON.stringify(restrictions)}`,
})
.use(Form, { target: '#upload-form' })

window.uppy = uppy

const modalTrigger = document.querySelector('#pick-files')
if (modalTrigger) modalTrigger.click()
}
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why define uppy and its plugins both in index and the route files? I expect this to only link to the app file, not define it in two places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by the route files?

I wanted to reuse uppy initialisation with all dev env variables and logic between react (React.jsx) and non-react (index.js). but for react we cannot uppy.use(Dashboard) so I pulled that out and instead do it only here in non-react (index.js). (and modalTrigger is not appliccable for react either, as well as window.uppy = uppy).

@Murderlon Murderlon changed the title React fixes @uppy/dashboard: propagate setOptions to StatusBar Jun 18, 2024
Comment on lines +1301 to +1310
return {
hideUploadButton: this.opts.hideUploadButton,
hideRetryButton: this.opts.hideRetryButton,
hidePauseResumeButton: this.opts.hidePauseResumeButton,
hideCancelButton: this.opts.hideCancelButton,
showProgressDetails: this.opts.showProgressDetails,
hideAfterFinish: this.opts.hideProgressAfterFinish,
locale: this.opts.locale,
doneButtonHandler: this.opts.doneButtonHandler,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it might be more readable to use destructuring here, not sure.

Suggested change
return {
hideUploadButton: this.opts.hideUploadButton,
hideRetryButton: this.opts.hideRetryButton,
hidePauseResumeButton: this.opts.hidePauseResumeButton,
hideCancelButton: this.opts.hideCancelButton,
showProgressDetails: this.opts.showProgressDetails,
hideAfterFinish: this.opts.hideProgressAfterFinish,
locale: this.opts.locale,
doneButtonHandler: this.opts.doneButtonHandler,
}
const {
hideUploadButton,
hideRetryButton,
hidePauseResumeButton,
hideCancelButton,
showProgressDetails,
hideAfterFinish,
locale,
doneButtonHandler,
} = this.opts
return {
hideUploadButton,
hideRetryButton,
hidePauseResumeButton,
hideCancelButton,
showProgressDetails,
hideAfterFinish,
locale,
doneButtonHandler,
}

Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] None 0 65.6 kB nicolo-ribaudo
npm/@babel/[email protected] None 0 49.3 kB nicolo-ribaudo
npm/@babel/[email protected] None 0 11.8 kB nicolo-ribaudo
npm/@babel/[email protected] None 0 1.89 MB nicolo-ribaudo
npm/@bcoe/[email protected] None 0 277 kB bcoe
npm/@hapi/[email protected] None 0 51.5 kB devinivy
npm/@istanbuljs/[email protected] None 0 17.2 kB coreyfarrell
npm/@jridgewell/[email protected] None 0 45.9 kB jridgewell
npm/@nodelib/[email protected] filesystem 0 11.8 kB mrmlnc
npm/@opentelemetry/[email protected] None 0 1.22 MB pichlermarc
npm/@types/[email protected] None 0 5.45 kB types
npm/@types/[email protected] None 0 31.7 kB types
npm/@uppy-dev/[email protected] None 0 0 B
npm/[email protected] environment 0 26.1 kB jonschlinkert
npm/[email protected] None 0 2.88 kB sindresorhus
npm/[email protected] environment 0 11.4 kB pfmooney
npm/[email protected] None 0 9.62 kB feross
npm/[email protected] environment, eval, unsafe 0 632 kB esailija
npm/[email protected] None 0 5.05 kB linusu
npm/[email protected] None 0 11.7 kB sindresorhus
npm/[email protected] None 0 43.7 kB sindresorhus
npm/[email protected] None 0 32.1 kB sindresorhus
npm/[email protected] None 0 17 kB jorgebucaran
npm/[email protected] filesystem, shell 0 113 kB abetomo
npm/[email protected] None 0 10.5 kB dougwilson
npm/[email protected] None 0 3.94 kB natevw
npm/[email protected] None 0 23.7 kB dougwilson
npm/[email protected] None 0 23.9 kB joshuakgoldberg
npm/[email protected] None 0 31.2 kB tehshrike
npm/[email protected] environment, eval 0 27.1 kB dougwilson
npm/[email protected] filesystem 0 9.02 kB dougwilson
npm/[email protected] environment, filesystem 0 79.1 kB motdotla
npm/[email protected] None 0 6.26 kB dougwilson
npm/[email protected] None 0 413 kB feedic
npm/[email protected] None 0 12.3 kB ljharb
npm/[email protected] filesystem 0 11.6 kB lukeed
npm/[email protected] None 0 3.66 kB dougwilson
npm/[email protected] None 0 2.69 kB jbnicolai
npm/[email protected] None 0 314 kB ariya
npm/[email protected] None 0 37.1 kB michaelficarra
npm/[email protected] None 0 82.8 kB goto-bus-stop
npm/[email protected] None 0 23.5 kB ljharb
npm/[email protected] None 0 22.8 kB dap
npm/[email protected] None 0 13 kB esp
npm/[email protected] None 0 17 kB esp
npm/[email protected] network 0 29.4 kB rubenverborgh
npm/[email protected] None 0 173 kB pipobscure
npm/[email protected] None 0 4.72 kB stefanpenner
npm/[email protected] None 0 3.71 kB jonschlinkert
npm/[email protected] None 0 12.1 kB phated
npm/[email protected] environment, filesystem 0 32.5 kB isaacs
npm/[email protected] None 0 12.8 kB ljharb
npm/[email protected] None 0 12 kB ljharb
npm/[email protected] None 0 20.6 kB ljharb
npm/[email protected] None 0 35.9 kB kornel
npm/[email protected] None 0 6.8 kB feross
npm/[email protected] None 0 51.5 kB kael
npm/[email protected] None 0 3.96 kB isaacs
npm/[email protected] None 0 28.9 kB ljharb
npm/[email protected] filesystem 0 3.01 kB sindresorhus
npm/[email protected] None 0 5.09 kB jonschlinkert
npm/[email protected] None 0 4.12 kB sindresorhus
npm/[email protected] None 0 6.23 kB sindresorhus
npm/[email protected] None 0 6.93 kB doowb
npm/[email protected] None 0 34.4 kB oss-bot
npm/[email protected] None 0 15.1 kB lydell
npm/[email protected] None 0 10.4 kB isaacs
npm/[email protected] None 0 12.7 kB isaacs
npm/[email protected] None 0 235 kB jordanbtucker
npm/[email protected] None 0 22.8 kB doowb
npm/[email protected] None 0 10.2 kB jdalton
npm/[email protected] None 0 1.41 MB bnjmnt4n
npm/[email protected] None 0 8.9 kB zensh
npm/[email protected] network 0 5.29 kB dougwilson
npm/[email protected] None 0 206 kB dougwilson
npm/[email protected] environment, filesystem 0 51.7 kB broofa
npm/[email protected] None 0 2.97 kB thejameskyle
npm/[email protected] None 0 1.55 kB cwmma
npm/[email protected] None 0 54.5 kB ljharb
npm/[email protected] environment, filesystem 0 19.1 kB isaacs
npm/[email protected] None 0 6.84 kB styfle
npm/[email protected] None 0 27.4 kB dougwilson
npm/[email protected] None 0 298 kB suguru03
npm/[email protected] None 0 9.22 kB jonschlinkert
npm/[email protected] None 0 5.49 kB sindresorhus
npm/[email protected] None 0 19.1 kB indutny
npm/[email protected] None 0 3.06 kB sindresorhus
npm/[email protected] None 0 10.3 kB dougwilson
npm/[email protected] None 0 4.55 kB sindresorhus
npm/[email protected] environment 0 5.15 kB alexeyraspopov
npm/[email protected] None 0 90 kB mrmlnc
npm/[email protected] unsafe 0 13.5 kB danez
npm/[email protected] environment, filesystem, unsafe 0 8.25 MB prettier-bot
npm/[email protected] None 0 33.5 kB google-wombot
npm/[email protected] None 0 123 kB kriskowal
npm/[email protected] None 0 8.46 kB dougwilson
npm/[email protected] None 0 302 kB mysticatea
npm/[email protected] None 0 31.7 kB feross
npm/[email protected] None 0 42.3 kB chalker
npm/[email protected] filesystem 0 85.2 kB linusu
npm/[email protected] None 0 805 kB tromey
npm/[email protected] None 0 12.1 kB dougwilson
npm/[email protected] None 0 46.9 kB sokra
npm/[email protected] None 0 12.5 kB dominictarr
npm/[email protected] None 0 84.9 kB typescript-bot
npm/[email protected] None 0 174 kB dchest
npm/[email protected] None 0 42.1 kB chaijs
npm/[email protected] None 0 111 kB sindresorhus
npm/[email protected] None 0 32.4 MB typescript-bot
npm/[email protected] None 0 4.31 kB dougwilson
npm/[email protected] None 0 5.48 kB tootallnate
npm/[email protected] None 0 123 kB ctavan
npm/[email protected] None 0 8.75 kB dougwilson
npm/[email protected] None 0 91.3 kB sokra
npm/[email protected] None 0 6.46 kB raynos
npm/[email protected] environment, filesystem 0 124 kB oss-bot

🚮 Removed packages: npm/@uppy-dev/[email protected], npm/@uppy-dev/[email protected], npm/@uppy-dev/[email protected], npm/@uppy-dev/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy-example/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/@uppy/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants