From 71dbad2a183d936ada94cbe3c80d2456b0d03be7 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Wed, 8 Jun 2016 14:54:05 +0200 Subject: [PATCH] Add location to context --- js/components/app_base.js | 11 +++++++--- .../ascribe_detail/edition_container.js | 1 - .../ascribe_detail/piece_container.js | 1 - js/components/ascribe_forms/form_login.js | 13 ++++++++---- .../ascribe_forms/form_register_piece.js | 8 ++++---- js/components/ascribe_forms/form_signup.js | 13 ++++++++---- js/components/ascribe_routes/proxy_handler.js | 11 +++++++--- .../ascribe_settings/contract_settings.js | 5 +---- .../ascribe_settings/settings_container.js | 5 +---- .../slides_container.js | 6 +++--- js/components/coa_verify_container.js | 12 ++++++----- js/components/context/with_context.js | 3 ++- js/components/login_container.js | 14 +++---------- js/components/password_reset_container.js | 16 +++++++-------- js/components/piece_list.js | 10 ++++------ js/components/prop_types/index.js | 2 +- js/components/register_piece.js | 5 +---- js/components/signup_container.js | 14 +++---------- .../components/23vivi/23vivi_landing.js | 5 +---- .../components/23vivi/23vivi_piece_list.js | 5 ----- .../wallet/components/cc/cc_register_piece.js | 8 +------- .../cyland_detail/cyland_piece_container.js | 1 - .../components/cyland/cyland_piece_list.js | 5 +---- .../cyland/cyland_register_piece.js | 13 +++++------- .../ikonotv/ikonotv_contract_notifications.js | 5 +---- .../ikonotv_detail/ikonotv_piece_container.js | 1 - .../components/ikonotv/ikonotv_landing.js | 17 ++++++++-------- .../components/ikonotv/ikonotv_piece_list.js | 7 +------ .../ikonotv/ikonotv_register_piece.js | 10 +++------- .../components/market/market_piece_list.js | 5 +---- .../market/market_register_piece.js | 20 ++++++------------- 31 files changed, 99 insertions(+), 153 deletions(-) diff --git a/js/components/app_base.js b/js/components/app_base.js index 6fc6c1ed..e1925d32 100644 --- a/js/components/app_base.js +++ b/js/components/app_base.js @@ -7,7 +7,7 @@ import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelStore from '../stores/whitelabel_store'; import GlobalNotification from './global_notification'; -import { currentUserShape, whitelabelShape } from './prop_types'; +import { currentUserShape, locationShape, whitelabelShape } from './prop_types'; import { mergeOptions } from '../utils/general_utils'; @@ -18,12 +18,13 @@ export default function AppBase(App) { propTypes: { children: React.PropTypes.element.isRequired, - location: React.PropTypes.object.isRequired, + location: locationShape.isRequired, routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired }, childContextTypes: { currentUser: currentUserShape, + location: locationShape, whitelabel: whitelabelShape }, @@ -37,7 +38,11 @@ export default function AppBase(App) { getChildContext() { const { currentUser, whitelabel } = this.state; - return { currentUser, whitelabel }; + return { + currentUser, + whitelabel, + location: this.props.location + }; }, componentDidMount() { diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index c061a0eb..8b619a6c 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -25,7 +25,6 @@ let EditionContainer = React.createClass({ furtherDetailsType: React.PropTypes.func, // Provided from router - location: React.PropTypes.object, params: React.PropTypes.object }, diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 49e2770b..1dd38849 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -57,7 +57,6 @@ const PieceContainer = React.createClass({ router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router - location: React.PropTypes.object, params: React.PropTypes.object }, diff --git a/js/components/ascribe_forms/form_login.js b/js/components/ascribe_forms/form_login.js index 1efab204..a28492a6 100644 --- a/js/components/ascribe_forms/form_login.js +++ b/js/components/ascribe_forms/form_login.js @@ -10,8 +10,11 @@ import UserActions from '../../actions/user_actions'; import Form from './form'; import Property from './property'; -import ApiUrls from '../../constants/api_urls'; import AscribeSpinner from '../ascribe_spinner'; +import withContext from '../context/with_context'; +import { locationShape } from '../prop_types'; + +import ApiUrls from '../../constants/api_urls'; import { getLangText } from '../../utils/lang_utils'; @@ -20,8 +23,10 @@ let LoginForm = React.createClass({ propTypes: { headerMessage: React.PropTypes.string, submitMessage: React.PropTypes.string, - location: React.PropTypes.object, - whitelabelName: React.PropTypes.string + whitelabelName: React.PropTypes.string, + + // Injected through HOCs + location: locationShape.isRequired // eslint-disable-line react/sort-prop-types }, getDefaultProps() { @@ -89,4 +94,4 @@ let LoginForm = React.createClass({ } }); -export default LoginForm; +export default withContext(LoginForm, 'location'); diff --git a/js/components/ascribe_forms/form_register_piece.js b/js/components/ascribe_forms/form_register_piece.js index 9c9d06aa..8203c35b 100644 --- a/js/components/ascribe_forms/form_register_piece.js +++ b/js/components/ascribe_forms/form_register_piece.js @@ -12,7 +12,7 @@ import UploadButton from '../ascribe_uploader/ascribe_upload_button/upload_butto import AscribeSpinner from '../ascribe_spinner'; import withContext from '../context/with_context'; -import { currentUserShape } from '../prop_types'; +import { currentUserShape, locationShape } from '../prop_types'; import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; @@ -35,14 +35,14 @@ let RegisterPieceForm = React.createClass({ // For this form to work with SlideContainer, we sometimes have to disable it disabled: React.PropTypes.bool, - location: React.PropTypes.object, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element ]), // Injected through HOCs - currentUser: currentUserShape.isRequired // eslint-disable-line react/sort-prop-types + currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types + location: locationShape.isRequired // eslint-disable-line react/sort-prop-types }, getDefaultProps() { @@ -240,4 +240,4 @@ let RegisterPieceForm = React.createClass({ } }); -export default withContext(RegisterPieceForm, 'currentUser'); +export default withContext(RegisterPieceForm, 'currentUser', 'location'); diff --git a/js/components/ascribe_forms/form_signup.js b/js/components/ascribe_forms/form_signup.js index 3f62ea04..034bd839 100644 --- a/js/components/ascribe_forms/form_signup.js +++ b/js/components/ascribe_forms/form_signup.js @@ -11,8 +11,11 @@ import Form from './form'; import Property from './property'; import InputCheckbox from './input_checkbox'; -import ApiUrls from '../../constants/api_urls'; import AscribeSpinner from '../ascribe_spinner'; +import withContext from '../context/with_context'; +import { locationShape } from '../prop_types'; + +import ApiUrls from '../../constants/api_urls'; import { getLangText } from '../../utils/lang_utils'; @@ -22,13 +25,15 @@ let SignupForm = React.createClass({ headerMessage: React.PropTypes.string, submitMessage: React.PropTypes.string, handleSuccess: React.PropTypes.func, - location: React.PropTypes.object, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element, React.PropTypes.string ]), - whitelabelName: React.PropTypes.string + whitelabelName: React.PropTypes.string, + + // Injected through HOCs + isLoggedIn: locationShape.isRequired, // eslint-disable-line react/sort-prop-types }, getDefaultProps() { @@ -129,4 +134,4 @@ let SignupForm = React.createClass({ }); -export default SignupForm; +export default withContext(SignupForm, 'location'); diff --git a/js/components/ascribe_routes/proxy_handler.js b/js/components/ascribe_routes/proxy_handler.js index 25950121..92556863 100644 --- a/js/components/ascribe_routes/proxy_handler.js +++ b/js/components/ascribe_routes/proxy_handler.js @@ -5,7 +5,7 @@ import React from 'react'; import UserStore from '../../stores/user_store'; import withContext from '../context/with_context'; -import { currentUserShape, routerShape, whitelabelShape } from '../prop_types'; +import { currentUserShape, locationShape, routerShape, whitelabelShape } from '../prop_types'; import AppConstants from '../../constants/application_constants'; @@ -84,11 +84,11 @@ export function ProxyHandler(...redirectFunctions) { // Injected through HOCs currentUser: currentUserShape.isRequired, isLoggedIn: bool.isRequired, + location: locationShape.isRequired, router: routerShape.isRequired, whitelabel: whitelabelShape.isRequired, // Provided from router - location: object, route: object }, @@ -133,6 +133,11 @@ export function ProxyHandler(...redirectFunctions) { } }); - return withContext(ProxyHandlerComponent, 'currentUser', 'isLoggedIn', 'router', 'whitelabel'); + return withContext(ProxyHandlerComponent, + 'currentUser', + 'isLoggedIn', + 'location', + 'router', + 'whitelabel'); }; } diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js index d6187870..c87a243b 100644 --- a/js/components/ascribe_settings/contract_settings.js +++ b/js/components/ascribe_settings/contract_settings.js @@ -28,10 +28,7 @@ let ContractSettings = React.createClass({ propTypes: { // Injected through HOCs currentUser: currentUserShape.isRequired, - whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, getInitialState() { diff --git a/js/components/ascribe_settings/settings_container.js b/js/components/ascribe_settings/settings_container.js index a62d7aa2..217302ce 100644 --- a/js/components/ascribe_settings/settings_container.js +++ b/js/components/ascribe_settings/settings_container.js @@ -26,10 +26,7 @@ let SettingsContainer = React.createClass({ // Injected through HOCs isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types - whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, loadUser(invalidateCache) { diff --git a/js/components/ascribe_slides_container/slides_container.js b/js/components/ascribe_slides_container/slides_container.js index c6b66339..c3c0d819 100644 --- a/js/components/ascribe_slides_container/slides_container.js +++ b/js/components/ascribe_slides_container/slides_container.js @@ -5,7 +5,7 @@ import React from 'react'; import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs'; import withContext from '../context/with_context'; -import { routerShape } from '../prop_types'; +import { locationShape, routerShape } from '../prop_types'; const { arrayOf, element, bool, shape, string, object } = React.PropTypes; @@ -19,10 +19,10 @@ const SlidesContainer = React.createClass({ pending: string, complete: string }), - location: object, pageExitWarning: string, // Injected through HOCs + location: locationShape.isRequired, // eslint-disable-line react/sort-prop-types router: routerShape.isRequired // eslint-disable-line react/sort-prop-types }, @@ -190,4 +190,4 @@ const SlidesContainer = React.createClass({ } }); -export default withContext(SlidesContainer, 'router'); +export default withContext(SlidesContainer, 'location', 'router'); diff --git a/js/components/coa_verify_container.js b/js/components/coa_verify_container.js index 8076d690..6bbf7a5a 100644 --- a/js/components/coa_verify_container.js +++ b/js/components/coa_verify_container.js @@ -6,20 +6,23 @@ import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; import Form from './ascribe_forms/form'; -import Property from './ascribe_forms/property'; import InputTextAreaToggable from './ascribe_forms/input_textarea_toggable'; +import Property from './ascribe_forms/property'; import AscribeSpinner from './ascribe_spinner'; +import withContext from './context/with_context'; +import { locationShape } from './prop_types'; import ApiUrls from '../constants/api_urls'; + import { getLangText } from '../utils/lang_utils'; import { setDocumentTitle } from '../utils/dom_utils'; let CoaVerifyContainer = React.createClass({ propTypes: { - // Provided from router - location: React.PropTypes.object + // Injected through HOCs + location: locationShape.isRequired }, render() { @@ -113,5 +116,4 @@ let CoaVerifyForm = React.createClass({ } }); - -export default CoaVerifyContainer; +export default withContext(CoaVerifyContainer, 'location'); diff --git a/js/components/context/with_context.js b/js/components/context/with_context.js index a4638531..10be1b5d 100644 --- a/js/components/context/with_context.js +++ b/js/components/context/with_context.js @@ -1,5 +1,5 @@ import React from 'react'; -import { currentUserShape, routerShape, whitelabelShape } from '../prop_types'; +import { currentUserShape, locationShape, routerShape, whitelabelShape } from '../prop_types'; import { selectFromObject } from '../../utils/general_utils'; import { getDisplayName } from '../../utils/react_utils'; @@ -42,6 +42,7 @@ const ContextPropDefinitions = { }, transformToProps: ({ currentUser }) => ({ isLoggedIn: !!currentUser.email }) }, + location: locationShape.isRequired, router: routerShape.isRequired, whitelabel: whitelabelShape.isRequired }; diff --git a/js/components/login_container.js b/js/components/login_container.js index 6e010cab..1676d544 100644 --- a/js/components/login_container.js +++ b/js/components/login_container.js @@ -15,25 +15,17 @@ import { getLangText } from '../utils/lang_utils'; let LoginContainer = React.createClass({ propTypes: { // Injected through HOCs - whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, render() { - const { - whitelabel: { name: whitelabelName }, - location - } = this.props; + const { whitelabel: { name: whitelabelName } } = this.props; setDocumentTitle(getLangText('Log in')); return (
- +
{getLangText(`Not a ${whitelabelName || 'ascribe'} user`)}? {getLangText('Sign up')}...
{getLangText('Forgot my password')}? {getLangText('Rescue me')}... diff --git a/js/components/password_reset_container.js b/js/components/password_reset_container.js index b50d41f7..8f348f65 100644 --- a/js/components/password_reset_container.js +++ b/js/components/password_reset_container.js @@ -10,7 +10,7 @@ import Property from './ascribe_forms/property'; import AscribeSpinner from './ascribe_spinner'; import withContext from './context/with_context'; -import { routerShape } from './prop_types'; +import { locationShape, routerShape } from './prop_types'; import ApiUrls from '../constants/api_urls'; @@ -21,10 +21,7 @@ import { getLangText } from '../utils/lang_utils'; let PasswordResetContainer = React.createClass({ propTypes: { // Injected through HOCs - router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + location: locationShape.isRequired, }, getInitialState() { @@ -113,10 +110,11 @@ let PasswordRequestResetForm = React.createClass({ let PasswordResetForm = withContext(React.createClass({ propTypes: { - router: React.PropTypes.object.isRequired, - email: React.PropTypes.string, - token: React.PropTypes.string + token: React.PropTypes.string, + + // Injected through HOCs + router: routerShape.isRequired // eslint-disable-line react/sort-prop-types }, getFormData() { @@ -180,4 +178,4 @@ let PasswordResetForm = withContext(React.createClass({ } }), 'router'); -export default PasswordResetContainer; +export default withContext(PasswordResetContainer, 'location'); diff --git a/js/components/piece_list.js b/js/components/piece_list.js index 1e3ee676..114585d7 100644 --- a/js/components/piece_list.js +++ b/js/components/piece_list.js @@ -22,7 +22,7 @@ import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar'; import AscribeSpinner from './ascribe_spinner'; import withContext from './context/with_context'; -import { routerShape } from './prop_types'; +import { locationShape, routerShape } from './prop_types'; import { getAvailableAcls } from '../utils/acl_utils'; import { setDocumentTitle } from '../utils/dom_utils'; @@ -47,10 +47,8 @@ const PieceList = React.createClass({ orderBy: React.PropTypes.string, // Injected through HOCs - router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + location: locationShape.isRequired, // eslint-disable-line react/sort-prop-types + router: routerShape.isRequired // eslint-disable-line react/sort-prop-types }, getDefaultProps() { @@ -352,4 +350,4 @@ const PieceList = React.createClass({ } }); -export default withContext(PieceList, 'router'); +export default withContext(PieceList, 'location', 'router'); diff --git a/js/components/prop_types/index.js b/js/components/prop_types/index.js index 05d6c5a4..e5f818dd 100644 --- a/js/components/prop_types/index.js +++ b/js/components/prop_types/index.js @@ -2,4 +2,4 @@ export { default as currentUserShape } from './current_user_shape'; export { default as whitelabelShape } from './whitelabel_shape'; // Re-export PropTypes from react-router -export { routerShape } from 'react-router/es6/PropTypes'; +export { locationShape, routerShape } from 'react-router/es6/PropTypes'; diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 8f49e433..31a608c3 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -31,10 +31,7 @@ const RegisterPiece = React.createClass( { // Injected through HOCs router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types - whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, getInitialState(){ diff --git a/js/components/signup_container.js b/js/components/signup_container.js index 7e7817b9..3735604b 100644 --- a/js/components/signup_container.js +++ b/js/components/signup_container.js @@ -13,10 +13,7 @@ import { getLangText } from '../utils/lang_utils'; let SignupContainer = React.createClass({ propTypes: { // Injected through HOCs - whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, getInitialState() { @@ -34,10 +31,7 @@ let SignupContainer = React.createClass({ }, render() { - const { - location, - whitelabel: { name: whitelabelName } - } = this.props; + const { whitelabel: { name: whitelabelName } } = this.props; const { message, submitted } = this.state; setDocumentTitle(getLangText('Sign up')); @@ -56,8 +50,7 @@ let SignupContainer = React.createClass({
+ whitelabelName={whitelabelName} />
{getLangText(`Already a ${whitelabelName || 'ascribe'} user`)}? {getLangText('Log in')}...
@@ -67,5 +60,4 @@ let SignupContainer = React.createClass({ } }); - export default withContext(SignupContainer, 'whitelabel'); diff --git a/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js b/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js index 2dc28444..0e725100 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js @@ -15,10 +15,7 @@ import { getLangText } from '../../../../../utils/lang_utils'; let Vivi23Landing = React.createClass({ propTypes: { // Injected through HOCs - whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, componentWillMount() { diff --git a/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js b/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js index 96231b1f..0da480db 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js @@ -7,11 +7,6 @@ import Vivi23AccordionListItemThumbnailPlaceholder from './23vivi_accordion_list import MarketPieceList from '../market/market_piece_list'; let Vivi23PieceList = React.createClass({ - propTypes: { - // Provided from router - location: React.PropTypes.object - }, - render() { return ( + submitMessage={getLangText('Submit')}> {this.getLicenses()} ); 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 eb781f50..4ab98e57 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 @@ -34,7 +34,6 @@ const CylandPieceContainer = React.createClass({ router: routerShape.isRequired, // Provided from router - location: React.PropTypes.object, params: React.PropTypes.object }, diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js b/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js index 5c0e7620..275ceb69 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js @@ -15,10 +15,7 @@ let CylandPieceList = React.createClass({ propTypes: { // Injected through HOCs currentUser: currentUserShape.isRequired, - whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, shouldRedirect(pieceCount) { 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 295ea4da..e4c2e631 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -24,7 +24,7 @@ import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; import withContext from '../../../../context/with_context'; -import { currentUserShape, routerShape, whitelabelShape } from '../../../../prop_types'; +import { currentUserShape, locationShape, routerShape, whitelabelShape } from '../../../../prop_types'; import ApiUrls from '../../../../../constants/api_urls'; @@ -38,11 +38,9 @@ const CylandRegisterPiece = React.createClass({ propTypes: { // Injected through HOCs currentUser: currentUserShape.isRequired, + location: locationShape.isRequired, router: routerShape.isRequired, whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object }, getInitialState(){ @@ -128,7 +126,7 @@ const CylandRegisterPiece = React.createClass({ }, render() { - const { currentUser, location, whitelabel } = this.props; + const { currentUser, whitelabel } = this.props; const { piece, step } = this.state; const today = new Moment(); @@ -163,8 +161,7 @@ const CylandRegisterPiece = React.createClass({ glyphiconClassNames={{ pending: 'glyphicon glyphicon-chevron-right', completed: 'glyphicon glyphicon-lock' - }} - location={location}> + }}>
@@ -219,4 +216,4 @@ const CylandRegisterPiece = React.createClass({ } }); -export default withContext(CylandRegisterPiece, 'currentUser', 'router', 'whitelabel'); +export default withContext(CylandRegisterPiece, 'currentUser', 'location', 'router', 'whitelabel'); 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 2bc127a9..a556ff30 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js @@ -28,10 +28,7 @@ const IkonotvContractNotifications = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, router: routerShape.isRequired, - whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, getInitialState() { 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 b4e2b001..369ad8e3 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 @@ -35,7 +35,6 @@ const IkonotvPieceContainer = React.createClass({ router: routerShape.isRequired, // Provided from router - location: React.PropTypes.object, params: React.PropTypes.object }, diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js index 55ca0e45..000180df 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js @@ -7,6 +7,7 @@ import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; import withContext from '../../../../context/with_context'; +import { locationShape } from '../../../../prop_types'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getLangText } from '../../../../../utils/lang_utils'; @@ -15,24 +16,22 @@ import { getLangText } from '../../../../../utils/lang_utils'; let IkonotvLanding = React.createClass({ propTypes: { // Injected through HOCs - isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + isLoggedIn: React.PropTypes.bool.isRequired, + location: locationShape.isRequired }, getEnterButton() { - const { isLoggedIn, location } = this.props; + const { isLoggedIn, location: { query } } = this.props; let redirect = '/login'; if (isLoggedIn) { redirect = '/collection'; - } else if (location.query.redirect) { - redirect = '/' + location.query.redirect; + } else if (query.redirect) { + redirect = `/${query.redirect}`; } return ( - + @@ -102,4 +101,4 @@ let IkonotvLanding = React.createClass({ } }); -export default withContext(IkonotvLanding, 'isLoggedIn'); +export default withContext(IkonotvLanding, 'isLoggedIn', 'location'); diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js index 014c2712..10ad82a6 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js @@ -19,12 +19,7 @@ let IkonotvPieceList = React.createClass({ propTypes: { // Injected through HOCs currentUser: currentUserShape.isRequired, - whitelabel: whitelabelShape.isRequired, - - // Provided from WalletApp - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired }, getInitialState() { 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 46801b90..b9b21454 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js @@ -22,7 +22,7 @@ import LoanForm from '../../../../ascribe_forms/form_loan'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; import withContext from '../../../../context/with_context'; -import { currentUserShape, routerShape, whitelabelShape } from '../../../../prop_types'; +import { currentUserShape, locationShape, routerShape, whitelabelShape } from '../../../../prop_types'; import ApiUrls from '../../../../../constants/api_urls'; @@ -36,11 +36,9 @@ const IkonotvRegisterPiece = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types + location: locationShape.isRequired, // eslint-disable-line react/sort-prop-types router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object }, getInitialState() { @@ -209,7 +207,6 @@ const IkonotvRegisterPiece = React.createClass({ }, render() { - const { location } = this.props; const { pageExitWarning, step } = this.state; return ( @@ -220,7 +217,6 @@ const IkonotvRegisterPiece = React.createClass({ pending: 'glyphicon glyphicon-chevron-right', completed: 'glyphicon glyphicon-lock' }} - location={location} pageExitWarning={pageExitWarning}>
@@ -244,4 +240,4 @@ const IkonotvRegisterPiece = React.createClass({ } }); -export default withContext(IkonotvRegisterPiece, 'currentUser', 'router', 'whitelabel'); +export default withContext(IkonotvRegisterPiece, 'currentUser', 'location', 'router', 'whitelabel'); diff --git a/js/components/whitelabel/wallet/components/market/market_piece_list.js b/js/components/whitelabel/wallet/components/market/market_piece_list.js index 63bed28f..3084fbc2 100644 --- a/js/components/whitelabel/wallet/components/market/market_piece_list.js +++ b/js/components/whitelabel/wallet/components/market/market_piece_list.js @@ -17,10 +17,7 @@ let MarketPieceList = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from router - location: React.PropTypes.object + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, componentWillMount() { 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 ad2a91d6..c5e326be 100644 --- a/js/components/whitelabel/wallet/components/market/market_register_piece.js +++ b/js/components/whitelabel/wallet/components/market/market_register_piece.js @@ -17,7 +17,7 @@ import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; import withContext from '../../../../context/with_context'; -import { routerShape, whitelabelShape } from '../../../../prop_types'; +import { locationShape, routerShape, whitelabelShape } from '../../../../prop_types'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { mergeOptions } from '../../../../../utils/general_utils'; @@ -27,10 +27,8 @@ let MarketRegisterPiece = React.createClass({ propTypes: { // Injected through HOCs router: routerShape.isRequired, - whitelabel: whitelabelShape.isRequired, - - // Provided from router - location: React.PropTypes.object + location: locationShape.isRequired, + whitelabel: whitelabelShape.isRequired }, getInitialState(){ @@ -99,12 +97,7 @@ let MarketRegisterPiece = React.createClass({ }, render() { - const { - location, - whitelabel: { - name: whitelabelName = 'Market' - } - } = this.props + const { whitelabel: { name: whitelabelName = 'Market' } } = this.props; const { piece, step } = this.state; setDocumentTitle(getLangText('Register a new piece')); @@ -116,8 +109,7 @@ let MarketRegisterPiece = React.createClass({ glyphiconClassNames={{ pending: 'glyphicon glyphicon-chevron-right', completed: 'glyphicon glyphicon-lock' - }} - location={location}> + }}>
@@ -160,4 +152,4 @@ let MarketRegisterPiece = React.createClass({ } }); -export default withContext(MarketRegisterPiece, 'router', 'whitelabel'); +export default withContext(MarketRegisterPiece, 'location', 'router', 'whitelabel');