Commit graph

335 commits

Author SHA1 Message Date
Artur Paikin
674fe15f31 fix state update event 2017-09-18 18:24:34 -04:00
Artur Paikin
11002c8d43 Merge pull request #341 from sunil-shrestha/fix/clearCurrentUploads
set the newState before emiting "core:state-update" .
2017-09-18 18:04:24 -04:00
Artur Paikin
a4668d4f96 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/core/Core.js
#	src/plugins/Dashboard/index.js
2017-09-15 23:56:18 -04:00
Artur Paikin
7b7aa7d7d9 add type.mime to tests 2017-09-14 22:50:14 -04:00
Artur Paikin
4a85a4d1e0 refactor a little, add file.type.mime (before the migration to mime entirely) add comments 2017-09-14 22:39:21 -04:00
Artur Paikin
1f8a369f4f separate checkMinNumberOfFiles method 2017-09-14 13:20:45 -04:00
Artur Paikin
829713851e Adjust checkMinNumberOfFiles
Fixes #344
2017-09-14 12:51:19 -04:00
Artur Paikin
0eb2448a3d Fix calculateTotalProgress - NaN 2017-09-13 18:50:41 -04:00
Sunil Shrestha
2c951a884d set the newState before emiting "core:state-update" . 2017-09-13 14:40:33 +03:00
Artur Paikin
016557e246 Merge pull request #330 from transloadit/fix/fileID
Better `generateFileID`
2017-09-12 11:10:29 -04:00
Artur Paikin
0e1a4b51a4 Merge pull request #335 from richardwillars/core-tests
[WIP] Remaining tests for src/core.js
2017-09-12 11:09:16 -04:00
Artur Paikin
e69151ca0c Merge pull request #319 from richardwillars/isOnline
Tell Uppy to be offline
2017-09-12 10:59:20 -04:00
Richard Willars
050ecbfa1e Adds tests for checkRestrictions 2017-09-12 15:48:03 +01:00
Richard Willars
abbaed88cd Test for createUpload 2017-09-12 10:50:12 +01:00
Richard Willars
979be04540 Remove upload test 2017-09-12 10:10:21 +01:00
Richard Willars
504a6977ac Adds tests for info messages (and fixes hideInfo method) 2017-09-12 09:09:25 +01:00
Artur Paikin
df659c5417 Merge pull request #328 from transloadit/chore/dashboard
Dashboard: show()/hide()/isOpen()
2017-09-11 21:16:56 -04:00
Artur Paikin
1cdd617b8c return an array always, even with a single item 2017-09-11 10:33:52 -04:00
Richard Willars
6ecaad1bc6 Rename isOnline with updateOnlineStatus and removed params
isOnline renamed to updateOnlineStatus and removes params

updateOnlineStatus default to true

Improved the window.navigator.onLine check

Adds tests for updateOnlineStatus

Removes debug

Fixes isTouchDevice test

File cleanup

Simplifies mock for window.navigator.onLine
2017-09-11 15:01:29 +01:00
Artur Paikin
a08319fde5 lastModified is a number 2017-09-11 09:59:19 -04:00
Artur Paikin
981a331c10 allow “selector” to be a DOM element in findAllDOMElements too 2017-09-11 09:45:43 -04:00
Renée Kooi
383aa85025 Merge pull request #323 from goto-bus-stop/rm-upload-complete
core: Remove `core:upload-complete` event.
2017-09-11 09:59:30 +02:00
Artur Paikin
6b6ce35927 add findDOMElements that always returns an array of DOM elements 2017-09-10 21:35:10 -04:00
Artur Paikin
80636d125c fix tests
I unfortunately can’t seem to understand this test: `should execute all
the postprocessors when uploading a file` in Core.test.js:
6bee4f427f
eb771774b/src/core/Core.test.js#L388

@richardwillars could you please help explain why the fileID is used
there and how, and if it’s wrong to change it the way I did here?
2017-09-10 20:53:18 -04:00
Artur Paikin
bd8345a166 Better generateFileID
Fixes #317
2017-09-10 19:56:31 -04:00
Artur Paikin
5d30474c43 Merge pull request #310 from richardwillars/jest-tests
Jest tests
2017-09-09 19:14:18 -04:00
Artur Paikin
7dfae9d24c support multiple elements in findDOMElement
@goto-bus-stop potential danger point. introduced to support multiple
dashboard open triggers #326

Maybe we should always return an array and just use the first element
where multiple elements don’t make sense
2017-09-08 15:23:44 -04:00
Artur Paikin
83f514232e bind info 2017-09-08 15:21:48 -04:00
Rich Willars
540c02b6b0 Add jest tests
Adds tests for src/core/Utils

Ports translator tests to jest

Adds tests for core/index

Added code coverage report

Adds tests for core/UppySocket

Adds tests to src/core and cleanup of test directory

Switched from import to require as the project supports node v4

Runs tests using Babel for backwards compatibilty

Adds src/core state tests

Adds src/core reset & close tests

Updates stagnant snapshot

Adds tests for preprocessors and postprocessors in src/core/Core.js

Adds tests for uploaders and metadata in src/core/Core

Adds tests for adding and removing files in src/core/Core

Adds test for getFile
2017-09-08 17:18:58 +01:00
Renée Kooi
2ef0f04ac2
core: Remove core:upload-complete event.
XHRUpload and Tus were relying on `core:upload-complete` to determine
when their uploads had all finished, but `core:upload-complete` could
fire before all XHR `onload` handlers were called. Then, because
XHRUpload and Tus would resolve their `handleUpload` promises at that
point, the `core:success` event could fire *before* all
`core:upload-success` events had fired, and before the plugins properly
handled responses. In particular, some files may not have `.uploadURL`
properties when `core:success` is fired:

https://community.transloadit.com/t/unable-to-get-to-work-the-awss3-plugin/14477/16

I think, that the XHR `onprogress` event would fire first at 100%, and
then the `onload` handler fired at some point later (after the response
was parsed or whatever the browser does to it). This could cause the
`core:upload-complete` event to fire before responses were handled by
Uppy.

The XHRUpload and Tus plugins now use the Promises that they were
already creating to wait for uploads to complete. This way they will
always have handled responses before handing over control to
postprocessors and before the `core:success` event is fired.

Since `core:upload-complete` is now unused, I just removed it for now.
2017-09-08 14:28:13 +02:00
Renée Kooi
2966c53668
core: fix comment indents 2017-09-08 13:51:40 +02:00
Renée Kooi
8a4cfed360 Merge pull request #316 from goto-bus-stop/promise-resolve
Handle sync returns and throws in possibly-async function options
2017-09-07 14:50:20 +02:00
Renée Kooi
dee1f69591
core: remove unnecessary instanceof check
This function will never be an instance of the `Uppy` class.
2017-09-05 19:19:30 +02:00
Renée Kooi
8011a5b88b
core: rm outdated comment 2017-09-05 19:19:03 +02:00
Renée Kooi
850c2bb526
Handle sync returns and throws in possibly-async function options
Fixes #315

This patch makes some function options that can return Promises a bit
easier to use. Previously, most of these required that the user returned
a Promise, even if they were doing sync work. Also, if an error was
thrown inside the provided function, it would actually throw the error
instead of rejecting a Promise, thus not allowing Uppy to show an error
notification or anything.

Instead, these options now use this pattern:

```js
Promise.resolve()
  .then(() => this.opts.onSomething(argument))
```

Inside a `.then()` handler, both a Promise and a plain value can be
returned, and the resulting Promise will be resolved with the correct
value. Also, any sync errors `throw`n inside a `.then()` handler cause
the returned Promise to be rejected.
2017-09-05 19:01:46 +02:00
Renée Kooi
15909b2c6b
core: Add reset-progress event hook for plugins 2017-09-04 19:00:35 +02:00
Renée Kooi
1e07cf1139 Merge pull request #309 from richardwillars/addplugin
Checks for plugin type and plugin id rather than name
2017-09-01 15:34:12 +02:00
Richard Willars
b7145e83f4 Removes 'none' string check on plugin type 2017-09-01 14:11:43 +01:00
Renée Kooi
fb5a7fb5cf Merge pull request #312 from richardwillars/updateAll
updateAll method uses iteratePlugins method
2017-09-01 14:55:26 +02:00
Richard Willars
cfc21fd179 updateAll method uses iteratePlugins method 2017-09-01 13:31:39 +01:00
Richard Willars
b0eb6c0a7e Checks for plugin type and plugin id rather than name 2017-09-01 11:38:11 +01:00
Artur Paikin
8baf64ebf7 Merge pull request #308 from transloadit/fix/submit-filecard-on-enter
Submit FileCard on enter key
2017-09-01 13:10:20 +03:00
Artur Paikin
cb62a1e623 minor refactoring 2017-08-31 21:52:08 +03:00
Renée Kooi
2960be0d86
xhrupload: Use error messages from the endpoint, closes #303 2017-08-31 11:23:31 +02:00
Renée Kooi
1360689063
core: Throw clearer error when .useing undefined
Previously this would throw "Plugin is not a constructor" when trying to
instantiate the plugin. Now it checks that the Plugin is actually a
function (and hopefully a constructor…) and throws a more helpful error
if it is not.
2017-08-30 13:24:13 +02:00
Artur Paikin
f97f01f38b msg --> message 2017-08-28 13:28:52 +03:00
Artur Paikin
dc12ed1229 Informer: support “explanations”, a (?) button that shows more info on hover / click 2017-08-26 07:43:13 +03:00
Artur Paikin
6d727e4c4e capitalize Uppy Server 2017-08-24 23:59:00 +03:00
Artur Paikin
138b088ac0 show informer on upload-error 2017-08-24 23:58:59 +03:00
Renée Kooi
7572a9b46b
transloadit: Add alwaysRunAssembly option
This adds back the ability to run assemblies without uploading any
files, which is useful in case the assembly uses an import robot.

To do this, this patch adds a new state key to the Transloadit plugin's
state, named `uploadsAssemblies` (open to bikeshedding lol)
This key associates assembly IDs with the upload ID that triggered them.
This allows figuring out which assemblies need to finish before
resolving the upload promise.

The upload ID is now passed into preprocessors and postprocessors so
they can use it to store metadata that is related to an upload instead
of a single file.

When `alwaysRunAssembly` is set to true, and zero files are available
for upload, an assembly is created anyway for the options returned by
`getAssemblyOptions(null)`.

It turns out that `afterUpload` actually didn't work correctly if
multiple assemblies were used for a single upload. I changed it so that
it does, and incidentally that also made it work again with zero-file
assemblies.
2017-08-22 15:34:34 +02:00