Better error checking along with other fixes
Этот коммит содержится в:
@@ -122,6 +122,7 @@ 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) {
|
||||||
|
if (clientId !== -1) {
|
||||||
var draft = PostStore.getCommentDraft(this.props.rootId);
|
var draft = PostStore.getCommentDraft(this.props.rootId);
|
||||||
|
|
||||||
var index = draft['uploadsInProgress'].indexOf(clientId);
|
var index = draft['uploadsInProgress'].indexOf(clientId);
|
||||||
@@ -132,6 +133,9 @@ module.exports = React.createClass({
|
|||||||
PostStore.storeCommentDraft(this.props.rootId, draft);
|
PostStore.storeCommentDraft(this.props.rootId, draft);
|
||||||
|
|
||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
||||||
|
} else {
|
||||||
|
this.setState({serverError: err});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
clearPreviews: function() {
|
clearPreviews: function() {
|
||||||
this.setState({previews: []});
|
this.setState({previews: []});
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ 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) {
|
||||||
|
if (clientId !== -1) {
|
||||||
var draft = PostStore.getDraft(this.state.channelId);
|
var draft = PostStore.getDraft(this.state.channelId);
|
||||||
|
|
||||||
var index = draft['uploadsInProgress'].indexOf(clientId);
|
var index = draft['uploadsInProgress'].indexOf(clientId);
|
||||||
@@ -155,6 +156,9 @@ module.exports = React.createClass({
|
|||||||
PostStore.storeDraft(this.state.channelId, draft);
|
PostStore.storeDraft(this.state.channelId, draft);
|
||||||
|
|
||||||
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
|
||||||
|
} else {
|
||||||
|
this.setState({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');
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user