{/*
The button needs to be of `type="button"` as it would
otherwise submit the form its in.
diff --git a/js/components/ascribe_uploader/react_s3_fine_uploader.js b/js/components/ascribe_uploader/react_s3_fine_uploader.js
index 877146a5..feb0479d 100644
--- a/js/components/ascribe_uploader/react_s3_fine_uploader.js
+++ b/js/components/ascribe_uploader/react_s3_fine_uploader.js
@@ -36,17 +36,11 @@ const ReactS3FineUploader = React.createClass({
keyRoutine: shape({
url: string,
fileClass: string,
- pieceId: oneOfType([
- string,
- number
- ])
+ pieceId: number
}),
createBlobRoutine: shape({
url: string,
- pieceId: oneOfType([
- string,
- number
- ])
+ pieceId: number
}),
handleChangedFile: func, // is for when a file is dropped or selected
submitFile: func, // is for when a file has been successfully uploaded, TODO: rename to handleSubmitFile
diff --git a/js/components/global_action.js b/js/components/global_action.js
deleted file mode 100644
index 80df0c75..00000000
--- a/js/components/global_action.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-
-import React from 'react';
-
-let GlobalAction = React.createClass({
- propTypes: {
- requestActions: React.PropTypes.object
- },
-
- render() {
- let pieceActions = null;
- if (this.props.requestActions && this.props.requestActions.pieces){
- pieceActions = this.props.requestActions.pieces.map((item) => {
- return (
-
- {item}
-
);
- });
- }
- let editionActions = null;
- if (this.props.requestActions && this.props.requestActions.editions){
- editionActions = Object.keys(this.props.requestActions.editions).map((pieceId) => {
- return this.props.requestActions.editions[pieceId].map((item) => {
- return (
-
- {item}
-
);
- });
- });
- }
-
- if (pieceActions || editionActions) {
- return (
-
- {pieceActions}
- {editionActions}
-
);
- }
- return null;
- }
-});
-
-export default GlobalAction;
\ No newline at end of file
diff --git a/js/components/password_reset_container.js b/js/components/password_reset_container.js
index 31275a08..6d2d089e 100644
--- a/js/components/password_reset_container.js
+++ b/js/components/password_reset_container.js
@@ -130,8 +130,9 @@ let PasswordResetForm = React.createClass({
},
handleSuccess() {
- this.history.pushState(null, '/collection');
- let notification = new GlobalNotificationModel(getLangText('password successfully updated'), 'success', 10000);
+ this.history.push('/collection');
+
+ const notification = new GlobalNotificationModel(getLangText('password successfully updated'), 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
diff --git a/js/components/piece_list.js b/js/components/piece_list.js
index de979e65..666d1b54 100644
--- a/js/components/piece_list.js
+++ b/js/components/piece_list.js
@@ -115,13 +115,13 @@ let PieceList = React.createClass({
},
componentDidUpdate() {
- const { redirectTo, shouldRedirect } = this.props;
+ const { location: { query }, redirectTo, shouldRedirect } = this.props;
const { unfilteredPieceListCount } = this.state;
if (redirectTo && unfilteredPieceListCount === 0 &&
(typeof shouldRedirect === 'function' && shouldRedirect(unfilteredPieceListCount))) {
// FIXME: hack to redirect out of the dispatch cycle
- window.setTimeout(() => this.history.pushState(null, this.props.redirectTo, this.props.location.query), 0);
+ window.setTimeout(() => this.history.push({ query, pathname: redirectTo }), 0);
}
},
@@ -174,15 +174,16 @@ let PieceList = React.createClass({
}
},
- searchFor(searchTerm) {
- this.loadPieceList({
- page: 1,
- search: searchTerm
- });
- this.history.pushState(null, this.props.location.pathname, {page: 1});
+ searchFor(search) {
+ const { location: { pathname } } = this.props;
+
+ this.loadPieceList({ search, page: 1 });
+ this.history.push({ pathname, query: { page: 1 } });
},
- applyFilterBy(filterBy){
+ applyFilterBy(filterBy) {
+ const { location: { pathname } } = this.props;
+
this.setState({
isFilterDirty: true
});
@@ -195,31 +196,32 @@ let PieceList = React.createClass({
this.state.pieceList
.forEach((piece) => {
// but only if they're actually open
- if(this.state.isEditionListOpenForPieceId[piece.id].show) {
+ const isEditionListOpenForPiece = this.state.isEditionListOpenForPieceId[piece.id];
+
+ if (isEditionListOpenForPiece && isEditionListOpenForPiece.show) {
EditionListActions.refreshEditionList({
pieceId: piece.id,
filterBy
});
}
-
});
});
// we have to redirect the user always to page one as it could be that there is no page two
// for filtered pieces
- this.history.pushState(null, this.props.location.pathname, {page: 1});
+ this.history.push({ pathname, query: { page: 1 } });
},
applyOrderBy(orderBy) {
- PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
- orderBy, this.state.orderAsc, this.state.filterBy);
+ const { filterBy, orderAsc, page, pageSize, search } = this.state;
+ PieceListActions.fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy });
},
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
+ const { orderAsc, pageSize } = this.state;
const orderBy = this.state.orderBy || this.props.orderBy;
- return PieceListActions.fetchPieceList(page, this.state.pageSize, search,
- orderBy, this.state.orderAsc, filterBy);
+ return PieceListActions.fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy });
},
fetchSelectedPieceEditionList() {
@@ -245,8 +247,9 @@ let PieceList = React.createClass({
},
handleAclSuccess() {
- PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
- this.state.orderBy, this.state.orderAsc, this.state.filterBy);
+ const { filterBy, orderBy, orderAsc, page, pageSize, search } = this.state;
+
+ PieceListActions.fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy });
this.fetchSelectedPieceEditionList()
.forEach((pieceId) => {
diff --git a/js/components/register_piece.js b/js/components/register_piece.js
index 8211e91e..3f268760 100644
--- a/js/components/register_piece.js
+++ b/js/components/register_piece.js
@@ -65,26 +65,21 @@ let RegisterPiece = React.createClass( {
this.setState(state);
},
- handleSuccess(response){
- let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
+ handleSuccess(response) {
+ const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
+
+ const notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
// once the user was able to register a piece successfully, we need to make sure to keep
// the piece list up to date
- PieceListActions.fetchPieceList(
- this.state.page,
- this.state.pageSize,
- this.state.searchTerm,
- this.state.orderBy,
- this.state.orderAsc,
- this.state.filterBy
- );
+ PieceListActions.fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy });
- this.history.pushState(null, `/pieces/${response.piece.id}`);
+ this.history.push(`/pieces/${response.piece.id}`);
},
getSpecifyEditions() {
- if(this.state.whitelabel && this.state.whitelabel.acl_create_editions || Object.keys(this.state.whitelabel).length === 0) {
+ if (this.state.whitelabel && this.state.whitelabel.acl_create_editions || Object.keys(this.state.whitelabel).length === 0) {
return (
+ min={1}
+ max={100} />
);
}
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 e3d5ab93..2ef96661 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
@@ -106,7 +106,7 @@ const PRRegisterPieceForm = React.createClass({
GlobalNotificationActions.appendGlobalNotification(notificationMessage);
});
})
- .then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`))
+ .then(() => this.history.push(`/pieces/${this.state.piece.id}`))
.catch((err) => {
const errMessage = (getErrorNotificationMessage(err) || getLangText("Oops! We weren't able to send your submission.")) +
getLangText(' Please contact support@ascribe.io');
@@ -193,11 +193,12 @@ const PRRegisterPieceForm = React.createClass({
render() {
const { location } = this.props;
+ const maxThumbnailSize = AppConstants.fineUploader.validation.workThumbnail.sizeLimit / 1000000;
return (
- }
+ }
subheader={
@@ -218,17 +215,19 @@ let NavigationHeader = React.createClass({
);
+ } else {
+ return null;
}
- return null;
}
});
let PrizePieceRatings = React.createClass({
propTypes: {
- loadPiece: React.PropTypes.func,
- piece: React.PropTypes.object,
- currentUser: React.PropTypes.object,
+ currentUser: React.PropTypes.object.isRequired,
+ loadPiece: React.PropTypes.func.isRequired,
+ piece: React.PropTypes.object.isRequired,
+
selectedPrizeActionButton: React.PropTypes.func
},
@@ -241,12 +240,18 @@ let PrizePieceRatings = React.createClass({
},
componentDidMount() {
- PieceListStore.listen(this.onChange);
- PrizeStore.listen(this.onChange);
PrizeRatingStore.listen(this.onChange);
+ PrizeStore.listen(this.onChange);
+ PieceListStore.listen(this.onChange);
PrizeActions.fetchPrize();
- this.fetchPrizeRatings();
+ this.fetchRatingsIfAuthorized();
+ },
+
+ componentWillReceiveProps(nextProps) {
+ if (nextProps.currentUser.email !== this.props.currentUser.email) {
+ this.fetchRatingsIfAuthorized();
+ }
},
componentWillUnmount() {
@@ -261,7 +266,7 @@ let PrizePieceRatings = React.createClass({
// with the problem.
onChange(state) {
if (state.prize && state.prize.active_round != this.state.prize.active_round) {
- this.fetchPrizeRatings(state);
+ this.fetchRatingsIfAuthorized(state);
}
this.setState(state);
@@ -276,9 +281,19 @@ let PrizePieceRatings = React.createClass({
}
},
- fetchPrizeRatings(state = this.state) {
- PrizeRatingActions.fetchOne(this.props.piece.id, state.prize.active_round);
- PrizeRatingActions.fetchAverage(this.props.piece.id, state.prize.active_round);
+ fetchRatingsIfAuthorized(state = this.state) {
+ const {
+ currentUser: {
+ is_admin: isAdmin,
+ is_judge: isJudge,
+ is_jury: isJury
+ },
+ piece: { id: pieceId } } = this.props;
+
+ if (state.prize && 'active_round' in state.prize && (isAdmin || isJudge || isJury)) {
+ PrizeRatingActions.fetchOne(pieceId, state.prize.active_round);
+ PrizeRatingActions.fetchAverage(pieceId, state.prize.active_round);
+ }
},
onRatingClick(event, args) {
@@ -303,9 +318,10 @@ let PrizePieceRatings = React.createClass({
},
refreshPieceData() {
+ const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
+
this.props.loadPiece();
- PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
- this.state.orderBy, this.state.orderAsc, this.state.filterBy);
+ PieceListActions.fetchPieceList({ page, pageSize, search, orderBy, orderAsc, filterBy });
},
onSelectChange() {
@@ -322,7 +338,7 @@ let PrizePieceRatings = React.createClass({
},
render() {
- if (this.props.piece && this.props.currentUser && this.props.currentUser.is_judge && this.state.average) {
+ if (this.props.piece.id && this.props.currentUser.is_judge && this.state.average) {
// Judge sees shortlisting, average and per-jury notes
return (
@@ -354,7 +370,7 @@ let PrizePieceRatings = React.createClass({
size='md'
step={0.5}
rating={this.state.average}
- ratingAmount={5}/>
+ ratingAmount={5} />
{this.state.ratings.map((item, i) => {
@@ -379,7 +395,7 @@ let PrizePieceRatings = React.createClass({
size='sm'
step={0.5}
rating={item.rating}
- ratingAmount={5}/>
+ ratingAmount={5} />
{note}
@@ -390,7 +406,7 @@ let PrizePieceRatings = React.createClass({