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

Cannot change closeAfterFinish when using Robodog.form #1638

Closed
kvz opened this issue Jun 5, 2019 · 3 comments · Fixed by #1690
Closed

Cannot change closeAfterFinish when using Robodog.form #1638

kvz opened this issue Jun 5, 2019 · 3 comments · Fixed by #1690
Assignees
Labels

Comments

@kvz
Copy link
Member

kvz commented Jun 5, 2019

Tried it like so but it has no effect:

var uppy = window.Robodog.form('#myForm', {
  waitForEncoding: true,
  waitForMetadata: true,
  allowMultipleUploads: false,

  closeAfterFinish: true,

  [ ... ]
})

I tried to work around this via:

uppy.on('complete', function (result) {
  uppy.getPlugin('Dashboard').closeModal();
}) 

which resulted in the error: [Uppy] [21:51:37] uppy.getPlugin(...) is null undefined

I then found the id is form:Dashboard and that worked 🎉 But so maybe the error message [Uppy] [21:51:37] uppy.getPlugin(...) is null undefined could be changed into sth like No plugin found by id "X", did you mean "${pluginlist.join('", "'}"?

The HTML file to reproduce: https://gist.github.com/kvz/cffea041a60dc041f59f79f891d98f44

@arturi
Copy link
Contributor

arturi commented Jun 6, 2019

Robodog on CDN wasn’t properly updated after the release, so it could have been an old version. I haven’t tested yet though.

@arturi
Copy link
Contributor

arturi commented Jun 12, 2019

Reminder to also make button.textContent = 'Select files' translatable: fd5a1e7#diff-f2a60d5531d02b07368ce883bb863d65R45

@arturi
Copy link
Contributor

arturi commented Jun 21, 2019

But so maybe the error message [Uppy] [21:51:37] uppy.getPlugin(...) is null undefined could be changed into sth like No plugin found by id "X", did you mean "${pluginlist.join('", "'}"

I tried doing this to improve the error message, like you suggested, @kvz:

/**
   * Find one Plugin by name.
   *
   * @param {string} id plugin id
   * @return {object | null}
   */
  getPlugin (id) {
    let foundPlugin = null
    this.iteratePlugins((plugin) => {
      if (plugin.id === id) {
        foundPlugin = plugin
        return false
      }
    })
    if (!foundPlugin) {
      const pluginList = []
      this.iteratePlugins((plugin) => {
        pluginList.push(plugin.id)
      })
      this.log(`No plugin found by id '${id}', did you mean '${pluginList.join("', '")}'`, 'error')
    }
    return foundPlugin
  }

But Core actually checks if the plugin exists when useing it, with getPlugin(), and getPlugin returning null is an expected behavior in this case. We could split this into getPlugin and pluginExists, I guess, but not sure if it’s worth it.

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

Successfully merging a pull request may close this issue.

3 participants