-
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
Add @uppy/remote-sources preset/plugin #3676
Conversation
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.
I know it's WIP but there still needs to be a way to pass options. I think (hope) that all remote plugins share the exact same options.
As far as I know, the only option for remote sources is |
All these options and the ones in other docs. |
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
this.opts.sources.forEach((pluginName) => { | ||
const plugin = this.uppy.getPlugin(pluginName) | ||
this.uppy.removePlugin(plugin) | ||
}) |
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.
Shouldn't be worried that this.opts.sources
can be modified by the user and the uninstall
would not work correctly? Another (better?) way of handling it would be to have a private Set
on the instance that caches all the plugins that were installed.
this.opts.sources.forEach((pluginName) => { | |
const plugin = this.uppy.getPlugin(pluginName) | |
this.uppy.removePlugin(plugin) | |
}) | |
this.#installedPlugins.forEach(plugin => this.uppy.removePlugin(plugin)) | |
this.#installedPlugins.clear() |
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.
Yeah, it sounds better, not sure if Set is required or just a private array. But I did think of this, if you modify options the correct way via uppy.getPlugin('RemoteSources').setOptions({ sources: ['Instagram'] })
, the plugin will first uninstall everything, then update options and install back: https://github.com/transloadit/uppy/pull/3676/files#diff-3b90938b025125a702e11b69f66acdd0c6985a892f64f4a28b06f0dcdb24e873R51-R55
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.
I think we should not assume that users will always use the correct way.
const sources = ['Instagram']
uppy.use(RemoteSources, { sources })
sources.pop() // The user mutates the array for some reason
uppy.getPlugin('RemoteSources').uninstall() // The Instagram plugin is still installed
I think Set
is more suited for our use case, but I suppose an array would also work.
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
e2e/clients/dashboard-tus/app.js
Outdated
.use(Tus, { | ||
endpoint: 'https://tusd.tusdemo.net/files', | ||
onShouldRetry, | ||
retryDelays: [2000, 3000, 4000], |
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.
That looks unrelated, can we put it in its own PR (or remove it)
cy.intercept( | ||
{ method: 'PATCH', pathname: '/files/*', times: 2 }, | ||
{ method: 'PATCH', pathname: '/files/*', times: 1 }, | ||
{ statusCode: 429, body: {} }, | ||
).as('patch') | ||
|
||
cy.wait('@patch') | ||
cy.wait('@patch') |
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.
Same here
…f test more robust" This reverts commit 76a760c.
@aduh95 please take another look, cause I’m not sure what I’m doing with |
const optsForRemoteSourcePlugin = { ...this.opts, sources: undefined } | ||
const plugin = availablePlugins.find(p => p.name === pluginId) | ||
this.uppy.use(plugin, optsForRemoteSourcePlugin) |
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.
We could have a more useful error message here (maybe it'd be worth having a unit test btw?)
const optsForRemoteSourcePlugin = { ...this.opts, sources: undefined } | |
const plugin = availablePlugins.find(p => p.name === pluginId) | |
this.uppy.use(plugin, optsForRemoteSourcePlugin) | |
const plugin = availablePlugins.find(p => p.name === pluginId) | |
if (plugin == null) { | |
const formatter = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' }); | |
throw new Error(`Invalid plugin name: "${pluginId}" is not one of ${formatter.format(availablePlugins)}.`) | |
} | |
this.uppy.use(plugin, { ...this.opts, sources: undefined }) |
private/dev/Dashboard.js
Outdated
sources: ['Box', 'Dropbox', 'Webcam', 'Facebook', 'GoogleDrive', 'Instagram', 'OneDrive', 'Unsplash', 'Url'], | ||
}) | ||
.use(Webcam, { |
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.
Is it expected that Webcam is both in RemoteSources and as standalone?
Also, optional nit, can we sort the list to be in alphabetical order.
website/src/docs/remote-sources.md
Outdated
tagline: "Uppy plugin that includes all remote sources that Uppy+Companion offer, like Instagram, Google Drive, Dropox, Box, Unsplash, Url etc" | ||
--- | ||
|
||
Remote Sources plugin makes it convinient to add all the available remote sources — Instagram, Google Drive, Unsplash, Url, etc — to Uppy Dashboard in one convinient package. |
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.
Remote Sources plugin makes it convinient to add all the available remote sources — Instagram, Google Drive, Unsplash, Url, etc — to Uppy Dashboard in one convinient package. | |
@uppy/remote-sources is a preset plugin to add all the available remote sources, such Instagram, Google Drive, Dropbox, and others to Uppy Dashboard in one package. |
website/src/docs/remote-sources.md
Outdated
}) | ||
``` | ||
|
||
You can possible to control which plugins will be used and the order they appear in the Dashboard, see below for `sources` option. All Companion-related options, such as `companionUrl`, are passed to the underlining plugins. |
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.
I think this sentence is redundant (it also has quite a few typos) as it just says 'hey we also have these two options' but you can also see that below in more detail
You can possible to control which plugins will be used and the order they appear in the Dashboard, see below for `sources` option. All Companion-related options, such as `companionUrl`, are passed to the underlining plugins. |
website/src/docs/remote-sources.md
Outdated
* Type: `string` | ||
* Default: `RemoteSources` |
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.
Could you align all of these with how I have been doing this in the new website? It would save me a rewrite.
The format is:
[one sentence explanation] ([type], Default: [default])
Example:
Render the Dashboard as a modal or inline (`Boolean`, default: `false`).
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.
Yeah, I like your way, just did this for consistency with the current docs.
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
All feedback addressed, I think this is ready to be merged. |
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/aws-s3 | 2.2.1 | @uppy/tus | 2.4.1 | | @uppy/aws-s3-multipart | 2.4.1 | @uppy/url | 2.2.0 | | @uppy/companion-client | 2.2.1 | @uppy/xhr-upload | 2.1.2 | | @uppy/core | 2.3.1 | @uppy/robodog | 2.8.0 | | @uppy/react | 2.2.2 | uppy | 2.12.0 | | @uppy/remote-sources | 0.1.0 | | | - @uppy/remote-sources: Add @uppy/remote-sources preset/plugin (Artur Paikin / #3676) - @uppy/react: Reset uppy instance when React component is unmounted (Tomasz Pęksa / #3814) - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus: queue socket token requests for remote files (Merlijn Vos / #3797) - @uppy/xhr-upload: replace `ev.target.status` with `xhr.status` (Wes Sankey / #3782) - @uppy/core: fix `TypeError` when file was deleted (Antoine du Hamel / #3811) - @uppy/robodog: fix linter warnings (Antoine du Hamel / #3808) - meta: fix GHA workflow for prereleases (Antoine du Hamel) - @uppy/aws-s3-multipart: allow `companionHeaders` to be modified with `setOptions` (Paulo Lemos Neto / #3770) - @uppy/url: enable passing optional meta data to `addFile` (Brad Edelman / #3788) - @uppy/url: fix `getFileNameFromUrl` (Brad Edelman / #3804) - @uppy/tus: make onShouldRetry type optional (Merlijn Vos / #3800) - doc: fix React examples (Antoine du Hamel / #3799) - meta: add GHA workflow for prereleases (Antoine du Hamel)
With the new preset / after:
Without the new preset / before: