diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index c954229aec..885efab7a8 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -122,16 +122,20 @@ module.exports = React.createClass({ this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']}); }, 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); - if (index !== -1) { - draft['uploadsInProgress'].splice(index, 1); + var index = draft['uploadsInProgress'].indexOf(clientId); + if (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() { this.setState({previews: []}); diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index 137420440a..377e7bd34e 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -145,16 +145,20 @@ module.exports = React.createClass({ this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']}); }, 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); - if (index !== -1) { - draft['uploadsInProgress'].splice(index, 1); + var index = draft['uploadsInProgress'].indexOf(clientId); + if (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) { var previews = this.state.previews; diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx index f1a06c3617..2bce1b5370 100644 --- a/web/react/components/file_upload.jsx +++ b/web/react/components/file_upload.jsx @@ -91,9 +91,6 @@ module.exports = React.createClass({ this.props.onUploadError(null); var files = e.originalEvent.dataTransfer.files; - if (!files.length) { - files = e.originalEvent.dataTransfer.getData('URL'); - } var channelId = this.props.channelId || ChannelStore.getCurrentId(); if (typeof files !== 'string' && files.length) { @@ -142,6 +139,8 @@ module.exports = React.createClass({ this.props.onUploadStart([clientId], channelId); } + } else { + this.props.onUploadError('Invalid file upload', -1); } }, componentDidMount: function() { @@ -149,7 +148,7 @@ module.exports = React.createClass({ var self = this; if (this.props.postType === 'post') { - $('.app__content').dragster({ + $('.row.main').dragster({ enter: function(dragsterEvent, e) { $('.center-file-overlay').removeClass('invisible'); $('.center-file-overlay').addClass('visible'); diff --git a/web/react/components/file_upload_overlay.jsx b/web/react/components/file_upload_overlay.jsx index 5f8ef0b0c2..a82f02af12 100644 --- a/web/react/components/file_upload_overlay.jsx +++ b/web/react/components/file_upload_overlay.jsx @@ -2,15 +2,15 @@ // See License.txt for license information. module.exports = React.createClass({ - displayName: 'FileUploadOverlay', - render: function() { - return ( -
-
- - Drop a file to upload it. -
-
- ); - } + displayName: 'FileUploadOverlay', + render: function() { + return ( +
+
+ + Drop a file to upload it. +
+
+ ); + } });