From edeec39548e3f5b581e6243f9ecdfe5026872ec9 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 8 Dec 2015 20:25:18 +0100 Subject: [PATCH] Small fixes for upload error behaviour * Change error dialog text slightly * Only show global notification on first error * Only create the S3 blob if the response is successful --- .../file_drag_and_drop_error_dialog.js | 4 ++-- .../ascribe_uploader/react_s3_fine_uploader.js | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_error_dialog.js b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_error_dialog.js index 326f727f..8696cc7f 100644 --- a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_error_dialog.js +++ b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_error_dialog.js @@ -24,7 +24,7 @@ let FileDragAndDropErrorDialog = React.createClass({ className='btn btn-default' onClick={() => { if (openIntercom) { - window.Intercom('showNewMessage', getLangText("I'm having trouble with uploading my file: ")); + window.Intercom('showNewMessage', getLangText("I'm having trouble uploading my file.")); } this.retryAllFiles() @@ -38,7 +38,7 @@ let FileDragAndDropErrorDialog = React.createClass({ return (

Let us help you

-

{getLangText('Still having problems? Give us a call!')}

+

{getLangText('Still having problems? Send us a message!')}

{this.getRetryButton('Contact us', true)}
); diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js index b022fe27..a9dd1039 100644 --- a/js/components/ascribe_uploader/react_s3_fine_uploader.js +++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js @@ -547,7 +547,7 @@ const ReactS3FineUploader = React.createClass({ xhr: this.getXhrErrorComment(xhr) }); // onError will catch any errors, so we can ignore them here - } else if (!res.error || res.success) { + } else if (!res.error && res.success) { let files = this.state.filesToUpload; // Set the state of the completed file to 'upload successful' in order to @@ -596,13 +596,13 @@ const ReactS3FineUploader = React.createClass({ let notificationMessage; if (showErrorPrompt) { - notificationMessage = errorNotificationMessage; - this.setStatusOfFile(id, FileStatus.UPLOAD_FAILED); // If we've already found an error on this upload, just ignore other errors // that pop up. They'll likely pop up again when the user retries. if (!this.state.errorState.errorClass) { + notificationMessage = errorNotificationMessage; + const errorState = React.addons.update(this.state.errorState, { errorClass: { $set: this.getUploadErrorClass({ @@ -620,8 +620,10 @@ const ReactS3FineUploader = React.createClass({ this.cancelUploads(); } - const notification = new GlobalNotificationModel(notificationMessage, 'danger', 5000); - GlobalNotificationActions.appendGlobalNotification(notification); + if (notificationMessage) { + const notification = new GlobalNotificationModel(notificationMessage, 'danger', 5000); + GlobalNotificationActions.appendGlobalNotification(notification); + } }, onCancel(id) { @@ -1061,7 +1063,7 @@ const ReactS3FineUploader = React.createClass({ uploadMethod } = this.props; // Only show the error state once all files are finished - const showError = !uploadInProgress && showErrorPrompt && errorClass; + const showError = !uploadInProgress && showErrorPrompt && errorClass != null; const props = { multiple,