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

Import from url #588

Merged
merged 11 commits into from
Feb 9, 2018
Merged

Import from url #588

merged 11 commits into from
Feb 9, 2018

Conversation

arturi
Copy link
Contributor

@arturi arturi commented Feb 2, 2018

screen shot 2018-02-02 at 12 20 30 am

screen shot 2018-02-02 at 12 20 58 am

Client side response to @ifedapoolarewaju work on uppy-server side transloadit/uppy-server@0a33b48.

With UI I think we could later make it the same as with other Providers and show a “select file” button below.

Code-wise, I hardcoded things in the Url plugin itself, didn’t separate the view and logic much there, @ifedapoolarewaju hoping we can find a way to make this more consistent with other Provider plugins.

super(uppy, opts)
this.id = this.opts.id || 'Url'
this.title = 'Link'
this.type = 'acquirer'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider not hardcoding these plugin types.

We could have core.types = {ACQUIRER: 'acquirer', ...}

then in our plugin we do:
this.type = core.types.ACQUIRER

it might be easier to maintain that way. Especially with custom plugins created outside this project.

what do you think?

this[method] = this[method].bind(this)
})

this[this.id] = new Provider(uppy, {
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I'm at crossroads with this one. Here are a few thoughts I have:

  1. I think we should consider removing plugins/Provider from the plugins folder, because it is not a plugin. And it's the only defaulter there. Maybe we should move it to core? Or somewhere else?

  2. Even if we do move plugins/Provider to a separate folder, I think its use doesn't apply to the URL plugin. I don't consider the URL a Provider because, for GoogleDrive, Dropbox, etc, we have a definite source (aka Provider) they connect to (e.g drive.google.com for GoogleDrive). So the expected behavior can be managed for each Provider.

But for URLs, it would be connecting to different sources (depending on the URL provided), from which we can expect different behaviors (e.g some may require authorization headers etc). So it might be tricky to squeeze that into a Provider. Instead maybe we should have URL stand as a separate plugin and not considered it a Provider type.

  1. That said, I think we need a separate module that manages communication with uppy-server. So instead of just plugins/Provider which does it right now. We can have a folder structure like this:
 ServerBridge(or a better name)
      --- Provider
      --- ApiCalls (or whatever)

where plugins like google drive can go on to use Provider, while plugins like URL, S3 can just use ApiCalls directly. And then going back to suggestion 1. we could move ServerBridge to Core or make it standalone.

What do you think? I hope I made sense 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed this in the call yesterday and decided to try the following: add generic API calls to provider/index.js so that we don’t have to repeat the boilerplate with fetch headers and so on. For now leave things as one this, provider, maybe think on a more generic name, like uppy-server-api or something.

Then maybe provider lives in uppy-core, but uppy-provider-views is a separate package.

}

getMeta (url) {
return fetch(`${this.hostname}/url/meta`, {
Copy link
Contributor

Choose a reason for hiding this comment

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

based on my suggestion 2. and 3. above, we can have this fetch done in ApiCalls


render (state) {
return <div class="uppy-Url">
<input
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if this view is not re-usable by any other plugin, then we can leave this as is, and no need to fuse this with Provider/view.

@goto-bus-stop
Copy link
Contributor

Cool! looks like you committed an outdated package-lock file though :)

@arturi arturi merged commit cfff63e into master Feb 9, 2018
@arturi arturi deleted the feature/import-from-url branch February 9, 2018 05:40
@arturi arturi changed the title [wip] Import from url Import from url Feb 9, 2018
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.

3 participants