DEV: Add uploadHandler support to composer-upload-uppy mixin (PR #14692)

This commit adds uploadHandler support to composer uploads using uppy. The only things we have that are using this are discourse-brightcove and discourse-video, which both pop modal windows to handle the file upload and completely leave out all the composer-type flows. This implementation simply follows the existing one, where if a single file is uploaded and there is a matching upload handler we take control away from uppy and hand it off to the upload handler.

Trying to get this kind of thing working within uppy would require a few changes because they have no way to restrict uploaders to certain file types and with the way their uploaders are run it doesn’t look like it would be easy to add this either, so I don’t think this is worth the work unless at some point in the future we plan to have more upload handler integrations.

I also fixed an issue with cleanUpComposerUploadHandler which is used in tests to reset the state of uploadHandlers in the composer. This was doing uploadHandlers = [] to clear that array, but that creates a brand new array so anything else referencing the original array will lose that reference. Better to set uploadHandlers.length = 0 to clear it. This was breaking the tests I added to see if upload handlers were working.

GitHub

Test failure is unrelated.

does it need to be an anonymous function ?

      url,

what is this achieving if we don’t test anything else after?

Great find!

Good point, changed this.

Eslint has a rule for this, I will open a dev topic to see the interest in adding it, I know I forget this all the time object-shorthand - Rules - ESLint - Pluggable JavaScript linter

Hmm I think this is because I previously had a test which was not closing these modals causing others to fail, but now I think of it it was probably an unrelated issue. Removing.

This test works perfectly fine without this line.

I spoke too soon @jjaffeux , if I remove this line the non-ember-CLI tests break, so leaving it in.