From a8120867b9125dd49bad2b0e8c3ac08a496abc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 30 Jun 2015 16:58:26 +0200 Subject: [PATCH 1/9] add call to action on empty piece list --- js/components/ascribe_accordion_list/accordion_list.js | 5 ++++- js/components/register_piece.js | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/components/ascribe_accordion_list/accordion_list.js b/js/components/ascribe_accordion_list/accordion_list.js index 4fa7d9d9..454e6dbc 100644 --- a/js/components/ascribe_accordion_list/accordion_list.js +++ b/js/components/ascribe_accordion_list/accordion_list.js @@ -18,7 +18,10 @@ let AccordionList = React.createClass({ ); } else if(this.props.itemList.length === 0) { return ( -

You don't have any works yet...

+
+

You don't have any works yet...

+

To register one, click here!

+
); } else { return ( diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 2e7fc184..44fc61b4 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -2,7 +2,6 @@ import React from 'react'; -import { getCookie } from '../utils/fetch_api_utils'; import AppConstants from '../constants/application_constants'; import Router from 'react-router'; From 26442c92300a671fe46aeac1adc5a64b00d7f2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 30 Jun 2015 17:12:13 +0200 Subject: [PATCH 2/9] add margins to button lists --- js/components/ascribe_buttons/acl_button.js | 4 ++-- .../piece_list_bulk_modal.js | 2 +- js/components/edition.js | 12 ++++++------ sass/main.scss | 4 ++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js index 526581c8..e31460c2 100644 --- a/js/components/ascribe_buttons/acl_button.js +++ b/js/components/ascribe_buttons/acl_button.js @@ -74,9 +74,9 @@ let AclButton = React.createClass({ return ( + } handleSuccess={ aclProps.handleSuccess } title={ aclProps.title } diff --git a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js index c50c09fd..f302374e 100644 --- a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js +++ b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js @@ -102,7 +102,7 @@ let PieceListBulkModal = React.createClass({ availableAcls={availableAcls} editions={selectedEditions} handleSuccess={this.handleSuccess} - className="text-center"/> + className="text-center ascribe-button-list"/> diff --git a/js/components/edition.js b/js/components/edition.js index 3d2193ae..073bb952 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -253,7 +253,7 @@ let EditionSummary = React.createClass({ @@ -577,14 +577,14 @@ let CoaDetails = React.createClass({ if (this.state.coa.url_safe) { return (
-

- + - +

diff --git a/sass/main.scss b/sass/main.scss index 4b7230bb..681e5149 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -242,3 +242,7 @@ body { .col-bottom { vertical-align: bottom; } + +.ascribe-button-list button { + margin-right: 1em; +} \ No newline at end of file From 929c694ad739f16717503ca6c088b6185bffbf6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 30 Jun 2015 17:57:20 +0200 Subject: [PATCH 3/9] finalized delete functionality --- .../ascribe_uploader/file_drag_and_drop.js | 2 +- .../file_drag_and_drop_preview_iterator.js | 2 +- .../ascribe_uploader/react_s3_fine_uploader.js | 7 +++++-- js/utils/requests.js | 14 +++++++++++++- sass/main.scss | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/js/components/ascribe_uploader/file_drag_and_drop.js b/js/components/ascribe_uploader/file_drag_and_drop.js index 5879a2ef..28c87677 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop.js +++ b/js/components/ascribe_uploader/file_drag_and_drop.js @@ -133,7 +133,7 @@ let FileDragAndDrop = React.createClass({ render: function () { // has files only is true if there are files that do not have the status deleted or canceled - let hasFiles = this.props.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled').length > 0; + let hasFiles = this.props.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0; let className = hasFiles ? 'has-files ' : ''; className += this.props.dropzoneInactive ? 'inactive-dropzone' : 'active-dropzone'; className += this.props.className ? ' ' + this.props.className : ''; diff --git a/js/components/ascribe_uploader/file_drag_and_drop_preview_iterator.js b/js/components/ascribe_uploader/file_drag_and_drop_preview_iterator.js index 8d8171ff..896d9f1f 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop_preview_iterator.js +++ b/js/components/ascribe_uploader/file_drag_and_drop_preview_iterator.js @@ -19,7 +19,7 @@ let FileDragAndDropPreviewIterator = React.createClass({ return (
{this.props.files.map((file, i) => { - if(file.status !== 'deleted' && file.status !== 'canceled') { + if(file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1) { return ( this.onDeleteComplete(fileToDelete.id, null, false)) @@ -417,7 +420,7 @@ var ReactS3FineUploader = React.createClass({ }, handleUploadFile(files) { - + console.log(this.state.files); // If multiple set and user already uploaded its work, // cancel upload if(!this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled').length > 0) { @@ -512,7 +515,7 @@ var ReactS3FineUploader = React.createClass({ handleResumeFile={this.handleResumeFile} multiple={this.props.multiple} areAssetsDownloadable={this.props.areAssetsDownloadable} - dropzoneInactive={!this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled').length > 0} /> + dropzoneInactive={!this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0} />
); } diff --git a/js/utils/requests.js b/js/utils/requests.js index e10a8a99..7e42dfee 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -27,6 +27,17 @@ class Requests { return response.text(); } + customJSONparse(responseText) { + // If the responses' body does not contain any data, + // fetch will resolve responseText to the string 'None'. + // If this is the case, we can not try to parse it as JSON. + if(responseText !== 'None') { + return JSON.parse(responseText); + } else { + return {}; + } + } + handleFatalError(err) { this.fatalErrorHandler(err); throw new ServerError(err); @@ -36,6 +47,7 @@ class Requests { if (!json.success) { let error = new APIError(); error.json = json; + console.error(new Error('The \'success\' property is missing in the server\'s response.')); throw error; } return json; @@ -83,7 +95,7 @@ class Requests { merged.method = verb; return fetch(url, merged) .then(this.unpackResponse) - .then(JSON.parse) + .then(this.customJSONparse) .catch(this.handleFatalError.bind(this)) .then(this.handleAPIError); } diff --git a/sass/main.scss b/sass/main.scss index 681e5149..d8d5345e 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -244,5 +244,5 @@ body { } .ascribe-button-list button { - margin-right: 1em; + margin-right: 1px; } \ No newline at end of file From 1db9921dd84af069313dcebfa23036a05ef44e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 1 Jul 2015 10:00:53 +0200 Subject: [PATCH 4/9] use safe urls for thumbnails and links --- .../ascribe_uploader/file_drag_and_drop_preview.js | 4 ++-- .../file_drag_and_drop_preview_image.js | 4 ++-- .../file_drag_and_drop_preview_other.js | 4 ++-- .../ascribe_uploader/react_s3_fine_uploader.js | 10 +++++++--- sass/ascribe_uploader.scss | 8 ++++++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/js/components/ascribe_uploader/file_drag_and_drop_preview.js b/js/components/ascribe_uploader/file_drag_and_drop_preview.js index 84853018..c58f6a38 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop_preview.js +++ b/js/components/ascribe_uploader/file_drag_and_drop_preview.js @@ -57,7 +57,7 @@ let FileDragAndDropPreview = React.createClass({ url={this.props.file.url} toggleUploadProcess={this.toggleUploadProcess} areAssetsDownloadable={this.props.areAssetsDownloadable} - downloadFile={this.handleDownloadFile}/>); + downloadUrl={this.props.file.s3UrlSafe}/>); } else { previewElement = (); + downloadUrl={this.props.file.s3UrlSafe}/>); } return ( diff --git a/js/components/ascribe_uploader/file_drag_and_drop_preview_image.js b/js/components/ascribe_uploader/file_drag_and_drop_preview_image.js index 1cbf67e6..04d35a47 100644 --- a/js/components/ascribe_uploader/file_drag_and_drop_preview_image.js +++ b/js/components/ascribe_uploader/file_drag_and_drop_preview_image.js @@ -10,7 +10,7 @@ let FileDragAndDropPreviewImage = React.createClass({ progress: React.PropTypes.number, url: React.PropTypes.string, toggleUploadProcess: React.PropTypes.func, - downloadFile: React.PropTypes.func, + downloadUrl: React.PropTypes.string, areAssetsDownloadable: React.PropTypes.bool }, @@ -48,7 +48,7 @@ let FileDragAndDropPreviewImage = React.createClass({ // only if assets are actually downloadable, there should be a download icon if the process is already at // 100%. If not, no actionSymbol should be displayed if(this.props.areAssetsDownloadable) { - actionSymbol =