1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Convert usages of withRouter to withContext

This commit is contained in:
Brett Sun 2016-06-08 13:52:24 +02:00
parent 5073b0988d
commit 5a0a6e88db
17 changed files with 103 additions and 85 deletions

View File

@ -1,7 +1,6 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
@ -11,20 +10,21 @@ import EditionListActions from '../../actions/edition_list_actions';
import PieceListActions from '../../actions/piece_list_actions';
import PieceListStore from '../../stores/piece_list_store';
import Form from './../ascribe_forms/form';
import Property from './../ascribe_forms/property';
import ListRequestActions from './../ascribe_forms/list_form_request_actions';
import AclButtonList from './../ascribe_buttons/acl_button_list';
import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button';
import DeleteButton from '../ascribe_buttons/delete_button';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
import Form from './../ascribe_forms/form';
import ListRequestActions from './../ascribe_forms/list_form_request_actions';
import Property from './../ascribe_forms/property';
import AclButtonList from './../ascribe_buttons/acl_button_list';
import AclInformation from '../ascribe_buttons/acl_information';
import DeleteButton from '../ascribe_buttons/delete_button';
import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button';
import AclProxy from '../acl_proxy';
import withContext from '../context/with_context';
import { routerShape } from '../prop_types';
import ApiUrls from '../../constants/api_urls';
@ -37,10 +37,12 @@ import { getLangText } from '../../utils/lang_utils';
const EditionActionPanel = React.createClass({
propTypes: {
edition: React.PropTypes.object.isRequired,
router: React.PropTypes.object.isRequired,
actionPanelButtonListType: React.PropTypes.func,
handleSuccess: React.PropTypes.func
handleSuccess: React.PropTypes.func,
// Injected through HOCs
router: routerShape.isRequired // eslint-disable-line react/sort-prop-types
},
getDefaultProps() {
@ -179,4 +181,4 @@ const EditionActionPanel = React.createClass({
}
});
export default withRouter(EditionActionPanel);
export default withContext(EditionActionPanel, 'router');

View File

@ -1,7 +1,6 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Moment from 'moment';
import ReactError from '../../mixins/react_error';
@ -38,6 +37,7 @@ import ListRequestActions from '../ascribe_forms/list_form_request_actions';
import AclProxy from '../acl_proxy';
import AscribeSpinner from '../ascribe_spinner';
import withContext from '../context/with_context';
import { routerShape } from '../prop_types';
import ApiUrls from '../../constants/api_urls';
@ -50,12 +50,11 @@ import { getLangText } from '../../utils/lang_utils';
*/
const PieceContainer = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
furtherDetailsType: React.PropTypes.func,
// Injected through HOCs
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types
// Provided from router
location: React.PropTypes.object,
@ -341,4 +340,4 @@ const PieceContainer = React.createClass({
}
});
export default withRouter(withContext(PieceContainer, 'isLoggedIn'));
export default withContext(PieceContainer, 'isLoggedIn', 'router');

View File

@ -1,7 +1,6 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import ContractListActions from '../../actions/contract_list_actions';
import ContractListStore from '../../stores/contract_list_store';
@ -13,8 +12,11 @@ import Form from './form';
import Property from './property';
import InputTextAreaToggable from './input_textarea_toggable';
import ApiUrls from '../../constants/api_urls';
import AscribeSpinner from '../ascribe_spinner';
import withContext from '../context/with_context';
import { routerShape } from '../prop_types';
import ApiUrls from '../../constants/api_urls';
import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
@ -22,7 +24,10 @@ import { mergeOptions } from '../../utils/general_utils';
const SendContractAgreementForm = React.createClass({
propTypes: {
handleSuccess: React.PropTypes.func
handleSuccess: React.PropTypes.func,
// Injected through HOCs
router: routerShape.isRequired // eslint-disable-line react/sort-prop-types
},
getInitialState() {
@ -149,4 +154,4 @@ const SendContractAgreementForm = React.createClass({
}
});
export default withRouter(SendContractAgreementForm);
export default withContext(SendContractAgreementForm, 'router');

View File

@ -1,12 +1,11 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import UserStore from '../../stores/user_store';
import withContext from '../context/with_context';
import { currentUserShape, whitelabelShape } from '../prop_types';
import { currentUserShape, routerShape, whitelabelShape } from '../prop_types';
import AppConstants from '../../constants/application_constants';
@ -85,7 +84,7 @@ export function ProxyHandler(...redirectFunctions) {
// Injected through HOCs
currentUser: currentUserShape.isRequired,
isLoggedIn: bool.isRequired,
router: React.PropTypes.object.isRequired,
router: routerShape.isRequired,
whitelabel: whitelabelShape.isRequired,
// Provided from router
@ -134,6 +133,6 @@ export function ProxyHandler(...redirectFunctions) {
}
});
return withRouter(withContext(ProxyHandlerComponent, 'currentUser', 'isLoggedIn', 'whitelabel'));
return withContext(ProxyHandlerComponent, 'currentUser', 'isLoggedIn', 'router', 'whitelabel');
};
}

View File

@ -1,17 +1,18 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs';
import withContext from '../context/with_context';
import { routerShape } from '../prop_types';
const { arrayOf, element, bool, shape, string, object } = React.PropTypes;
const SlidesContainer = React.createClass({
propTypes: {
forwardProcess: bool.isRequired,
router: object.isRequired,
children: arrayOf(element),
glyphiconClassNames: shape({
@ -19,7 +20,10 @@ const SlidesContainer = React.createClass({
complete: string
}),
location: object,
pageExitWarning: string
pageExitWarning: string,
// Injected through HOCs
router: routerShape.isRequired // eslint-disable-line react/sort-prop-types
},
contextTypes: {
@ -186,4 +190,4 @@ const SlidesContainer = React.createClass({
}
});
export default withRouter(SlidesContainer);
export default withContext(SlidesContainer, 'router');

View File

@ -1,10 +1,9 @@
import React from 'react';
import { currentUserShape, whitelabelShape } from '../prop_types';
import { currentUserShape, routerShape, whitelabelShape } from '../prop_types';
import { selectFromObject } from '../../utils/general_utils';
import { getDisplayName } from '../../utils/react_utils';
/**
* ContextPropDefinitions
* ======================
@ -43,6 +42,7 @@ const ContextPropDefinitions = {
},
transformToProps: ({ currentUser }) => ({ isLoggedIn: !!currentUser.email })
},
router: routerShape.isRequired,
whitelabel: whitelabelShape.isRequired
};

View File

@ -1,21 +1,28 @@
'use strict';
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import ApiUrls from '../constants/api_urls';
import AscribeSpinner from './ascribe_spinner';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
import { getLangText } from '../utils/lang_utils';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import AscribeSpinner from './ascribe_spinner';
import withContext from './context/with_context';
import { routerShape } from './prop_types';
import ApiUrls from '../constants/api_urls';
import { setDocumentTitle } from '../utils/dom_utils';
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
},
@ -104,7 +111,7 @@ let PasswordRequestResetForm = React.createClass({
}
});
let PasswordResetForm = withRouter(React.createClass({
let PasswordResetForm = withContext(React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
@ -171,6 +178,6 @@ let PasswordResetForm = withRouter(React.createClass({
</Form>
);
}
}));
}), 'router');
export default PasswordResetContainer;

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions';
@ -22,17 +21,17 @@ import PieceListBulkModal from './ascribe_piece_list_bulk_modal/piece_list_bulk_
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 { getAvailableAcls } from '../utils/acl_utils';
import { setDocumentTitle } from '../utils/dom_utils';
import { mergeOptions, isShallowEqual } from '../utils/general_utils';
import { getLangText } from '../utils/lang_utils';
import { setDocumentTitle } from '../utils/dom_utils';
const PieceList = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
accordionListItemType: React.PropTypes.func,
bulkModalButtonListType: React.PropTypes.func,
canLoadPieceList: React.PropTypes.bool,
@ -47,6 +46,9 @@ const PieceList = React.createClass({
orderParams: React.PropTypes.array,
orderBy: React.PropTypes.string,
// Injected through HOCs
router: routerShape.isRequired, // eslint-disable-line react/sort-prop-types
// Provided from router
location: React.PropTypes.object
},
@ -350,4 +352,4 @@ const PieceList = React.createClass({
}
});
export default withRouter(PieceList);
export default withContext(PieceList, 'router');

View File

@ -1,2 +1,5 @@
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';

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row';
@ -14,16 +13,14 @@ import Property from './ascribe_forms/property';
import RegisterPieceForm from './ascribe_forms/form_register_piece';
import withContext from './context/with_context';
import { whitelabelShape } from './prop_types';
import { routerShape, whitelabelShape } from './prop_types';
import { getLangText } from '../utils/lang_utils';
import { setDocumentTitle } from '../utils/dom_utils';
import { getLangText } from '../utils/lang_utils';
const RegisterPiece = React.createClass( {
propTypes: {
router: React.PropTypes.object.isRequired,
headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string,
children: React.PropTypes.oneOfType([
@ -33,7 +30,8 @@ const RegisterPiece = React.createClass( {
]),
// Injected through HOCs
whitelabel: whitelabelShape.isRequired,
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
@ -107,4 +105,4 @@ const RegisterPiece = React.createClass( {
}
});
export default withRouter(withContext(RegisterPiece, 'whitelabel'));
export default withContext(RegisterPiece, 'router', 'whitelabel');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import EditionListActions from '../../../../../../actions/edition_list_actions';
@ -21,15 +20,18 @@ import WalletPieceContainer from '../../ascribe_detail/wallet_piece_container';
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
import AscribeSpinner from '../../../../../ascribe_spinner';
import withContext from '../../../../../context/with_context';
import { routerShape } from '../../../../../prop_types';
import { getLangText } from '../../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../../utils/dom_utils';
import { mergeOptions } from '../../../../../../utils/general_utils';
import { getLangText } from '../../../../../../utils/lang_utils';
const CylandPieceContainer = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
// Injected through HOCs
router: routerShape.isRequired,
// Provided from router
location: React.PropTypes.object,
@ -120,4 +122,4 @@ const CylandPieceContainer = React.createClass({
}
});
export default withRouter(CylandPieceContainer);
export default withContext(CylandPieceContainer, 'router');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Moment from 'moment';
@ -25,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, whitelabelShape } from '../../../../prop_types';
import { currentUserShape, routerShape, whitelabelShape } from '../../../../prop_types';
import ApiUrls from '../../../../../constants/api_urls';
@ -37,10 +36,9 @@ import { mergeOptions } from '../../../../../utils/general_utils';
const CylandRegisterPiece = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
// Injected through HOCs
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
currentUser: currentUserShape.isRequired,
router: routerShape.isRequired,
whitelabel: whitelabelShape.isRequired,
// Provided from router
@ -221,4 +219,4 @@ const CylandRegisterPiece = React.createClass({
}
});
export default withRouter(withContext(CylandRegisterPiece, 'currentUser', 'isLoggedIn'));
export default withContext(CylandRegisterPiece, 'currentUser', 'router', 'whitelabel');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import Button from 'react-bootstrap/lib/Button';
@ -16,7 +15,7 @@ import CopyrightAssociationForm from '../../../../ascribe_forms/form_copyright_a
import Property from '../../../../ascribe_forms/property';
import withContext from '../../../../context/with_context';
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
import { currentUserShape, routerShape, whitelabelShape } from '../../../../prop_types';
import AppConstants from '../../../../../constants/application_constants';
@ -26,11 +25,10 @@ import { getLangText } from '../../../../../utils/lang_utils';
const IkonotvContractNotifications = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
// Injected through HOCs
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types
currentUser: currentUserShape.isRequired,
router: routerShape.isRequired,
whitelabel: whitelabelShape.isRequired,
// Provided from router
location: React.PropTypes.object
@ -201,4 +199,4 @@ const IkonotvContractNotifications = React.createClass({
}
});
export default withRouter(withContext(IkonotvContractNotifications, 'currentUser', 'whitelabel'));
export default withContext(IkonotvContractNotifications, 'currentUser', 'router', 'whitelabel');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import EditionListActions from '../../../../../../actions/edition_list_actions';
@ -22,15 +21,18 @@ import WalletPieceContainer from '../../ascribe_detail/wallet_piece_container';
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
import AscribeSpinner from '../../../../../ascribe_spinner';
import withContext from '../../../../../context/with_context';
import { routerShape } from '../../../../../prop_types';
import { getLangText } from '../../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../../utils/dom_utils';
import { mergeOptions } from '../../../../../../utils/general_utils';
import { getLangText } from '../../../../../../utils/lang_utils';
const IkonotvPieceContainer = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
// Injected through HOCs
router: routerShape.isRequired,
// Provided from router
location: React.PropTypes.object,
@ -138,4 +140,4 @@ const IkonotvPieceContainer = React.createClass({
}
});
export default withRouter(IkonotvPieceContainer);
export default withContext(IkonotvPieceContainer, 'router');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Moment from 'moment';
import Col from 'react-bootstrap/lib/Col';
@ -23,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, whitelabelShape } from '../../../../prop_types';
import { currentUserShape, routerShape, whitelabelShape } from '../../../../prop_types';
import ApiUrls from '../../../../../constants/api_urls';
@ -33,12 +32,11 @@ import { getLangText } from '../../../../../utils/lang_utils';
const IkonotvRegisterPiece = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
handleSuccess: React.PropTypes.func,
// Injected through HOCs
currentUser: currentUserShape.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
@ -246,4 +244,4 @@ const IkonotvRegisterPiece = React.createClass({
}
});
export default withRouter(withContext(IkonotvRegisterPiece, 'currentUser', 'whitelabel'));
export default withContext(IkonotvRegisterPiece, 'currentUser', 'router', 'whitelabel');

View File

@ -1,5 +1,4 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row';
@ -18,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 { whitelabelShape } from '../../../../prop_types';
import { routerShape, whitelabelShape } from '../../../../prop_types';
import { setDocumentTitle } from '../../../../../utils/dom_utils';
import { mergeOptions } from '../../../../../utils/general_utils';
@ -26,9 +25,8 @@ import { getLangText } from '../../../../../utils/lang_utils';
let MarketRegisterPiece = React.createClass({
propTypes: {
router: React.PropTypes.object.isRequired,
// Injected through HOCs
router: routerShape.isRequired,
whitelabel: whitelabelShape.isRequired,
// Provided from router
@ -162,4 +160,4 @@ let MarketRegisterPiece = React.createClass({
}
});
export default withRouter(withContext(MarketRegisterPiece, 'whitelabel'));
export default withContext(MarketRegisterPiece, 'router', 'whitelabel');

View File

@ -1,9 +1,10 @@
import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import classNames from 'classnames';
import AppBase from '../../app_base';
import withContext from '../../context/with_context';
import Header from '../../header';
import { routerShape } from '../../prop_types';
import { getSubdomain } from '../../../utils/general_utils';
@ -12,8 +13,10 @@ let WalletApp = React.createClass({
propTypes: {
activeRoute: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired,
router: React.PropTypes.object.isRequired,
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
// Injected through HOCs
router: routerShape.isRequired,
},
render() {
@ -48,4 +51,4 @@ let WalletApp = React.createClass({
}
});
export default AppBase(withRouter(WalletApp));
export default AppBase(withContext(WalletApp, 'router'));