diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 0879dea0..a20e7040 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -1,7 +1,7 @@ 'use strict'; import React from 'react'; -import { Link, History } from 'react-router'; +import { Link } from 'react-router'; import Moment from 'moment'; import Row from 'react-bootstrap/lib/Row'; @@ -44,8 +44,6 @@ let Edition = React.createClass({ loadEdition: React.PropTypes.func }, - mixins: [History], - getDefaultProps() { return { furtherDetailsType: FurtherDetails diff --git a/js/components/ascribe_detail/edition_action_panel.js b/js/components/ascribe_detail/edition_action_panel.js index 36a79e7c..e7bbdc86 100644 --- a/js/components/ascribe_detail/edition_action_panel.js +++ b/js/components/ascribe_detail/edition_action_panel.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; @@ -42,7 +41,9 @@ let EditionActionPanel = React.createClass({ handleSuccess: React.PropTypes.func }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getDefaultProps() { return { @@ -75,7 +76,7 @@ let EditionActionPanel = React.createClass({ let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, refreshCollection() { diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index ee53f0e1..33d16e2a 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import ReactError from '../../mixins/react_error'; import { ResourceNotFoundError } from '../../models/errors'; @@ -31,7 +30,7 @@ let EditionContainer = React.createClass({ params: React.PropTypes.object }, - mixins: [History, ReactError], + mixins: [ReactError], getInitialState() { return mergeOptions( diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 1aebff75..5ed24a2e 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Moment from 'moment'; import ReactError from '../../mixins/react_error'; @@ -57,7 +56,11 @@ let PieceContainer = React.createClass({ params: React.PropTypes.object }, - mixins: [History, ReactError], + contextTypes: { + router: React.PropTypes.object.isRequired + }, + + mixins: [ReactError], getDefaultProps() { return { @@ -159,7 +162,7 @@ let PieceContainer = React.createClass({ let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, getCreateEditionsDialog() { diff --git a/js/components/ascribe_forms/form_login.js b/js/components/ascribe_forms/form_login.js index a604850d..bb45f6f3 100644 --- a/js/components/ascribe_forms/form_login.js +++ b/js/components/ascribe_forms/form_login.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; @@ -13,7 +12,6 @@ import Form from './form'; import Property from './property'; import ApiUrls from '../../constants/api_urls'; -import AppConstants from '../../constants/application_constants'; import AscribeSpinner from '../ascribe_spinner'; import { getLangText } from '../../utils/lang_utils'; @@ -28,8 +26,6 @@ let LoginForm = React.createClass({ location: React.PropTypes.object }, - mixins: [History], - getDefaultProps() { return { headerMessage: getLangText('Enter ascribe'), diff --git a/js/components/ascribe_forms/form_send_contract_agreement.js b/js/components/ascribe_forms/form_send_contract_agreement.js index 6f5f74d7..3cc6b554 100644 --- a/js/components/ascribe_forms/form_send_contract_agreement.js +++ b/js/components/ascribe_forms/form_send_contract_agreement.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import ContractListActions from '../../actions/contract_list_actions'; import ContractListStore from '../../stores/contract_list_store'; @@ -25,7 +24,9 @@ let SendContractAgreementForm = React.createClass({ handleSuccess: React.PropTypes.func }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object + }, getInitialState() { return mergeOptions( @@ -58,7 +59,7 @@ let SendContractAgreementForm = React.createClass({ notification = new GlobalNotificationModel(notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, getFormData() { diff --git a/js/components/ascribe_forms/form_signup.js b/js/components/ascribe_forms/form_signup.js index 22f3e120..df28af5f 100644 --- a/js/components/ascribe_forms/form_signup.js +++ b/js/components/ascribe_forms/form_signup.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import UserStore from '../../stores/user_store'; import UserActions from '../../actions/user_actions'; @@ -28,8 +27,6 @@ let SignupForm = React.createClass({ location: React.PropTypes.object }, - mixins: [History], - getDefaultProps() { return { headerMessage: getLangText('Welcome to ascribe'), diff --git a/js/components/ascribe_routes/proxy_handler.js b/js/components/ascribe_routes/proxy_handler.js index 228f0f62..77486175 100644 --- a/js/components/ascribe_routes/proxy_handler.js +++ b/js/components/ascribe_routes/proxy_handler.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { RouteContext } from 'react-router'; import history from '../../history'; import UserStore from '../../stores/user_store'; @@ -40,7 +39,7 @@ export function AuthRedirect({to, when}) { // and redirect if `true`. if(exprToValidate) { - window.setTimeout(() => history.replaceState(null, to, query)); + window.setTimeout(() => history.replace({ path: to, query })); return true; // 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) { delete query.redirect; - window.setTimeout(() => history.replaceState(null, '/' + redirect, query)); + window.setTimeout(() => history.replace({ path: '/' + redirect, query: query })); return true; } else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) { @@ -81,17 +80,36 @@ export function ProxyHandler(...redirectFunctions) { displayName: 'ProxyHandler', propTypes: { - location: object + location: object, + + // Supplied by react-router + route: object }, - // We need insert `RouteContext` here in order to be able - // to use the `Lifecycle` widget in further down nested components - mixins: [RouteContext], + contextTypes: { + router: object + }, + + childContextTypes: { + route: object, + router: object + }, getInitialState() { 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() { UserStore.listen(this.onChange); UserActions.fetchCurrentUser(); diff --git a/js/components/ascribe_slides_container/slides_container.js b/js/components/ascribe_slides_container/slides_container.js index d427d2f6..7533ed94 100644 --- a/js/components/ascribe_slides_container/slides_container.js +++ b/js/components/ascribe_slides_container/slides_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History, Lifecycle } from 'react-router'; import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs'; @@ -21,7 +20,10 @@ const SlidesContainer = React.createClass({ pageExitWarning: string }, - mixins: [History, Lifecycle], + contextTypes: { + route: object.isRequired, + router: object.isRequired + }, getInitialState() { return { @@ -37,6 +39,11 @@ const SlidesContainer = React.createClass({ // Initially, we need to dispatch 'resize' once to render correctly 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() { @@ -64,7 +71,7 @@ const SlidesContainer = React.createClass({ setSlideNum(nextSlideNum, additionalQueryParams = {}) { let queryParams = Object.assign(this.props.location.query, additionalQueryParams); 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. diff --git a/js/components/logout_container.js b/js/components/logout_container.js index 41bd9a1f..4659a29e 100644 --- a/js/components/logout_container.js +++ b/js/components/logout_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import AscribeSpinner from './ascribe_spinner'; @@ -13,8 +12,6 @@ import { setDocumentTitle } from '../utils/dom_utils'; let LogoutContainer = React.createClass({ - mixins: [History], - componentDidMount() { UserActions.logoutCurrentUser(); alt.flush(); diff --git a/js/components/password_reset_container.js b/js/components/password_reset_container.js index 31275a08..ad10cf03 100644 --- a/js/components/password_reset_container.js +++ b/js/components/password_reset_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Form from './ascribe_forms/form'; import Property from './ascribe_forms/property'; @@ -120,7 +119,9 @@ let PasswordResetForm = React.createClass({ token: React.PropTypes.string }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getFormData() { return { @@ -130,7 +131,7 @@ let PasswordResetForm = React.createClass({ }, handleSuccess() { - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); let 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..80afcb2b 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import PieceListStore from '../stores/piece_list_store'; import PieceListActions from '../actions/piece_list_actions'; @@ -46,7 +45,9 @@ let PieceList = React.createClass({ location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getDefaultProps() { return { @@ -115,13 +116,17 @@ let PieceList = React.createClass({ }, componentDidUpdate() { - const { redirectTo, shouldRedirect } = this.props; + const { redirectTo: pathname, + shouldRedirect, + location: { + query + } } = this.props; const { unfilteredPieceListCount } = this.state; - if (redirectTo && unfilteredPieceListCount === 0 && + if (pathname && 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.context.router.push({ pathname, query }), 0); } }, @@ -175,14 +180,19 @@ let PieceList = React.createClass({ }, searchFor(searchTerm) { + const { pathname } = this.props.location; + this.loadPieceList({ page: 1, 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({ 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 // for filtered pieces - this.history.pushState(null, this.props.location.pathname, {page: 1}); + this.context.router.push({ pathname, query: {page: 1} }); }, applyOrderBy(orderBy) { diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 8211e91e..d2295fd6 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Col from 'react-bootstrap/lib/Col'; import Row from 'react-bootstrap/lib/Row'; @@ -38,7 +37,9 @@ let RegisterPiece = React.createClass( { location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState(){ return mergeOptions( @@ -80,7 +81,7 @@ let RegisterPiece = React.createClass( { this.state.filterBy ); - this.history.pushState(null, `/pieces/${response.piece.id}`); + this.context.router.push({ pathname: `/pieces/${response.piece.id}` }); }, getSpecifyEditions() { 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..1176958d 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 @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Form from '../../../../../ascribe_forms/form'; import Property from '../../../../../ascribe_forms/property'; @@ -35,7 +34,9 @@ const PRRegisterPieceForm = React.createClass({ currentUser: object }, - mixins: [History], + contextTypes: { + router: object + }, getInitialState() { return { @@ -106,7 +107,7 @@ const PRRegisterPieceForm = React.createClass({ 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) => { const errMessage = (getErrorNotificationMessage(err) || getLangText("Oops! We weren't able to send your submission.")) + getLangText(' Please contact support@ascribe.io'); diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_landing.js b/js/components/whitelabel/prize/portfolioreview/components/pr_landing.js index cdada68b..0e83d2ca 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_landing.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_landing.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import PrizeActions from '../../simple_prize/actions/prize_actions'; import PrizeStore from '../../simple_prize/stores/prize_store'; @@ -23,7 +22,9 @@ const PRLanding = React.createClass({ location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object + }, getInitialState() { return mergeOptions( @@ -42,7 +43,12 @@ const PRLanding = React.createClass({ if(location && location.query && location.query.redirect) { let queryCopy = JSON.parse(JSON.stringify(location.query)); 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 + }); + }); } }, diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_register_piece.js b/js/components/whitelabel/prize/portfolioreview/components/pr_register_piece.js index d7aa1aa8..0d66f0a4 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_register_piece.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_register_piece.js @@ -1,7 +1,7 @@ 'use strict'; import React from 'react'; -import { Link, History } from 'react-router'; +import { Link } from 'react-router'; import Col from 'react-bootstrap/lib/Col'; import Row from 'react-bootstrap/lib/Row'; @@ -23,7 +23,9 @@ const PRRegisterPiece = React.createClass({ location: object }, - mixins: [History], + contextTypes: { + router: object + }, getInitialState() { return UserStore.getState(); @@ -39,7 +41,7 @@ const PRRegisterPiece = React.createClass({ if(currentUser && currentUser.email) { const submittedPieceId = getCookie(currentUser.email); if(submittedPieceId) { - this.history.pushState(null, `/pieces/${submittedPieceId}`); + this.context.router.push({ pathname: `/pieces/${submittedPieceId}` }); } } }, diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js b/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js index 04ff8ce6..3e2b7736 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js @@ -17,7 +17,7 @@ export function AuthPrizeRoleRedirect({ to, when }) { .reduce((a, b) => a || b); if (exprToValidate) { - window.setTimeout(() => history.replaceState(null, to, query)); + window.setTimeout(() => history.replace({ path: to, query: query })); return true; } else { return false; diff --git a/js/components/whitelabel/prize/simple_prize/components/prize_landing.js b/js/components/whitelabel/prize/simple_prize/components/prize_landing.js index e26a05b5..3c1843a4 100644 --- a/js/components/whitelabel/prize/simple_prize/components/prize_landing.js +++ b/js/components/whitelabel/prize/simple_prize/components/prize_landing.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import PrizeActions from '../actions/prize_actions'; import PrizeStore from '../stores/prize_store'; @@ -19,7 +18,9 @@ import { getLangText } from '../../../../../utils/lang_utils'; let Landing = React.createClass({ - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState() { return mergeOptions( @@ -46,7 +47,7 @@ let Landing = React.createClass({ // if user is already logged in, redirect him to piece list if(this.state.currentUser && this.state.currentUser.email) { // 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); } }, diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js index d211d3e8..25b98902 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import PieceActions from '../../../../../../actions/piece_actions'; import PieceStore from '../../../../../../stores/piece_store'; @@ -36,7 +35,9 @@ let CylandPieceContainer = React.createClass({ params: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object + }, getInitialState() { return mergeOptions( @@ -85,7 +86,7 @@ let CylandPieceContainer = React.createClass({ let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, render() { diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_landing.js b/js/components/whitelabel/wallet/components/cyland/cyland_landing.js index 21f8835a..4e607f52 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_landing.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_landing.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import WhitelabelActions from '../../../../../actions/whitelabel_actions'; 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 UserActions from '../../../../../actions/user_actions'; -import AscribeSpinner from '../../../../ascribe_spinner'; - import { mergeOptions } from '../../../../../utils/general_utils'; import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; @@ -22,7 +19,9 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils'; let CylandLanding = React.createClass({ - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState() { return mergeOptions( @@ -49,7 +48,7 @@ let CylandLanding = React.createClass({ // if user is already logged in, redirect him to piece list if(this.state.currentUser && this.state.currentUser.email) { // 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); } }, diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js index fabed011..9fcaad8b 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Moment from 'moment'; @@ -46,7 +45,9 @@ let CylandRegisterPiece = React.createClass({ location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState(){ return mergeOptions( @@ -129,7 +130,7 @@ let CylandRegisterPiece = React.createClass({ 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 diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js index 7975c1f3..1544e55c 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Button from 'react-bootstrap/lib/Button'; @@ -33,7 +32,9 @@ import { mergeOptions } from '../../../../../utils/general_utils'; let IkonotvContractNotifications = React.createClass({ - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState() { return mergeOptions( @@ -119,7 +120,7 @@ let IkonotvContractNotifications = React.createClass({ NotificationActions.flushContractAgreementListNotifications(); NotificationActions.fetchContractAgreementListNotifications(); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, handleDeny() { @@ -132,7 +133,7 @@ let IkonotvContractNotifications = React.createClass({ handleDenySuccess() { let notification = new GlobalNotificationModel(getLangText('You have denied the conditions'), 'success', 5000); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, getCopyrightAssociationForm(){ diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js index df58b7c7..61f76396 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import PieceActions from '../../../../../../actions/piece_actions'; import PieceStore from '../../../../../../stores/piece_store'; @@ -37,7 +36,9 @@ let IkonotvPieceContainer = React.createClass({ params: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState() { return mergeOptions( @@ -94,7 +95,7 @@ let IkonotvPieceContainer = React.createClass({ let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); }, render() { diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js index c40d779d..7f706df7 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js @@ -2,7 +2,6 @@ import React from 'react'; import Moment from 'moment'; -import { History } from 'react-router'; import Col from 'react-bootstrap/lib/Col'; import Row from 'react-bootstrap/lib/Row'; @@ -43,7 +42,9 @@ let IkonotvRegisterPiece = React.createClass({ location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState(){ return mergeOptions( @@ -103,7 +104,7 @@ let IkonotvRegisterPiece = React.createClass({ PieceActions.updatePiece(response.piece); } if (!this.canSubmit()) { - this.history.pushState(null, '/collection'); + this.context.router.push({ pathname: '/collection' }); } else { this.incrementStep(); @@ -134,7 +135,7 @@ let IkonotvRegisterPiece = React.createClass({ this.refreshPieceList(); 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 diff --git a/js/components/whitelabel/wallet/components/market/market_register_piece.js b/js/components/whitelabel/wallet/components/market/market_register_piece.js index 387934f9..06fe67ff 100644 --- a/js/components/whitelabel/wallet/components/market/market_register_piece.js +++ b/js/components/whitelabel/wallet/components/market/market_register_piece.js @@ -1,7 +1,6 @@ 'use strict'; import React from 'react'; -import { History } from 'react-router'; import Col from 'react-bootstrap/lib/Col'; import Row from 'react-bootstrap/lib/Row'; @@ -30,7 +29,9 @@ let MarketRegisterPiece = React.createClass({ location: React.PropTypes.object }, - mixins: [History], + contextTypes: { + router: React.PropTypes.object.isRequired + }, getInitialState(){ return mergeOptions( @@ -82,7 +83,7 @@ let MarketRegisterPiece = React.createClass({ handleAdditionalDataSuccess() { 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 diff --git a/js/third_party/notifications.js b/js/third_party/notifications.js index 85379479..8dfc12b4 100644 --- a/js/third_party/notifications.js +++ b/js/third_party/notifications.js @@ -29,7 +29,7 @@ class NotificationsHandler { if (res.notifications && res.notifications.length > 0) { this.loaded = true; console.log('Contractagreement notifications loaded'); - history.pushState(null, '/contract_notifications'); + history.push({ pathname: '/contract_notifications' }); } } );