diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js
index 74584ba3..7dfc9570 100644
--- a/js/components/ascribe_detail/piece_container.js
+++ b/js/components/ascribe_detail/piece_container.js
@@ -85,6 +85,7 @@ let PieceContainer = React.createClass({
// store as it will otherwise display wrong/old data once the user loads
// the piece detail a second time
PieceActions.updatePiece({});
+
this.loadPiece();
UserActions.fetchCurrentUser();
},
@@ -92,7 +93,7 @@ let PieceContainer = React.createClass({
componentDidUpdate() {
const { pieceError } = this.state;
- if(pieceError && pieceError.status === 404) {
+ if (pieceError && pieceError.status === 404) {
this.throws(new ResourceNotFoundError(getLangText("Oops, the piece you're looking for doesn't exist.")));
}
},
diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js
index a2b7b9bc..d4002e85 100644
--- a/js/components/ascribe_forms/form.js
+++ b/js/components/ascribe_forms/form.js
@@ -182,7 +182,7 @@ let Form = React.createClass({
delete formData.password;
}
- console.logGlobal(err, false, formData);
+ console.logGlobal(err, formData);
if(this.props.isInline) {
let notification = new GlobalNotificationModel(getLangText('Something went wrong, please try again later'), 'danger');
diff --git a/js/components/ascribe_forms/form_login.js b/js/components/ascribe_forms/form_login.js
index 8b7c1e23..a604850d 100644
--- a/js/components/ascribe_forms/form_login.js
+++ b/js/components/ascribe_forms/form_login.js
@@ -93,7 +93,6 @@ let LoginForm = React.createClass({
@@ -103,7 +102,6 @@ let LoginForm = React.createClass({
diff --git a/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js b/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js
index 5848bca1..6612f968 100644
--- a/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js
+++ b/js/components/ascribe_uploader/ascribe_upload_button/upload_button.js
@@ -71,17 +71,9 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
handleOnClick() {
if(!this.state.disabled) {
let evt;
- const uploadingFiles = this.getUploadingFiles();
- const uploadedFile = this.getUploadedFile();
- this.clearSelection();
- if(uploadingFiles.length) {
- this.props.handleCancelFile(uploadingFiles[0].id);
- } else if(uploadedFile && !uploadedFile.s3UrlSafe) {
- this.props.handleCancelFile(uploadedFile.id);
- } else if(uploadedFile && uploadedFile.s3UrlSafe) {
- this.props.handleDeleteFile(uploadedFile.id);
- }
+ // First, remove any currently uploading or uploaded items
+ this.onClickRemove();
try {
evt = new MouseEvent('click', {
@@ -99,18 +91,19 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
}
},
- onClickCancel() {
- this.clearSelection();
- const uploadingFile = this.getUploadingFiles()[0];
- this.props.handleCancelFile(uploadingFile.id);
- },
-
onClickRemove() {
- this.clearSelection();
+ const uploadingFiles = this.getUploadingFiles();
const uploadedFile = this.getUploadedFile();
- this.props.handleDeleteFile(uploadedFile.id);
- },
+ this.clearSelection();
+ if(uploadingFiles.length) {
+ this.props.handleCancelFile(uploadingFiles[0].id);
+ } else if(uploadedFile && !uploadedFile.s3UrlSafe) {
+ this.props.handleCancelFile(uploadedFile.id);
+ } else if(uploadedFile && uploadedFile.s3UrlSafe) {
+ this.props.handleDeleteFile(uploadedFile.id);
+ }
+ },
getButtonLabel() {
let { filesToUpload, fileClassToUpload } = this.props;
@@ -133,7 +126,7 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
return (
{' ' + truncateTextAtCharIndex(uploadingFiles[0].name, 40) + ' '}
- [{getLangText('cancel upload')}]
+ [{getLangText('cancel upload')}]
);
} else if(uploadedFile) {
@@ -193,4 +186,4 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
);
}
});
-}
\ No newline at end of file
+}
diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js
index 67b19e02..eb211504 100644
--- a/js/components/ascribe_uploader/react_s3_fine_uploader.js
+++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js
@@ -344,6 +344,7 @@ const ReactS3FineUploader = React.createClass({
// still we warn the user of this component
console.warn('createBlobRoutine was not defined for ReactS3FineUploader. Continuing without creating the blob on the server.');
resolve();
+ return;
}
window.fetch(createBlobRoutine.url, {
@@ -439,7 +440,7 @@ const ReactS3FineUploader = React.createClass({
onComplete(id, name, res, xhr) {
// There has been an issue with the server's connection
if (xhr && xhr.status === 0 && res.success) {
- console.logGlobal(new Error('Upload succeeded with a status code 0'), false, {
+ console.logGlobal(new Error('Upload succeeded with a status code 0'), {
files: this.state.filesToUpload,
chunks: this.state.chunks,
xhr: this.getXhrErrorComment(xhr)
@@ -497,7 +498,7 @@ const ReactS3FineUploader = React.createClass({
},
onError(id, name, errorReason, xhr) {
- console.logGlobal(errorReason, false, {
+ console.logGlobal(errorReason, {
files: this.state.filesToUpload,
chunks: this.state.chunks,
xhr: this.getXhrErrorComment(xhr)
diff --git a/js/components/header.js b/js/components/header.js
index c18ebd5b..797684ec 100644
--- a/js/components/header.js
+++ b/js/components/header.js
@@ -16,12 +16,13 @@ import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import AclProxy from './acl_proxy';
+import EventActions from '../actions/event_actions';
+
import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store';
import WhitelabelActions from '../actions/whitelabel_actions';
import WhitelabelStore from '../stores/whitelabel_store';
-import EventActions from '../actions/event_actions';
import HeaderNotifications from './header_notification';
@@ -58,6 +59,19 @@ let Header = React.createClass({
// close the mobile expanded navigation after a click by itself.
// To get rid of this, we set the state of the component ourselves.
history.listen(this.onRouteChange);
+
+ if (this.state.currentUser && this.state.currentUser.email) {
+ EventActions.profileDidLoad.defer(this.state.currentUser);
+ }
+ },
+
+ componentWillUpdate(nextProps, nextState) {
+ const { currentUser: { email: curEmail } = {} } = this.state;
+ const { currentUser: { email: nextEmail } = {} } = nextState;
+
+ if (nextEmail && curEmail !== nextEmail) {
+ EventActions.profileDidLoad.defer(nextState.currentUser);
+ }
},
componentWillUnmount() {
@@ -105,10 +119,6 @@ let Header = React.createClass({
onChange(state) {
this.setState(state);
-
- if(this.state.currentUser && this.state.currentUser.email) {
- EventActions.profileDidLoad.defer(this.state.currentUser);
- }
},
onMenuItemClick() {
diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js
index 41f2c25a..a8d946b5 100644
--- a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js
+++ b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js
@@ -75,7 +75,7 @@ const PRRegisterPieceForm = React.createClass({
const additionalDataFormData = additionalDataForm.getFormData();
// composing data for piece registration
- let registerPieceFormData = registerPieceForm.getFormData();
+ const registerPieceFormData = registerPieceForm.getFormData();
registerPieceFormData.digital_work_key = digitalWorkKey.state.value;
registerPieceFormData.thumbnail_file = thumbnailKey.state.value;
registerPieceFormData.terms = true;
@@ -83,33 +83,33 @@ const PRRegisterPieceForm = React.createClass({
// submitting the piece
requests
.post(ApiUrls.pieces_list, { body: registerPieceFormData })
- .then(({ success, piece, notification }) => {
- if(success) {
- this.setState({
- piece
- }, () => {
- supportingMaterials.refs.input.createBlobRoutine();
- proofOfPayment.refs.input.createBlobRoutine();
- });
+ .then(({ piece, notification }) => {
+ this.setState({piece}, () => {
+ supportingMaterials.refs.input.createBlobRoutine();
+ proofOfPayment.refs.input.createBlobRoutine();
+ });
- setCookie(currentUser.email, piece.id);
+ setCookie(currentUser.email, piece.id);
- return requests.post(ApiUrls.piece_extradata, {
+ return requests
+ .post(ApiUrls.piece_extradata, {
body: {
extradata: additionalDataFormData,
piece_id: piece.id
},
piece_id: piece.id
+ })
+ .then(() => {
+ const notificationMessage = new GlobalNotificationModel(notification || getLangText('You have successfully submitted "%s" to Portfolio Review 2015', piece.title), 'success', 5000);
+ GlobalNotificationActions.appendGlobalNotification(notificationMessage);
});
- } else {
- const notificationMessage = new GlobalNotificationModel(notification, 'danger', 5000);
- GlobalNotificationActions.appendGlobalNotification(notificationMessage);
- }
})
.then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`))
- .catch(() => {
- const notificationMessage = new GlobalNotificationModel(getLangText("Ups! We weren't able to send your submission. Contact: support@ascribe.io"), 'danger', 5000);
+ .catch((err) => {
+ const notificationMessage = new GlobalNotificationModel(getLangText("Oops! We weren't able to send your submission. Contact: support@ascribe.io"), 'danger', 5000);
GlobalNotificationActions.appendGlobalNotification(notificationMessage);
+
+ console.logGlobal(new Error('Portfolio Review piece registration failed'), err);
});
},
@@ -167,7 +167,7 @@ const PRRegisterPieceForm = React.createClass({
} else {
return (