1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +01:00

Replace usage of History mixin with contextTypes

This commit is contained in:
Tim Daubenschütz 2016-01-25 17:53:28 +01:00
parent d0586c937d
commit 5900e900ae
26 changed files with 131 additions and 87 deletions

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { Link, History } from 'react-router'; import { Link } from 'react-router';
import Moment from 'moment'; import Moment from 'moment';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
@ -44,8 +44,6 @@ let Edition = React.createClass({
loadEdition: React.PropTypes.func loadEdition: React.PropTypes.func
}, },
mixins: [History],
getDefaultProps() { getDefaultProps() {
return { return {
furtherDetailsType: FurtherDetails furtherDetailsType: FurtherDetails

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
@ -42,7 +41,9 @@ let EditionActionPanel = React.createClass({
handleSuccess: React.PropTypes.func handleSuccess: React.PropTypes.func
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getDefaultProps() { getDefaultProps() {
return { return {
@ -75,7 +76,7 @@ let EditionActionPanel = React.createClass({
let notification = new GlobalNotificationModel(response.notification, 'success'); let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
refreshCollection() { refreshCollection() {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import ReactError from '../../mixins/react_error'; import ReactError from '../../mixins/react_error';
import { ResourceNotFoundError } from '../../models/errors'; import { ResourceNotFoundError } from '../../models/errors';
@ -31,7 +30,7 @@ let EditionContainer = React.createClass({
params: React.PropTypes.object params: React.PropTypes.object
}, },
mixins: [History, ReactError], mixins: [ReactError],
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Moment from 'moment'; import Moment from 'moment';
import ReactError from '../../mixins/react_error'; import ReactError from '../../mixins/react_error';
@ -57,7 +56,11 @@ let PieceContainer = React.createClass({
params: React.PropTypes.object params: React.PropTypes.object
}, },
mixins: [History, ReactError], contextTypes: {
router: React.PropTypes.object.isRequired
},
mixins: [ReactError],
getDefaultProps() { getDefaultProps() {
return { return {
@ -159,7 +162,7 @@ let PieceContainer = React.createClass({
let notification = new GlobalNotificationModel(response.notification, 'success'); let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
getCreateEditionsDialog() { getCreateEditionsDialog() {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions'; import GlobalNotificationActions from '../../actions/global_notification_actions';
@ -13,7 +12,6 @@ import Form from './form';
import Property from './property'; import Property from './property';
import ApiUrls from '../../constants/api_urls'; import ApiUrls from '../../constants/api_urls';
import AppConstants from '../../constants/application_constants';
import AscribeSpinner from '../ascribe_spinner'; import AscribeSpinner from '../ascribe_spinner';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
@ -28,8 +26,6 @@ let LoginForm = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History],
getDefaultProps() { getDefaultProps() {
return { return {
headerMessage: getLangText('Enter ascribe'), headerMessage: getLangText('Enter ascribe'),

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import ContractListActions from '../../actions/contract_list_actions'; import ContractListActions from '../../actions/contract_list_actions';
import ContractListStore from '../../stores/contract_list_store'; import ContractListStore from '../../stores/contract_list_store';
@ -25,7 +24,9 @@ let SendContractAgreementForm = React.createClass({
handleSuccess: React.PropTypes.func handleSuccess: React.PropTypes.func
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -58,7 +59,7 @@ let SendContractAgreementForm = React.createClass({
notification = new GlobalNotificationModel(notification, 'success', 10000); notification = new GlobalNotificationModel(notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
getFormData() { getFormData() {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import UserStore from '../../stores/user_store'; import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions'; import UserActions from '../../actions/user_actions';
@ -28,8 +27,6 @@ let SignupForm = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History],
getDefaultProps() { getDefaultProps() {
return { return {
headerMessage: getLangText('Welcome to ascribe'), headerMessage: getLangText('Welcome to ascribe'),

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { RouteContext } from 'react-router';
import history from '../../history'; import history from '../../history';
import UserStore from '../../stores/user_store'; import UserStore from '../../stores/user_store';
@ -40,7 +39,7 @@ export function AuthRedirect({to, when}) {
// and redirect if `true`. // and redirect if `true`.
if(exprToValidate) { if(exprToValidate) {
window.setTimeout(() => history.replaceState(null, to, query)); window.setTimeout(() => history.replace({ path: to, query }));
return true; return true;
// Otherwise there can also be the case that the backend // Otherwise there can also be the case that the backend
@ -48,7 +47,7 @@ export function AuthRedirect({to, when}) {
} else if(!exprToValidate && when === 'loggedIn' && redirect) { } else if(!exprToValidate && when === 'loggedIn' && redirect) {
delete query.redirect; delete query.redirect;
window.setTimeout(() => history.replaceState(null, '/' + redirect, query)); window.setTimeout(() => history.replace({ path: '/' + redirect, query: query }));
return true; return true;
} else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) { } else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) {
@ -81,17 +80,36 @@ export function ProxyHandler(...redirectFunctions) {
displayName: 'ProxyHandler', displayName: 'ProxyHandler',
propTypes: { propTypes: {
location: object location: object,
// Supplied by react-router
route: object
}, },
// We need insert `RouteContext` here in order to be able contextTypes: {
// to use the `Lifecycle` widget in further down nested components router: object
mixins: [RouteContext], },
childContextTypes: {
route: object,
router: object
},
getInitialState() { getInitialState() {
return UserStore.getState(); return UserStore.getState();
}, },
getChildContext() {
return {
route: this.props.route,
// TODO: Find out if it is necessary to
// pass router here as a contextType, since
// react-router apparently does it already
router: this.context.router
};
},
componentDidMount() { componentDidMount() {
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History, Lifecycle } from 'react-router';
import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs'; import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs';
@ -21,7 +20,10 @@ const SlidesContainer = React.createClass({
pageExitWarning: string pageExitWarning: string
}, },
mixins: [History, Lifecycle], contextTypes: {
route: object.isRequired,
router: object.isRequired
},
getInitialState() { getInitialState() {
return { return {
@ -37,6 +39,11 @@ const SlidesContainer = React.createClass({
// Initially, we need to dispatch 'resize' once to render correctly // Initially, we need to dispatch 'resize' once to render correctly
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));
// Since react-router 2.0.0, we need to define the `routerWillLeave`
// method ourselves.
const { router, route } = this.context;
router.setRouteLeaveHook(route, this.routerWillLeave);
}, },
componentWillUnmount() { componentWillUnmount() {
@ -64,7 +71,7 @@ const SlidesContainer = React.createClass({
setSlideNum(nextSlideNum, additionalQueryParams = {}) { setSlideNum(nextSlideNum, additionalQueryParams = {}) {
let queryParams = Object.assign(this.props.location.query, additionalQueryParams); let queryParams = Object.assign(this.props.location.query, additionalQueryParams);
queryParams.slide_num = nextSlideNum; queryParams.slide_num = nextSlideNum;
this.history.pushState(null, this.props.location.pathname, queryParams); this.context.router.push({ pathname: this.props.location.pathname, query: queryParams });
}, },
// breadcrumbs are defined as attributes of the slides. // breadcrumbs are defined as attributes of the slides.

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import AscribeSpinner from './ascribe_spinner'; import AscribeSpinner from './ascribe_spinner';
@ -13,8 +12,6 @@ import { setDocumentTitle } from '../utils/dom_utils';
let LogoutContainer = React.createClass({ let LogoutContainer = React.createClass({
mixins: [History],
componentDidMount() { componentDidMount() {
UserActions.logoutCurrentUser(); UserActions.logoutCurrentUser();
alt.flush(); alt.flush();

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Form from './ascribe_forms/form'; import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property'; import Property from './ascribe_forms/property';
@ -120,7 +119,9 @@ let PasswordResetForm = React.createClass({
token: React.PropTypes.string token: React.PropTypes.string
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getFormData() { getFormData() {
return { return {
@ -130,7 +131,7 @@ let PasswordResetForm = React.createClass({
}, },
handleSuccess() { handleSuccess() {
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
let notification = new GlobalNotificationModel(getLangText('password successfully updated'), 'success', 10000); let notification = new GlobalNotificationModel(getLangText('password successfully updated'), 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
}, },

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import PieceListStore from '../stores/piece_list_store'; import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions'; import PieceListActions from '../actions/piece_list_actions';
@ -46,7 +45,9 @@ let PieceList = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getDefaultProps() { getDefaultProps() {
return { return {
@ -115,13 +116,17 @@ let PieceList = React.createClass({
}, },
componentDidUpdate() { componentDidUpdate() {
const { redirectTo, shouldRedirect } = this.props; const { redirectTo: pathname,
shouldRedirect,
location: {
query
} } = this.props;
const { unfilteredPieceListCount } = this.state; const { unfilteredPieceListCount } = this.state;
if (redirectTo && unfilteredPieceListCount === 0 && if (pathname && unfilteredPieceListCount === 0 &&
(typeof shouldRedirect === 'function' && shouldRedirect(unfilteredPieceListCount))) { (typeof shouldRedirect === 'function' && shouldRedirect(unfilteredPieceListCount))) {
// FIXME: hack to redirect out of the dispatch cycle // 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.context.router.push({ pathname, query }), 0);
} }
}, },
@ -175,14 +180,19 @@ let PieceList = React.createClass({
}, },
searchFor(searchTerm) { searchFor(searchTerm) {
const { pathname } = this.props.location;
this.loadPieceList({ this.loadPieceList({
page: 1, page: 1,
search: searchTerm search: searchTerm
}); });
this.history.pushState(null, this.props.location.pathname, {page: 1});
this.context.router.push({ pathname, query: {page: 1} });
}, },
applyFilterBy(filterBy){ applyFilterBy(filterBy) {
const { pathname } = this.props.location;
this.setState({ this.setState({
isFilterDirty: true isFilterDirty: true
}); });
@ -207,7 +217,7 @@ let PieceList = React.createClass({
// we have to redirect the user always to page one as it could be that there is no page two // we have to redirect the user always to page one as it could be that there is no page two
// for filtered pieces // for filtered pieces
this.history.pushState(null, this.props.location.pathname, {page: 1}); this.context.router.push({ pathname, query: {page: 1} });
}, },
applyOrderBy(orderBy) { applyOrderBy(orderBy) {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
@ -38,7 +37,9 @@ let RegisterPiece = React.createClass( {
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
@ -80,7 +81,7 @@ let RegisterPiece = React.createClass( {
this.state.filterBy this.state.filterBy
); );
this.history.pushState(null, `/pieces/${response.piece.id}`); this.context.router.push({ pathname: `/pieces/${response.piece.id}` });
}, },
getSpecifyEditions() { getSpecifyEditions() {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Form from '../../../../../ascribe_forms/form'; import Form from '../../../../../ascribe_forms/form';
import Property from '../../../../../ascribe_forms/property'; import Property from '../../../../../ascribe_forms/property';
@ -35,7 +34,9 @@ const PRRegisterPieceForm = React.createClass({
currentUser: object currentUser: object
}, },
mixins: [History], contextTypes: {
router: object
},
getInitialState() { getInitialState() {
return { return {
@ -106,7 +107,7 @@ const PRRegisterPieceForm = React.createClass({
GlobalNotificationActions.appendGlobalNotification(notificationMessage); GlobalNotificationActions.appendGlobalNotification(notificationMessage);
}); });
}) })
.then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`)) .then(() => this.context.router.push({ pathname: `/pieces/${this.state.piece.id}` }))
.catch((err) => { .catch((err) => {
const errMessage = (getErrorNotificationMessage(err) || getLangText("Oops! We weren't able to send your submission.")) + const errMessage = (getErrorNotificationMessage(err) || getLangText("Oops! We weren't able to send your submission.")) +
getLangText(' Please contact support@ascribe.io'); getLangText(' Please contact support@ascribe.io');

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import PrizeActions from '../../simple_prize/actions/prize_actions'; import PrizeActions from '../../simple_prize/actions/prize_actions';
import PrizeStore from '../../simple_prize/stores/prize_store'; import PrizeStore from '../../simple_prize/stores/prize_store';
@ -23,7 +22,9 @@ const PRLanding = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -42,7 +43,12 @@ const PRLanding = React.createClass({
if(location && location.query && location.query.redirect) { if(location && location.query && location.query.redirect) {
let queryCopy = JSON.parse(JSON.stringify(location.query)); let queryCopy = JSON.parse(JSON.stringify(location.query));
delete queryCopy.redirect; delete queryCopy.redirect;
window.setTimeout(() => this.history.replaceState(null, `/${location.query.redirect}`, queryCopy)); window.setTimeout(() => {
this.context.router.replace({
pathname: `/${location.query.redirect}`,
query: queryCopy
});
});
} }
}, },

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { Link, History } from 'react-router'; import { Link } from 'react-router';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
@ -23,7 +23,9 @@ const PRRegisterPiece = React.createClass({
location: object location: object
}, },
mixins: [History], contextTypes: {
router: object
},
getInitialState() { getInitialState() {
return UserStore.getState(); return UserStore.getState();
@ -39,7 +41,7 @@ const PRRegisterPiece = React.createClass({
if(currentUser && currentUser.email) { if(currentUser && currentUser.email) {
const submittedPieceId = getCookie(currentUser.email); const submittedPieceId = getCookie(currentUser.email);
if(submittedPieceId) { if(submittedPieceId) {
this.history.pushState(null, `/pieces/${submittedPieceId}`); this.context.router.push({ pathname: `/pieces/${submittedPieceId}` });
} }
} }
}, },

View File

@ -17,7 +17,7 @@ export function AuthPrizeRoleRedirect({ to, when }) {
.reduce((a, b) => a || b); .reduce((a, b) => a || b);
if (exprToValidate) { if (exprToValidate) {
window.setTimeout(() => history.replaceState(null, to, query)); window.setTimeout(() => history.replace({ path: to, query: query }));
return true; return true;
} else { } else {
return false; return false;

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import PrizeActions from '../actions/prize_actions'; import PrizeActions from '../actions/prize_actions';
import PrizeStore from '../stores/prize_store'; import PrizeStore from '../stores/prize_store';
@ -19,7 +18,9 @@ import { getLangText } from '../../../../../utils/lang_utils';
let Landing = React.createClass({ let Landing = React.createClass({
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -46,7 +47,7 @@ let Landing = React.createClass({
// if user is already logged in, redirect him to piece list // if user is already logged in, redirect him to piece list
if(this.state.currentUser && this.state.currentUser.email) { if(this.state.currentUser && this.state.currentUser.email) {
// FIXME: hack to redirect out of the dispatch cycle // FIXME: hack to redirect out of the dispatch cycle
window.setTimeout(() => this.history.replaceState(null, '/collection'), 0); window.setTimeout(() => this.context.router.replace({ pathname: '/collection' }), 0);
} }
}, },

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import PieceActions from '../../../../../../actions/piece_actions'; import PieceActions from '../../../../../../actions/piece_actions';
import PieceStore from '../../../../../../stores/piece_store'; import PieceStore from '../../../../../../stores/piece_store';
@ -36,7 +35,9 @@ let CylandPieceContainer = React.createClass({
params: React.PropTypes.object params: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -85,7 +86,7 @@ let CylandPieceContainer = React.createClass({
let notification = new GlobalNotificationModel(response.notification, 'success'); let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
render() { render() {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import WhitelabelActions from '../../../../../actions/whitelabel_actions'; import WhitelabelActions from '../../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../../stores/whitelabel_store'; import WhitelabelStore from '../../../../../stores/whitelabel_store';
@ -13,8 +12,6 @@ import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import UserStore from '../../../../../stores/user_store'; import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions'; import UserActions from '../../../../../actions/user_actions';
import AscribeSpinner from '../../../../ascribe_spinner';
import { mergeOptions } from '../../../../../utils/general_utils'; import { mergeOptions } from '../../../../../utils/general_utils';
import { getLangText } from '../../../../../utils/lang_utils'; import { getLangText } from '../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils';
@ -22,7 +19,9 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let CylandLanding = React.createClass({ let CylandLanding = React.createClass({
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -49,7 +48,7 @@ let CylandLanding = React.createClass({
// if user is already logged in, redirect him to piece list // if user is already logged in, redirect him to piece list
if(this.state.currentUser && this.state.currentUser.email) { if(this.state.currentUser && this.state.currentUser.email) {
// FIXME: hack to redirect out of the dispatch cycle // FIXME: hack to redirect out of the dispatch cycle
window.setTimeout(() => this.history.replaceState(null, '/collection'), 0); window.setTimeout(() => this.context.router.replace({ pathname: '/collection' }), 0);
} }
}, },

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Moment from 'moment'; import Moment from 'moment';
@ -46,7 +45,9 @@ let CylandRegisterPiece = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
@ -129,7 +130,7 @@ let CylandRegisterPiece = React.createClass({
PieceActions.fetchOne(this.state.piece.id); PieceActions.fetchOne(this.state.piece.id);
this.history.pushState(null, `/pieces/${this.state.piece.id}`); this.context.router.push({ pathname: `/pieces/${this.state.piece.id}` });
}, },
// We need to increase the step to lock the forms that are already filled out // We need to increase the step to lock the forms that are already filled out

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import Button from 'react-bootstrap/lib/Button'; import Button from 'react-bootstrap/lib/Button';
@ -33,7 +32,9 @@ import { mergeOptions } from '../../../../../utils/general_utils';
let IkonotvContractNotifications = React.createClass({ let IkonotvContractNotifications = React.createClass({
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -119,7 +120,7 @@ let IkonotvContractNotifications = React.createClass({
NotificationActions.flushContractAgreementListNotifications(); NotificationActions.flushContractAgreementListNotifications();
NotificationActions.fetchContractAgreementListNotifications(); NotificationActions.fetchContractAgreementListNotifications();
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
handleDeny() { handleDeny() {
@ -132,7 +133,7 @@ let IkonotvContractNotifications = React.createClass({
handleDenySuccess() { handleDenySuccess() {
let notification = new GlobalNotificationModel(getLangText('You have denied the conditions'), 'success', 5000); let notification = new GlobalNotificationModel(getLangText('You have denied the conditions'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
getCopyrightAssociationForm(){ getCopyrightAssociationForm(){

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import PieceActions from '../../../../../../actions/piece_actions'; import PieceActions from '../../../../../../actions/piece_actions';
import PieceStore from '../../../../../../stores/piece_store'; import PieceStore from '../../../../../../stores/piece_store';
@ -37,7 +36,9 @@ let IkonotvPieceContainer = React.createClass({
params: React.PropTypes.object params: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState() { getInitialState() {
return mergeOptions( return mergeOptions(
@ -94,7 +95,7 @@ let IkonotvPieceContainer = React.createClass({
let notification = new GlobalNotificationModel(response.notification, 'success'); let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
render() { render() {

View File

@ -2,7 +2,6 @@
import React from 'react'; import React from 'react';
import Moment from 'moment'; import Moment from 'moment';
import { History } from 'react-router';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
@ -43,7 +42,9 @@ let IkonotvRegisterPiece = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
@ -103,7 +104,7 @@ let IkonotvRegisterPiece = React.createClass({
PieceActions.updatePiece(response.piece); PieceActions.updatePiece(response.piece);
} }
if (!this.canSubmit()) { if (!this.canSubmit()) {
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
} }
else { else {
this.incrementStep(); this.incrementStep();
@ -134,7 +135,7 @@ let IkonotvRegisterPiece = React.createClass({
this.refreshPieceList(); this.refreshPieceList();
PieceActions.fetchOne(this.state.piece.id); PieceActions.fetchOne(this.state.piece.id);
this.history.pushState(null, `/pieces/${this.state.piece.id}`); this.context.router.push({ pathname: `/pieces/${this.state.piece.id}` });
}, },
// We need to increase the step to lock the forms that are already filled out // We need to increase the step to lock the forms that are already filled out

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import { History } from 'react-router';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row'; import Row from 'react-bootstrap/lib/Row';
@ -30,7 +29,9 @@ let MarketRegisterPiece = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
mixins: [History], contextTypes: {
router: React.PropTypes.object.isRequired
},
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
@ -82,7 +83,7 @@ let MarketRegisterPiece = React.createClass({
handleAdditionalDataSuccess() { handleAdditionalDataSuccess() {
this.refreshPieceList(); this.refreshPieceList();
this.history.pushState(null, '/collection'); this.context.router.push({ pathname: '/collection' });
}, },
// We need to increase the step to lock the forms that are already filled out // We need to increase the step to lock the forms that are already filled out

View File

@ -29,7 +29,7 @@ class NotificationsHandler {
if (res.notifications && res.notifications.length > 0) { if (res.notifications && res.notifications.length > 0) {
this.loaded = true; this.loaded = true;
console.log('Contractagreement notifications loaded'); console.log('Contractagreement notifications loaded');
history.pushState(null, '/contract_notifications'); history.push({ pathname: '/contract_notifications' });
} }
} }
); );