mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
finalized delete functionality
This commit is contained in:
parent
bb73416a8c
commit
929c694ad7
@ -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 : '';
|
||||
|
@ -19,7 +19,7 @@ let FileDragAndDropPreviewIterator = React.createClass({
|
||||
return (
|
||||
<div>
|
||||
{this.props.files.map((file, i) => {
|
||||
if(file.status !== 'deleted' && file.status !== 'canceled') {
|
||||
if(file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1) {
|
||||
return (
|
||||
<FileDragAndDropPreview
|
||||
key={i}
|
||||
|
@ -345,6 +345,7 @@ var ReactS3FineUploader = React.createClass({
|
||||
let newState = React.addons.update(this.state, {filesToUpload: {$set: updatedFilesToUpload}});
|
||||
this.setState(newState);
|
||||
} else {
|
||||
// server has to respond with 204
|
||||
//let notification = new GlobalNotificationModel('Could not load attached files (Further data)', 'danger', 10000);
|
||||
//GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
//
|
||||
@ -388,6 +389,8 @@ var ReactS3FineUploader = React.createClass({
|
||||
// promise
|
||||
} else {
|
||||
let fileToDelete = this.state.filesToUpload[fileId];
|
||||
fileToDelete.status = 'deleted';
|
||||
console.log(this.state.uploader.getUploads());
|
||||
S3Fetcher
|
||||
.deleteFile(fileToDelete.s3Key, fileToDelete.s3Bucket)
|
||||
.then(() => 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} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -244,5 +244,5 @@ body {
|
||||
}
|
||||
|
||||
.ascribe-button-list button {
|
||||
margin-right: 1em;
|
||||
margin-right: 1px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user