Commit graph

203 commits

Author SHA1 Message Date
Merlijn Vos
f2d30420f3
Mention the file name in exceedsSize error message (#2918)
* Mention the file name in exceedsSize error message

* Fix implementation and tests

* Undo accidental commited changes
2021-06-07 15:42:41 +01:00
Antoine du Hamel
1aa17533ee
core: enrich error event for use from postproocessor (#2909)
Fixes: https://github.com/transloadit/uppy/issues/2840
2021-05-31 12:43:18 +01:00
Artur Paikin
c4a637655d
Golden Retriever 2: Return of the Ghost (#2701)
* don’t store file.data on local files when we save to localStorage, add isGhost: true, additional event restore-confirmed

Co-Authored-By: Renée Kooi <github@kooi.me>

* Don’t double-emit upload-started for Golden Retriever-restored files that were already started

Co-Authored-By: Renée Kooi <github@kooi.me>

* removeFile: delete updatedUploads[uploadID] instead of calling _removeUpload to avoide excess state updates

Co-Authored-By: Renée Kooi <github@kooi.me>

* clear preview, throttle saving state

* add service message and ghost icons

* regenerate thumnails on restore properly

* allow replacing duplicate files if it’s a ghost

* re-generate thumbnails on componentDidUpdate

* tweak styles for ghosts

* Dashboard cleanup

* refactor: load IndexedDBStore and ServiceWorkerStore together, add uninstall, handle file-edit-complete

* recoveredState — show upload button as “restore”, hide progress pause/resume, handle abortRestore

* tweak serviceMsg mobile styles

* use i18n for strings

* Handle aborting, complete and last file removal with MetaDataStore.cleanup(instanceID)

* fix all the tests

* import .eslintrc from master

* autofix

* add lodash.throttle

* when re-selecting ghost files, only replace the blob, keeping progress, meta, etc

* Delete package-lock.json

* Update en_US locale

* add golden retriever support to darkmode styles

* add golden retriever to website example

* Update package-lock.json

Co-authored-by: Renée Kooi <github@kooi.me>
2021-05-12 16:30:30 +01:00
Antoine du Hamel
a6bebda396
core: remove outdated comment (#2868)
Fixes: https://github.com/transloadit/uppy/issues/2787
2021-05-05 21:30:41 +01:00
Antoine du Hamel
a32870fe10
core: use AggregateError when available (#2869) 2021-05-04 23:35:32 +01:00
Artur Paikin
b760b0e918
add uppy.logout() (#2850) 2021-04-27 15:37:02 +01:00
Kevin van Zonneveld
764c2ccada
Update Linter (#2796)
* relocate .vscode

* Switch to transloadit linter

* Update .eslintrc.json

* autofix code

* unlink and install eslint-config-transloadit@1.1.1

* Change 0 to "off"

* Don't change 'use strict'

* Do not vertically align

* disable key-spacing

* add import/no-extraneous-dependencies per package

* add more react/a11y warnings

* Revert "autofix code"

This reverts commit 14c8a8cde8.

* add import/no-extraneous-dependencies per example and main package

* autofix code (2)

* Allow devDependencies in ./bin

* Change import/no-extraneous-dependencies to warn again

* upgrade linter

* Set import/no-extraneous-dependencies to warn
2021-03-15 16:25:17 +00:00
Artur Paikin
502a755458
Use Array.findIndex instead of Array.indexOf in uppy.removePlugin (#2793)
* move findIndex to @uppy/utils, add tests

* use Array.findIndex instead of Array.indexOf in uppy.removePlugin

because strict comparison started failing with Vue3 Proxies
2021-03-08 18:16:01 +00:00
Renée Kooi
bba2a2543a
transloadit: fix polling fallback bugs (#2759)
* transloadit: fix polling attempts after Assembly completed

* core: mark postprocessing completion if upload is complete
2021-02-10 12:29:53 +00:00
Renée Kooi
52760d2bb7
dashboard: improve support for right-to-left scripts (#2705)
* dashboard: fix modal position on rtl pages, fixes #2495

* Align text to the right on right-to-left pages

* core: fix default text alignment on right-to-left pages

* dashboard: fix margin in provider browser on right-to-left pages

* dashboard: use direction-aware offset properties

* provider-views: use logical offset CSS properties

* status-bar: use logical offset CSS properties

* dashboard: fix addMore icon margin on RTL pages

* dashboard: some more logical properties

* build: compile logical properties to old CSS

* dashboard: set dir attribute if page did not provide one

* status-bar: set fallback text direction if not provided

* support direction option for inline and modal dashboard

* use companion.uppy.io on deploy previews

* provider-views: fix RTL alignment of file icons

* put the dir attribute on a wrapper div

* fix icon alignment in RTL provider views

* informer: fix ? alignment in RTL mode
2021-01-27 17:13:38 +00:00
Artur Paikin
a6a28eac67
dashboard: add autoopen for file editors (image-editor) (#2681)
* final-file-added event for when the last file in the batch has been added

* intoduce autoOpenFileEditor — open when the last file (image) from a batch has beed added

* make cropping box more visible

* add docs

* final-file-added --> files-added
2020-12-18 21:27:48 +00:00
Artur Paikin
95e014f572
test: use DeepFrozenStore in one end to end test (#2607)
* use DeepFrozenStore in one end to end test

Follow up to #320

* add DeepFrozenStore to some Core unit tests
2020-11-25 21:19:32 +00:00
Artur Paikin
449798d964
pass files array to _checkRestrictions in _checkAndCreateFileStateObject via addFiles (#2655) 2020-11-25 11:55:36 +00:00
Artur Paikin
3967e05fbc
Add uppy.passesRestrictions(file) and disallow selecting files that don’t pass restrictions in providers (#2602)
* add passesRestrictions(file) and utilize it in provider-views

* disallow selecting more than maxNumberOfFiles

* add restriction reason and include folders

* let’s leave folder out of this for now — otherwise not only you can’t select them, but navigate too

* disallow selecting if totalCurrentSelectionFileSize is over maxTotalFileSize

* handle maxNumberOfFiles not being set 🙈

* fix totalCurrentSelectionFileSize and handle no file.name

* support grid in restrictions

* refactor the restriction reason logic, rename to validateRestrictions, wrap icon in a container

* add uppyFileSizes 🙈

* get rid of canSelectMore in favor of validateRestrictions (file, files)

* handle shift key bulk selection

* remove unused props

* use infoTimeout
2020-11-11 21:41:16 +00:00
Artur Paikin
f169943664
add uppy.opts.infoTimeout (#2619) 2020-11-06 17:48:25 +00:00
Ifedapo .A. Olarewaju
d586a4cf53
companion,unsplash: Unsplash provider (#2431)
* unsplash[wip]: implement unsplash provider + plugin

* unsplash,provider-views,companion-client: fully working unsplash plugin

* unsplash: clean up plugin implementation

* provider-views: refactor CloseWrapper

* companion-client: encode search text before adding it to URL

Co-authored-by: Renée Kooi <renee@kooi.me>

* companion: use object spread over Object.assign

Co-authored-by: Renée Kooi <renee@kooi.me>

* zoom: fix provider-view import

* circle icon

* update locale strings and package-lock

* move truncateString to @uppy/utils and use it for Unsplash name-description conversion, adding .jpg

* use alt_description if description in null

* companion: handle name truncation internally

* companion: handling carriage for truncation + fix urlmeta import

Co-authored-by: Renée Kooi <renee@kooi.me>
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2020-10-28 19:50:51 +01:00
Artur Paikin
9b5d3ec9a7
Restrictions: add maxTotalFileSize (#2594)
* add maxTotalFileSize restriction and tests

* docs and types

* use file.data.size and expect.toThrowError in tests
2020-10-24 00:14:08 +01:00
Enrique Mejia
ae4b9df31e
core: add postprocess progress when upload success (#2535)
* core: add postprocess progress when upload success

* Update packages/@uppy/core/src/index.js

Co-authored-by: Renée Kooi <renee@kooi.me>
2020-10-15 01:55:53 +01:00
Anthony Veaudry
8577db1e74
Adds minFileSize option Closes #2389 (#2394)
Co-authored-by: Renée Kooi <renee@kooi.me>
2020-08-06 16:11:55 +02:00
Renée Kooi
6b63325035
core: do not create an upload in retryAll() if there were no errors (#2361)
fixes #2298
2020-07-13 18:33:45 +02:00
Artur Paikin
eab4ddd55c Add reason argument to removeFiles 2020-06-24 18:27:19 +01:00
Artur Paikin
68f36b1ac2
Refactor FileProgress component (#2303)
* refactor FileProgress component; pass hideCancelButton, hidePauseResumeButton and hideRetryButton

* move icons to where they are rendered, rename UppyIcon to uppy-u-icon

* cleanup: rename DashboardItem, remove xmlns

* update docs to specify the option also hides action button on each individual file
2020-06-06 04:10:01 +02:00
Renée Kooi
811d763e16
core: add some more suggestions to the incorrect target warning (#2242) 2020-05-15 20:41:39 +02:00
Kevin van Zonneveld
803611ed04
Move @uppy/utils/lib/prettyBytes -> @transloadit/prettier-bytes (#2231)
* Move @uppy/utils/lib/prettyBytes -> @transloadit/prettier-bytes so we can more easily re-use it across projects

* Switch to MIT licensed @transloadit/prettier-bytes

* lockfile fun

* build: add dep for website/inject.js

Co-authored-by: Renée Kooi <renee@kooi.me>
2020-05-07 16:54:13 +02:00
Alexander Zaytsev
57da3a5a80
Dark mode design improvements (#2232)
* Modify highlight/link color

* Paler dashed outline

* Simpler input focus

* Tweak statuses' gray

* Tweak & fix :focus colors

* Swap TabBtn hover/focus colors

* Tweak dark focus outline

* Darker actionBtn

* Webcam button support

* Add isDraggingOver support

* Add ScreenCapture support

* ProviderBrowserItem-inner support

* Better fakeCheckbox support
2020-05-05 18:02:24 +02:00
Artur Paikin
53138f48f8 move from white to off-white 2020-04-24 09:17:37 +02:00
Artur Paikin
ed8a494875
Mark network errors as NetworkError (#2110)
* Add NetworkError error type and isNetworkError utility check

* Detect network errors in tus and xhr-upload

Co-Authored-By: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>

* add NetworkError check to RequestClient in companion-client

* return false if !xhr 🙈

* move catch so that only errors from _checkMinNumberOfFiles are caught — errors from uploads are logged in `upload-error` already

//cc @goto-bus-stop

* Add NetworkError to MiniXHRUpload in aws-s3

//cc @goto-bus-stop

* Add tests

//cc @ifedapoolarewaju

* pass xhr to NetworkError

* add logging in catch of uppy.upload()

* start error message with “This looks like a network error”

* originalRequest --> request, return NetworkError right away

* check for NetworkError in `delete` as well

do we need it in preflight too, @ifedapoolarewaju?

* remove redundant error message re-declaration

* _showOrLogErrorAndThrow, but don’t showInformer

Co-authored-by: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
2020-04-21 10:36:49 +02:00
Renée Kooi
ab76448508
aws-s3: handle upload internally instead of deferring to xhr-up… (#2060)
* aws-s3: handle actual upload internally instead of deferring to XHRUpload

* aws-s3: add a comment explaining the mess

* aws-s3: move XHRUpload code into a separate class

* utils: support prioritization in rate limiting queue

* aws-s3: remove old implementation

* core,status-bar: account for pre/postprocessing files in progress calculations

* changelog: add entry for this PR

* utils: Support cancellation in `RateLimitedQueue#wrapPromiseFunction`

* s3: remove preprocessing stage, only use upload-* events

* utils: remove console.log

* aws-s3: comment out duplicate `upload-started`

* xhr-upload: reorder `ProgressTimeout` creation for readability

* aws-s3: apply 7d972e0 to MiniXHRUpload

* aws-s3: apply 4ed7508 to MiniXHRUpload
2020-04-06 13:53:21 +02:00
Artur Paikin
5079d98584
dashboard: 2020 redesign 🍿 (#2015)
* ProviderViews: Improve Instagram’s “video thumbnail”

* Update all provider icons to nicer round ones

* Change “drop files” copy depending on number of acquirers and Dashboard width

* Translator: support multiple components in options

When the source contains multiple placeholders for interpolation, we should ignore chunks that are not strings, because those can be JSX objects and will be otherwise incorrectly turned into strings.

Without this condition we’d get this: [object Object] hello [object Object] my <button>

* Remove unused locale strings

* Rever renderSingleInlineProvider, use Browse button instead of link, tweak styles

* Try “Browse My Device” button

* Introduce “Dark Mode“: new Dashboard option 'theme': 'light', 'dark' or 'auto'

* Refactor to also add uninstall/removeListener for the darkModeMediaQuery; remove all bindings in favor of class properties

* More dark mode styles: Providers, FileCard, tweaking focus, inputs, etc

* My Device: mobile and desktop icons

* add isMobileDevice capability, very simple detection

* More dark mode styles

* refactor

* switch back to single simple my device icon

* chrome 78 for android doesn’t support document.querySelector 👌

* nobr --> span white-space: nowrap

* Major style tweaks for mobile provider list, show dashed borders only when DnD is supported

* Add color after “import from”

just for Russian for now, because I’m thinking if this should be a part of the language string or html? @goto-bus-stop @kvz, what do you think?

* improve isMobileDevice, add tests

* don’t set the isMobileDevice capability in core for now

* add checks for typeof window !== 'undefined', otherwise fails in Node/RN

* update locales

* refactor renderDropFilesSubtitle
2020-03-24 18:05:11 +01:00
Artur Paikin
f4497838da
Only _startIfAutoProceed if some files were actually added (#2146) 2020-03-21 11:03:56 +01:00
Renée Kooi
5e25b2a939
Fix translations that did not respect word order (#2077)
* Fix translations that did not respect word order

Fixes #2069

We were still using raw string concatenation in these two places. To
maintain backwards compatibility, this commit adds _new_ translations
that are substitution-based instead of concatenation-based. The old
translation is passed in as a possible substitution parameter
`backwardsCompat`, and the default (English) translations use this
parameter.

With this, if you are using a custom locale that overrides eg. the
`exceedsSize` string, Uppy will first get your `exceedsSize`
translation, and then use the default `exceedsSize2` translation which
concatenates that result and the file size. So it works the same as it
did in the past.
If a translation requires a different word order, it can override the
`exceedsSize2` translation instead.
```js
new Uppy({
  locale: {
    strings: {
      exceedsSize2: 'Maximum file size of %{size} exceeded',
      poweredBy2: '%{uppy} made this!'
    }
  }
})
```

In 2.0, we can remove all the old strings and only use `poweredBy2` (and
probably rename them to `poweredBy` too, heh)

* website: add missing dashboard strings to docs

* locales: remove unused second plural form from EN and NL

* build: allow different numbers of plural forms

* utils: add test for new throwing behaviour

* docs: insert PR url

* locales: revert ko_KR changes

* changelog: add 2.0 backlog entry

* locales: var → const

* docs: add brief note that translators should supply a pluralize function

* locales: update en_US with new template

* fix HEIGHT_MD = 400

Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2020-03-19 14:41:14 +01:00
Artur Paikin
856243a149
core, transloadit: Allow new uploads when retrying; improve error handling (#1960)
* Set `allowNewUpload: true` when an error occurs to allow retryAll

* Add assembly error message and assembly_id

* Pass debug option to Robodog

* Add forceAllowNewUpload to use in retry and retryAll, improve calls to _showOrLogErrorAndThrow

* Capitalize Create Assembly message

* don’t throw error from 'upload-error' event,  improved error message structure

* handle errors better

* check if error.details exists

* Doc tweaks: added error.assembly
2020-02-11 17:06:33 +01:00
Artur Paikin
d0f181caeb
core: Add noNewAlreadyUploading and noDuplicates (#2057)
* Add noNewAlreadyUploading and noDuplicates

* Update en_US.js

* fix test

* Update index.js

* Update en_US.js
2020-02-10 14:54:40 +01:00
Mohammed Shahim
6bef0a0314
Fix mime type checking bug (#2004)
* fix for mimetype issue #1988

* core: disregard mime parameters

Co-authored-by: Renée Kooi <renee@kooi.me>
2020-02-05 12:17:34 +01:00
Artur Paikin
d385d2c84e
Clear state error after the last file is removed (#2041) 2020-02-03 13:07:47 +03:00
Artur Paikin
1ea950d5d2
core: Always log errors (#2029)
* Show errors in logs always. nullLogger --> justErrorsLogger

Reasoning: too often we ended up showing errors in the Informer bubble, but not in the console, which is wrong and annoying. Devs still have an option to silence logs or direct them elsewhere by setting a custom logger

* Hide pause/resume buttons when error occures

* Update tests

* Update website/src/docs/uppy.md

Co-Authored-By: Renée Kooi <renee@kooi.me>

Co-authored-by: Renée Kooi <renee@kooi.me>
2020-01-28 18:45:23 +03:00
Artur Paikin
7eda2346a8
core: setState(modifiedFiles) in onBeforeUpload (#2028)
* Updating files in state, too, because uploader plugins receive file IDs only, not actual files

* Update doc examples with simpler spread syntax
2020-01-20 15:33:38 +03:00
Renée Kooi
1463ee79ce
Improve performance of adding and removing files (#1949)
* core: add an addFiles() method that only updates state once

Previously, adding 1300-ish files took around 260ms, and looked like
this in Firefox's performance tab:

![Flamegraph](https://i.imgur.com/08veuoU.png)

All of the downward peaks are `setState()` calls and GC.

Now it takes around 60ms, and looks like this:

![Flamegraph](https://i.imgur.com/xFdwVBV.png)

Here, most of the time is spent generating file IDs and guessing file
types. Those would be areas to look at next.

* dashboard: prevent frequent state update if nothing changed

After the last commit, `addFiles()` still spends a lot of time in
`emit()` and `hideAllPanels()`. The reason is that `addFiles()` still
emits all the hundreds of file-added events, and the Dashboard responds
to each with `hideAllPanels()`, which does a state update. But this all
happens synchronously, and the state almost certainly did not change
since the last `file-added` event that fired a millisecond ago.

This adds a check to avoid the state update if it is not necessary.

![Flamegraph](https://i.imgur.com/KhuD035.png)

Adding 1300 files takes about 40ms now.

With this change, the `addFiles()` call is no longer the slowest
part—now preact rendering all the items is!

* utils: optimize generateFileID and getFileNameAndExtension

Replaces some clever things with more mundane and faster things!

Now, generateFileID is a bunch of string concatenations.
Now, getFileNameAndExtension uses `lastIndexOf()` instead of a regex.

![Flamegraph](https://i.imgur.com/ZQ1IhxI.png)

Adding 1300 files takes about 25ms.

* dashboard: use preact-virtual-list

* thumbnail-generator: add `lazy` option

* dashboard: request thumbnails once file item renders the first time

* dashboard: fork preact-virtual-list

* core: add removeFiles() to remove files in bulk

* Implement removeFile() in terms of removeFiles()

* thumbnail-generator: only queue files that can be previewed

* rename size constants to accommodate WIDTH/HEIGHT

* Use new uppy.addFiles in DragDrop and FileInput

* utils: fix getFileNameAndExtension() type

* Rip out the lazy thumbnail generation

* Rip out virtualization.

* Remove virtualization leftovers

* tell future people that this is intentionally verbose

* Update package-lock.json

* henlo i am spell

* Make `addFiles()` respect maxNumberOfFiles

* core: show an informer error if some files fail in bulk add

* locales: fix quotes to make build:locale-pack happy

Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2020-01-13 12:29:08 +01:00
Alexis Hope
23b8e820ea Add reset-progress event to docs (#1922)
* document reset-progress event

* reword progress reset behaviour

* remove totalProgress reference
2019-11-08 18:03:52 +03:00
Artur Paikin
4e54483e61 core: setOptions for Core and plugins (#1728)
* Add a method to update options in Core

* Add a method to update options in Plugin (for any plugins)

* Allow re-initializing i18n locales after they’ve been updated with .setOptions

* use rest spread instead of Object.assign

* override setOptions in plugins to include i18nInit

* merge restrictions object in setOptions

* check that newOpts exists

* add spread ...

* don’t double merge

* add i18nInit to all plugins that use translation strings

* add setOptions tests to Core and Dashboard

* add setOptions docs for Core and Plugins

* fix tests for thumbnail-generator by adding plugins: {} to mock core

cause ThumbnailGenerator now calls this.setPluginState, which expects `core.state.plugins`

* also update meta with setOptions if it’s passed, change the way this.opts is set in core

@goto-bus-stop does this look ok? merging restrictions opts in core

* if locale was passed to setOptions(), call plugin.setOptions() on all plugins, so that i18n updates

* add Dashboard test that checks if locale is updated from Core via setOptions()

* Reafactor website Dashboard example to use setOptions and allow selecting a locale

🎉
2019-11-04 10:33:30 +01:00
Juliano
073937d512 fix: skip upload-success event for a file that has been removed (#1875)
* fix: skip upload-success event for a file that has been removed

* eslint --fix
2019-10-25 13:16:59 +02:00
Renée Kooi
50bbeb0245
core: provide default error message (#1880)
We were already doing `if (file.error)` in places, now that is
guaranteed to work even if the error message was empty or the error
object is custom and doesn't have a `.message` property.
2019-10-11 16:42:40 +02:00
Renée Kooi
733de659da
Upgrade standard to v14 (#1860)
* Update eslint dependencies.

* standard --fix

* build: disable handler name lint rule

* status-bar: manually fix lint errors

* webcam: manually fix lint errors

* url: manually fix lint errors

* react-native: manually fix lint errors

* dashboard: manually fix lint errors

* informer: manually fix linting errors

* progress-bar: manually fix lint errors

* provider-views: manually fix lint errors

* redux-dev-tools: manually fix lint errors

* build: disable buggy no-unused-vars rule

* examples: manually fix lint errors

* ` quotes for code things, ' for text things
2019-10-09 14:53:02 +02:00
Ifedapo .A. Olarewaju
c67262028c
Merge branch 'master' into revoke-provider-access 2019-09-25 19:34:57 +01:00
Artur Paikin
5f14ad576d Fix duplicate file test
failing because doing new File([sampleImage], { type: 'image/jpeg' }) twice resulted in a different lastModified
2019-09-20 19:31:25 +03:00
ifedapoolarewaju
c3fb49ee47
companion,companion-client,provider-views: revoke provider access on logout 2019-09-20 11:49:45 +01:00
Artur Paikin
e82ac0f137
core: Don’t add/overwrite existing files, allow duplicates from different folders (#1767)
* Add file.data.relativePath to the file.id

* Don’t add/overwrite a file if a file with the same id already exsists, issue a warning

* override @uppy/tus fingerprint to uppy’s file.id

* combine cordove/react native handling, don’t log twice

* always use onError for errors in addFile

* use file.meta.relativePath instead of file.data.relativePath

what do you think, @lakesare?

* update tests to include allowing/diallowing duplicates and file.id generation with relativePath

* update tus-js-client

* refactor error handling for addFile and upload into a mutual  _showOrLogErrorAndThrow method

* explain duplicate files and relativePath

* throw TypeError vs Error when allowedFileTypes is not an array

* fix tests

* tweak docs

* Emit restriction-failed for all restriction errors, move it to _showOrLogErrorAndThrow
2019-09-19 16:43:51 +03:00
Joe Duchnowski
17f862f2ac
Fix "Cannot read property 'log' of undefined" 2019-08-19 10:16:34 -04:00
Artur Paikin
ff7771b2cd
xhr-upload: Throw an error when trying to upload a remote file with bundle: true (#1769)
* Warn that we can’t bundle remote files when uploading in xhr-upload

* allow for `error` type logs in `onError` callback

* refactor error handling

* tweak error copy

* add Promise.reject

* throw always

* update docs to reflect that we now send global metadata with xhr, and that bundle: true is not possible with remote uploads
2019-08-16 18:38:54 +03:00
Renée Kooi
c62ec3665d Update eslint to v6 (#1777)
* Update eslint

* Do eslint --fix

* Do not access Object.prototype method 'hasOwnProperty' from target object

* utils: add hasProperty

* eslint --fix

* Disable quote-props for locale files

* add back quotes in locale files

* revert locale files to state on master

* Update react-scripts
2019-08-13 21:45:30 +03:00