-
Notifications
You must be signed in to change notification settings - Fork 2k
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
core: setOptions for Core and plugins #1728
Conversation
9e8b13a
to
bbc720f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably a good direction .. if there is some option that cannot be changed without breaking everything, we could override setOptions() to blacklist it. For some options like limit
, we could add a method to the RateLimitedQueue to change the limit on the fly.
Regarding this, we probably need to merge in the restrictions object too then right? Else you lose any other restrictions. Maybe we should move all the merging stuff that we do in the constructor into |
Would this allow for changing the size of the Uppy instance? I would love to save screen space by having a thing drag n drop window that expands or grows larger to encompass the thumbnail(s) with their respective controls, etc. This would require a re-draw so this may need an "event" to trigger after setting? |
Then I wonder if we should merge all objects manually, like |
Also not sure if we should allow changing locale per plugin via |
@BallisticPain if I understand you correctly, and you’d like to dynamically change the size of |
cause ThumbnailGenerator now calls this.setPluginState, which expects `core.state.plugins`
…opts is set in core @goto-bus-stop does this look ok? merging restrictions opts in core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems almost perfect! One last thing: when you change the locale in Core, all the plugins' locales need to be updated as well, so the things they inherited are reflected. For ex, add this to ./examples/dev/Dashboard.js:
setTimeout(() => {
uppy.setOptions({
locale: require('@uppy/locales/src/th_TH')
})
}, 2000)
after 2s the main dashboard screens will still be in english. if you open a panel (like for GDrive), it's in Thai. i'm not sure exactly why the panel is in Thai and the main screens are not. but it's fixed by refreshing the Translator instance the dashboard uses with dashboardPlugin.i18nInit()
.
… plugins, so that i18n updates
Thanks, Renée!
Simple: |
uppy.setOptions({ restrictions: { maxNumberOfFiles: 3 } })
— we’ve changedmaxNumberOfFiles
depending on some condition in our app on the flyuppy.getPlugin('Dashboard').setOptions({ note: 'You can only upload 3 files' })
— we’ve changed thenote
to reflect the newmaxNumberOfFiles
Adds an— done automatically nowuppy.getPlugin('Dashboard').i18nInit()
API to re-init the i18n translations, so that new stings are used after they’ve been updated with methods above.We keep getting requests to update options or change locales in uppy on the fly, this PR addresses that (and fixes #1687):
ToDo:
i18nInit
to all plugins that use translation strings