Better error checking along with other fixes
Этот коммит содержится в:
@@ -122,16 +122,20 @@ module.exports = React.createClass({
|
|||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']});
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']});
|
||||||
},
|
},
|
||||||
handleUploadError: function(err, clientId) {
|
handleUploadError: function(err, clientId) {
|
||||||
var draft = PostStore.getCommentDraft(this.props.rootId);
|
if (clientId !== -1) {
|
||||||
|
var draft = PostStore.getCommentDraft(this.props.rootId);
|
||||||
|
|
||||||
var index = draft['uploadsInProgress'].indexOf(clientId);
|
var index = draft['uploadsInProgress'].indexOf(clientId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
draft['uploadsInProgress'].splice(index, 1);
|
draft['uploadsInProgress'].splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostStore.storeCommentDraft(this.props.rootId, draft);
|
||||||
|
|
||||||
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
||||||
|
} else {
|
||||||
|
this.setState({serverError: err});
|
||||||
}
|
}
|
||||||
|
|
||||||
PostStore.storeCommentDraft(this.props.rootId, draft);
|
|
||||||
|
|
||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
|
||||||
},
|
},
|
||||||
clearPreviews: function() {
|
clearPreviews: function() {
|
||||||
this.setState({previews: []});
|
this.setState({previews: []});
|
||||||
|
|||||||
@@ -145,16 +145,20 @@ module.exports = React.createClass({
|
|||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']});
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']});
|
||||||
},
|
},
|
||||||
handleUploadError: function(err, clientId) {
|
handleUploadError: function(err, clientId) {
|
||||||
var draft = PostStore.getDraft(this.state.channelId);
|
if (clientId !== -1) {
|
||||||
|
var draft = PostStore.getDraft(this.state.channelId);
|
||||||
|
|
||||||
var index = draft['uploadsInProgress'].indexOf(clientId);
|
var index = draft['uploadsInProgress'].indexOf(clientId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
draft['uploadsInProgress'].splice(index, 1);
|
draft['uploadsInProgress'].splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostStore.storeDraft(this.state.channelId, draft);
|
||||||
|
|
||||||
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
||||||
|
} else {
|
||||||
|
this.setState({serverError: err});
|
||||||
}
|
}
|
||||||
|
|
||||||
PostStore.storeDraft(this.state.channelId, draft);
|
|
||||||
|
|
||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
|
||||||
},
|
},
|
||||||
removePreview: function(id) {
|
removePreview: function(id) {
|
||||||
var previews = this.state.previews;
|
var previews = this.state.previews;
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ module.exports = React.createClass({
|
|||||||
this.props.onUploadError(null);
|
this.props.onUploadError(null);
|
||||||
|
|
||||||
var files = e.originalEvent.dataTransfer.files;
|
var files = e.originalEvent.dataTransfer.files;
|
||||||
if (!files.length) {
|
|
||||||
files = e.originalEvent.dataTransfer.getData('URL');
|
|
||||||
}
|
|
||||||
var channelId = this.props.channelId || ChannelStore.getCurrentId();
|
var channelId = this.props.channelId || ChannelStore.getCurrentId();
|
||||||
|
|
||||||
if (typeof files !== 'string' && files.length) {
|
if (typeof files !== 'string' && files.length) {
|
||||||
@@ -142,6 +139,8 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
this.props.onUploadStart([clientId], channelId);
|
this.props.onUploadStart([clientId], channelId);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.props.onUploadError('Invalid file upload', -1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
@@ -149,7 +148,7 @@ module.exports = React.createClass({
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this.props.postType === 'post') {
|
if (this.props.postType === 'post') {
|
||||||
$('.app__content').dragster({
|
$('.row.main').dragster({
|
||||||
enter: function(dragsterEvent, e) {
|
enter: function(dragsterEvent, e) {
|
||||||
$('.center-file-overlay').removeClass('invisible');
|
$('.center-file-overlay').removeClass('invisible');
|
||||||
$('.center-file-overlay').addClass('visible');
|
$('.center-file-overlay').addClass('visible');
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'FileUploadOverlay',
|
displayName: 'FileUploadOverlay',
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div className='center-file-overlay invisible'>
|
<div className='file-overlay center-file-overlay invisible'>
|
||||||
<div>
|
<div>
|
||||||
<i className='fa fa-upload'></i>
|
<i className='fa fa-upload'></i>
|
||||||
<span>Drop a file to upload it.</span>
|
<span>Drop a file to upload it.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user