From d52a89cd3ef3e380b1f93356e2ea58fd79b60fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 27 Jul 2015 15:34:45 +0200 Subject: [PATCH 1/3] only display hashing toggle on user permissions --- .../ascribe_forms/form_register_piece.js | 2 +- .../ascribe_uploader/file_drag_and_drop.js | 4 ++-- .../file_drag_and_drop_dialog.js | 6 ++--- .../react_s3_fine_uploader.js | 23 +++++++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/js/components/ascribe_forms/form_register_piece.js b/js/components/ascribe_forms/form_register_piece.js index 3d97eb06..4b3ebe81 100644 --- a/js/components/ascribe_forms/form_register_piece.js +++ b/js/components/ascribe_forms/form_register_piece.js @@ -174,7 +174,7 @@ let FileUploader = React.createClass({ } }} multiple={false} - localHashing={false} /> + enableLocalHashing={true} /> ); } }); diff --git a/js/components/ascribe_uploader/file_drag_and_drop.js b/js/components/ascribe_uploader/file_drag_and_drop.js index 6e6feac1..51999e94 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop.js +++ b/js/components/ascribe_uploader/file_drag_and_drop.js @@ -30,7 +30,7 @@ let FileDragAndDrop = React.createClass({ areAssetsDownloadable: React.PropTypes.bool, areAssetsEditable: React.PropTypes.bool, - localHashing: React.PropTypes.bool, + enableLocalHashing: React.PropTypes.bool, // triggers a FileDragAndDrop-global spinner hashingProgress: React.PropTypes.number, @@ -177,7 +177,7 @@ let FileDragAndDrop = React.createClass({ multipleFiles={this.props.multiple} hasFiles={hasFiles} onClick={this.handleOnClick} - localHashing={this.props.localHashing}/> + enableLocalHashing={this.props.enableLocalHashing}/> file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0} hashingProgress={this.state.hashingProgress} - localHashing={this.props.localHashing} /> + enableLocalHashing={this.props.enableLocalHashing} /> ); } From 332366ec1587906496e52f72c24647df2559f336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 27 Jul 2015 16:00:54 +0200 Subject: [PATCH 2/3] Integrate dropzone inactivity into user flow --- .../ascribe_uploader/file_drag_and_drop.js | 4 ++++ .../ascribe_uploader/react_s3_fine_uploader.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/js/components/ascribe_uploader/file_drag_and_drop.js b/js/components/ascribe_uploader/file_drag_and_drop.js index 51999e94..ad176487 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop.js +++ b/js/components/ascribe_uploader/file_drag_and_drop.js @@ -82,6 +82,10 @@ let FileDragAndDrop = React.createClass({ event.stopPropagation(); let files; + if(this.props.dropzoneInactive) { + return; + } + // handle Drag and Drop if(event.dataTransfer && event.dataTransfer.files.length > 0) { files = event.dataTransfer.files; diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js index cdc91b16..9b40e6cb 100644 --- a/js/components/ascribe_uploader/react_s3_fine_uploader.js +++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js @@ -695,6 +695,17 @@ var ReactS3FineUploader = React.createClass({ this.setState(newState); }, + isDropzoneInactive() { + let filesToDisplay = this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1); + let queryParams = this.getQuery(); + + if((this.props.enableLocalHashing && !queryParams.method) || !this.props.areAssetsEditable || !this.props.multiple && filesToDisplay.length > 0) { + return true; + } else { + return false; + } + + }, render() { return ( @@ -711,7 +722,7 @@ var ReactS3FineUploader = React.createClass({ multiple={this.props.multiple} areAssetsDownloadable={this.props.areAssetsDownloadable} areAssetsEditable={this.props.areAssetsEditable} - dropzoneInactive={!this.props.areAssetsEditable || !this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0} + dropzoneInactive={this.isDropzoneInactive()} hashingProgress={this.state.hashingProgress} enableLocalHashing={this.props.enableLocalHashing} /> From 21fc2cee28c99e85da1f6c96142b720f971a2360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 27 Jul 2015 16:37:54 +0200 Subject: [PATCH 3/3] convert cancel hashing action to anchor --- js/components/ascribe_uploader/file_drag_and_drop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/components/ascribe_uploader/file_drag_and_drop.js b/js/components/ascribe_uploader/file_drag_and_drop.js index ad176487..9606f552 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop.js +++ b/js/components/ascribe_uploader/file_drag_and_drop.js @@ -161,7 +161,7 @@ let FileDragAndDrop = React.createClass({

{getLangText('Computing hash(es)... This may take a few minutes.')}

{Math.ceil(this.props.hashingProgress)}% - {getLangText('Cancel hashing')} + {getLangText('Cancel hashing')}