diff --git a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js index 9dcaf7f3..5528ec25 100644 --- a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js +++ b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview.js @@ -41,14 +41,21 @@ const FileDragAndDropPreview = React.createClass({ }, handleDeleteFile() { - // handleDeleteFile is optional, so if its not submitted, - // don't run it - // On the other hand, if the files progress is not yet at a 100%, - // just run fineuploader.cancel - if(this.props.handleDeleteFile && this.props.file.progress === 100) { - this.props.handleDeleteFile(this.props.file.id); - } else if(this.props.handleCancelFile && this.props.file.progress !== 100) { - this.props.handleCancelFile(this.props.file.id); + const { handleDeleteFile, + handleCancelFile, + file } = this.props; + // `handleDeleteFile` is optional, so if its not submitted, don't run it + // + // For delete though, we only want to trigger it, when we're sure that + // the file has *completely* been uploaded to S3 and call now also be + // deleted using an HTTP DELETE request. + if (handleDeleteFile && + file.progress === 100 && + (file.status === 'upload successful' || file.status === 'online') && + file.s3UrlSafe) { + handleDeleteFile(file.id); + } else if(handleCancelFile) { + handleCancelFile(file.id); } }, @@ -107,7 +114,8 @@ const FileDragAndDropPreview = React.createClass({ url={file.url} toggleUploadProcess={this.toggleUploadProcess} areAssetsDownloadable={areAssetsDownloadable} - downloadUrl={file.s3UrlSafe}/> + downloadUrl={file.s3UrlSafe} + showProgress={numberOfDisplayedFiles > 1} /> ); } else { previewElement = ( @@ -117,7 +125,8 @@ const FileDragAndDropPreview = React.createClass({ type={file.type.split('/')[1]} toggleUploadProcess={this.toggleUploadProcess} areAssetsDownloadable={areAssetsDownloadable} - downloadUrl={file.s3UrlSafe}/> + downloadUrl={file.s3UrlSafe} + showProgress={numberOfDisplayedFiles > 1} /> ); } diff --git a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_image.js b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_image.js index 502b11c1..b5cf4694 100644 --- a/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_image.js +++ b/js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop_preview_image.js @@ -3,6 +3,7 @@ import React from 'react'; import ProgressBar from 'react-bootstrap/lib/ProgressBar'; +import AclProxy from '../../acl_proxy'; import AscribeSpinner from '../../ascribe_spinner'; import { getLangText } from '../../../utils/lang_utils'; @@ -15,7 +16,8 @@ const FileDragAndDropPreviewImage = React.createClass({ url: string, toggleUploadProcess: func, downloadUrl: string, - areAssetsDownloadable: bool + areAssetsDownloadable: bool, + showProgress: bool }, getInitialState() { @@ -36,40 +38,45 @@ const FileDragAndDropPreviewImage = React.createClass({ }, render() { - let imageStyle = { - backgroundImage: 'url("' + this.props.url + '")', + const { url, + progress, + areAssetsDownloadable, + downloadUrl, + showProgress } = this.props; + const imageStyle = { + backgroundImage: 'url("' + url + '")', backgroundSize: 'cover' }; let actionSymbol; - if(this.props.progress > 0 && this.props.progress < 99 && this.state.paused) { - actionSymbol =