In case an error occurs while uploading a file, we'd need to improve visual feedback.
For instance, web ui being deployed behind an nginx proxy with file size limit (see https://github.com/nuxeo/nuxeo-web-ui/commit/3c31848a8a2daa58afa83211cca802860b2993ea), we receive a 413 http response and the error is only visible in the dev tool console.
We would like to add a better error feedback for nuxeo-file and nuxeo-dropzone elements.
A simple solution was leveraging the validation behavior of the element to flag the widget invalid. But we may want a better, cleaner (and more global?) error feedback.
fox@fox-xps:~/workspace/nuxeo-web-ui$ git diff diff --git i/elements/nuxeo-dropzone/nuxeo-dropzone.js w/elements/nuxeo-dropzone/nuxeo-dropzone.js index ac05da6a..3c72122e 100644 --- i/elements/nuxeo-dropzone/nuxeo-dropzone.js +++ w/elements/nuxeo-dropzone/nuxeo-dropzone.js @@ -319,6 +319,8 @@ Polymer({ listeners: { batchFinished: 'importBatch', 'nx-blob-picked': '_blobPicked', + uploadInterrupted: '_handleError', + batchFailed: '_handleError', }, observers: ['_reset(document)', '_filesChanged(files.splices)'], @@ -538,4 +540,11 @@ Polymer({ } return this.files && this.files.length > 0; }, + + _handleError(e) { + if (e.detail && e.detail.error && e.detail.error.response && e.detail.error.response.status) { + this.invalid = true; + this._errorMessage = this.i18n(`dropzone.invalid.httpStatusCode.${e.error.response.status}`); + } + }, }); diff --git i/i18n/messages.json w/i18n/messages.json index aa8b11b5..3607fb40 100644 --- i/i18n/messages.json +++ w/i18n/messages.json @@ -535,6 +535,7 @@ "driveSyncToggleButton.unsync": "Unsynchronize", "dropzone.abort": "Abort file upload", "dropzone.add": "Upload main file", + "dropzone.invalid.httpStatusCode.413": "File size exceeded", "dropzone.invalid.uploading": "File upload pending", "dropzone.dropFile": "Drop your file", "dropzone.uploaded": "File uploaded",
- is related to
-
ELEMENTS-1123 Improve nuxeo-dropzone UX
- Open
-
DESIGN-268 Give feedback to the user when trying to drag invalid types of files to the dropzone
- Resolved
-
NXP-27803 Validate nuxeo-dropzone to check pending upload and required
- Resolved