From b02695a33ab1221dd093b0599882f0882e2d2006 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 7 Jun 2016 14:53:48 +0200 Subject: [PATCH] Convert whitelabel to be passed down through context and withWhitelabel HOC --- js/components/app_base.js | 13 +++++----- .../accordion_list_item_wallet.js | 13 ++++++---- js/components/ascribe_app.js | 12 +++------- js/components/ascribe_detail/edition.js | 10 ++------ .../ascribe_detail/edition_action_panel.js | 8 ++----- .../ascribe_detail/edition_container.js | 8 ++----- .../ascribe_detail/piece_container.js | 3 --- .../ascribe_settings/account_settings.js | 10 ++++---- .../ascribe_settings/contract_settings.js | 12 ++++------ .../ascribe_settings/settings_container.js | 13 ++++------ js/components/coa_verify_container.js | 3 --- js/components/header.js | 8 +++---- js/components/login_container.js | 19 ++++++++------- js/components/password_reset_container.js | 3 --- js/components/piece_list.js | 22 +++++++---------- js/components/prop_types/index.js | 1 + js/components/prop_types/whitelabel_shape.js | 11 +++++++++ js/components/register_piece.js | 5 ++-- js/components/signup_container.js | 17 ++++++++----- .../components/23vivi/23vivi_landing.js | 13 +++++----- .../components/23vivi/23vivi_piece_list.js | 3 --- .../components/artcity/artcity_landing.js | 9 ++++--- .../wallet/components/cc/cc_register_piece.js | 3 --- .../cyland_detail/cyland_piece_container.js | 3 --- .../components/cyland/cyland_landing.js | 10 ++++---- .../components/cyland/cyland_piece_list.js | 12 ++++------ .../cyland/cyland_register_piece.js | 10 ++++---- .../wallet/components/demo/demo_landing.js | 10 ++++---- .../ikonotv/ikonotv_contract_notifications.js | 10 ++++---- .../ikonotv_detail/ikonotv_piece_container.js | 3 --- .../components/ikonotv/ikonotv_landing.js | 3 --- .../components/ikonotv/ikonotv_piece_list.js | 10 ++++---- .../ikonotv/ikonotv_register_piece.js | 10 ++++---- .../components/lumenus/lumenus_landing.js | 14 +++++------ .../market_buttons/market_acl_button_list.js | 17 +++++++------ .../market_buttons/market_submit_button.js | 24 ++++++++++--------- .../components/market/market_landing.js | 12 +++++----- .../components/market/market_piece_list.js | 10 ++++---- .../market/market_register_piece.js | 21 +++++++++------- .../components/polline/polline_landing.js | 12 +++++----- js/components/whitelabel/wallet/wallet_app.js | 12 +++------- js/utils/react_utils.js | 24 ++++++++++++++++++- 42 files changed, 217 insertions(+), 229 deletions(-) create mode 100644 js/components/prop_types/whitelabel_shape.js diff --git a/js/components/app_base.js b/js/components/app_base.js index 735c4cc4..6fc6c1ed 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 } from './prop_types'; +import { currentUserShape, whitelabelShape } from './prop_types'; import { mergeOptions } from '../utils/general_utils'; @@ -23,7 +23,8 @@ export default function AppBase(App) { }, childContextTypes: { - currentUser: currentUserShape + currentUser: currentUserShape, + whitelabel: whitelabelShape }, getInitialState() { @@ -34,9 +35,9 @@ export default function AppBase(App) { }, getChildContext() { - const { currentUser } = this.state; + const { currentUser, whitelabel } = this.state; - return { currentUser }; + return { currentUser, whitelabel }; }, componentDidMount() { @@ -58,7 +59,6 @@ export default function AppBase(App) { render() { const { routes } = this.props; - const { whitelabel } = this.state; // The second element of the routes prop given to us by react-router is always the // active second-level component object (ie. after App). @@ -68,8 +68,7 @@ export default function AppBase(App) {
+ activeRoute={activeRoute} /> diff --git a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js index e752451e..a4a5ffe3 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js @@ -19,24 +19,27 @@ import AccordionListItemPiece from './accordion_list_item_piece'; import AccordionListItemEditionWidget from './accordion_list_item_edition_widget'; import CreateEditionsForm from '../ascribe_forms/create_editions_form'; - import AclProxy from '../acl_proxy'; +import { whitelabelShape } from '../prop_types'; -import { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_utils'; +import { getLangText } from '../../utils/lang_utils'; +import { withWhitelabel } from '../../utils/react_utils'; let AccordionListItemWallet = React.createClass({ propTypes: { content: React.PropTypes.object.isRequired, - whitelabel: React.PropTypes.object.isRequired, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element ]), className: React.PropTypes.string, - thumbnailPlaceholder: React.PropTypes.func + thumbnailPlaceholder: React.PropTypes.func, + + // Injected through HOCs + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, getInitialState() { @@ -162,4 +165,4 @@ let AccordionListItemWallet = React.createClass({ } }); -export default AccordionListItemWallet; +export default withWhitelabel(AccordionListItemWallet); diff --git a/js/components/ascribe_app.js b/js/components/ascribe_app.js index 2d506ab0..7a7fb2d6 100644 --- a/js/components/ascribe_app.js +++ b/js/components/ascribe_app.js @@ -11,22 +11,16 @@ const AscribeApp = React.createClass({ activeRoute: React.PropTypes.object.isRequired, children: React.PropTypes.element.isRequired, routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - - // Provided from AppBase - whitelabel: React.PropTypes.object }, render() { - const { activeRoute, children, routes, whitelabel } = this.props; + const { activeRoute, children, routes } = this.props; const showFooter = activeRoute && activeRoute.footer; return (
-
- +
+ {/* Routes are injected here */} {children} diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 2d7195c3..bb71e184 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -36,7 +36,6 @@ import { withCurrentUser } from '../../utils/react_utils'; const Edition = React.createClass({ propTypes: { edition: React.PropTypes.object.isRequired, - whitelabel: React.PropTypes.object.isRequired, actionPanelButtonListType: React.PropTypes.func, coaError: React.PropTypes.object, @@ -60,7 +59,6 @@ const Edition = React.createClass({ edition, isLoggedIn, loadEdition, - whitelabel, furtherDetailsType: FurtherDetailsType } = this.props; @@ -84,8 +82,7 @@ const Edition = React.createClass({ + handleSuccess={loadEdition} /> @@ -157,7 +154,6 @@ const Edition = React.createClass({ let EditionSummary = withCurrentUser(React.createClass({ propTypes: { edition: React.PropTypes.object.isRequired, - whitelabel: React.PropTypes.object.isRequired, actionPanelButtonListType: React.PropTypes.func, handleSuccess: React.PropTypes.func, @@ -182,7 +178,6 @@ let EditionSummary = withCurrentUser(React.createClass({ edition, handleSuccess, isLoggedIn, - whitelabel } = this.props; return ( @@ -214,8 +209,7 @@ let EditionSummary = withCurrentUser(React.createClass({ + handleSuccess={handleSuccess} />
diff --git a/js/components/ascribe_detail/edition_action_panel.js b/js/components/ascribe_detail/edition_action_panel.js index b97525cc..efbf2e34 100644 --- a/js/components/ascribe_detail/edition_action_panel.js +++ b/js/components/ascribe_detail/edition_action_panel.js @@ -38,7 +38,6 @@ const EditionActionPanel = React.createClass({ propTypes: { edition: React.PropTypes.object.isRequired, router: React.PropTypes.object.isRequired, - whitelabel: React.PropTypes.object.isRequired, actionPanelButtonListType: React.PropTypes.func, handleSuccess: React.PropTypes.func @@ -99,9 +98,7 @@ const EditionActionPanel = React.createClass({ }, render() { - const { actionPanelButtonListType: ActionPanelButtonListType, - edition, - whitelabel } = this.props; + const { edition, actionPanelButtonListType: ActionPanelButtonListType } = this.props; if (edition.notifications && edition.notifications.length) { return ( @@ -117,8 +114,7 @@ const EditionActionPanel = React.createClass({ availableAcls={edition.acl} className="ascribe-button-list" handleSuccess={this.handleSuccess} - pieceOrEditions={[edition]} - whitelabel={whitelabel}> + pieceOrEditions={[edition]} > diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index 6c6b669e..c061a0eb 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -24,9 +24,6 @@ let EditionContainer = React.createClass({ actionPanelButtonListType: React.PropTypes.func, furtherDetailsType: React.PropTypes.func, - // Provided from AscribeApp - whitelabel: React.PropTypes.object.isRequired, - // Provided from router location: React.PropTypes.object, params: React.PropTypes.object @@ -75,7 +72,7 @@ let EditionContainer = React.createClass({ }, render() { - const { actionPanelButtonListType, furtherDetailsType, whitelabel } = this.props; + const { actionPanelButtonListType, furtherDetailsType } = this.props; const { edition, coaMeta } = this.state; if (edition.id) { @@ -87,8 +84,7 @@ let EditionContainer = React.createClass({ coaError={coaMeta.err} edition={edition} furtherDetailsType={furtherDetailsType} - loadEdition={this.loadEdition} - whitelabel={whitelabel} /> + loadEdition={this.loadEdition} /> ); } else { return ( diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 7d4d982d..e750568b 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -57,9 +57,6 @@ const PieceContainer = React.createClass({ // Injected through HOCs isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types - // Provided from AscribeApp - whitelabel: React.PropTypes.object, - // Provided from router location: React.PropTypes.object, params: React.PropTypes.object diff --git a/js/components/ascribe_settings/account_settings.js b/js/components/ascribe_settings/account_settings.js index 7f8ce388..b4ca588c 100644 --- a/js/components/ascribe_settings/account_settings.js +++ b/js/components/ascribe_settings/account_settings.js @@ -14,20 +14,20 @@ import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph'; import AclProxy from '../acl_proxy'; import AscribeSpinner from '../ascribe_spinner'; -import { currentUserShape } from '../prop_types'; +import { currentUserShape, whitelabelShape } from '../prop_types'; import ApiUrls from '../../constants/api_urls'; import { getLangText } from '../../utils/lang_utils'; -import { withCurrentUser } from '../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../utils/react_utils'; let AccountSettings = React.createClass({ propTypes: { loadUser: React.PropTypes.func.isRequired, - whitelabel: React.PropTypes.object.isRequired // Injected through HOCs - currentUser: currentUserShape.isRequired // eslint-disable-line react/sort-prop-types + currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, handleSuccess() { @@ -112,4 +112,4 @@ let AccountSettings = React.createClass({ } }); -export default withCurrentUser(AccountSettings); +export default withCurrentUser(withWhitelabel(AccountSettings)); diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js index c812f6df..51afb34b 100644 --- a/js/components/ascribe_settings/contract_settings.js +++ b/js/components/ascribe_settings/contract_settings.js @@ -16,21 +16,19 @@ import CreateContractForm from '../ascribe_forms/form_create_contract'; import ActionPanel from '../ascribe_panel/action_panel'; import AclProxy from '../acl_proxy'; -import { currentUserShape } from '../prop_types'; +import { currentUserShape, whitelabelShape } from '../prop_types'; import { setDocumentTitle } from '../../utils/dom_utils'; import { truncateTextAtCharIndex } from '../../utils/general_utils'; import { getLangText } from '../../utils/lang_utils'; -import { withCurrentUser } from '../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../utils/react_utils'; let ContractSettings = React.createClass({ propTypes: { // Injected through HOCs - currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from AscribeApp - whitelabel: React.PropTypes.object.isRequired, + currentUser: currentUserShape.isRequired, + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object @@ -185,4 +183,4 @@ let ContractSettings = React.createClass({ } }); -export default ContractSettings; +export default withCurrentUser(withWhitelabel(ContractSettings)); diff --git a/js/components/ascribe_settings/settings_container.js b/js/components/ascribe_settings/settings_container.js index e968a874..e7e4dce4 100644 --- a/js/components/ascribe_settings/settings_container.js +++ b/js/components/ascribe_settings/settings_container.js @@ -10,10 +10,11 @@ import BitcoinWalletSettings from './bitcoin_wallet_settings'; import WebhookSettings from './webhook_settings'; import AclProxy from '../acl_proxy'; +import { whitelabelShape } from '../prop_types'; import { setDocumentTitle } from '../../utils/dom_utils'; import { getLangText } from '../../utils/lang_utils'; -import { withCurrentUser } from '../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../utils/react_utils'; let SettingsContainer = React.createClass({ @@ -25,9 +26,7 @@ let SettingsContainer = React.createClass({ // Injected through HOCs isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from AscribeApp - whitelabel: React.PropTypes.object.isRequired, + whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router location: React.PropTypes.object @@ -45,9 +44,7 @@ let SettingsContainer = React.createClass({ if (isLoggedIn) { return (
- + {children} ; @@ -311,7 +309,6 @@ const PieceList = React.createClass({ availableAcls={availableAcls} handleSuccess={this.handleAclSuccess} pieceOrEditions={selectedEditions} - whitelabel={whitelabel} className="text-center ascribe-button-list collapse-group"> + thumbnailPlaceholder={customThumbnailPlaceholder}> diff --git a/js/components/prop_types/index.js b/js/components/prop_types/index.js index 7f95e291..e9b3a67c 100644 --- a/js/components/prop_types/index.js +++ b/js/components/prop_types/index.js @@ -1 +1,2 @@ export { default as currentUserShape } from './current_user_shape'; +export { default as whitelabelShape } from './whitelabel_shape'; diff --git a/js/components/prop_types/whitelabel_shape.js b/js/components/prop_types/whitelabel_shape.js new file mode 100644 index 00000000..72f8bc36 --- /dev/null +++ b/js/components/prop_types/whitelabel_shape.js @@ -0,0 +1,11 @@ +import React from 'react'; + + +const { shape, string } = React.PropTypes; + +export default shape({ + name: string, + subdomain: string, + title: string, + user: string +}); diff --git a/js/components/register_piece.js b/js/components/register_piece.js index 75aa6b20..6bbd6fe3 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -13,6 +13,7 @@ import GlobalNotificationActions from '../actions/global_notification_actions'; import Property from './ascribe_forms/property'; import RegisterPieceForm from './ascribe_forms/form_register_piece'; +import { whitelabelShape } from './prop_types'; import { getLangText } from '../utils/lang_utils'; import { setDocumentTitle } from '../utils/dom_utils'; @@ -29,8 +30,8 @@ const RegisterPiece = React.createClass( { React.PropTypes.string ]), - // Provided from AscribeApp - whitelabel: React.PropTypes.object.isRequired, + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object diff --git a/js/components/signup_container.js b/js/components/signup_container.js index 1e5b8767..74c21218 100644 --- a/js/components/signup_container.js +++ b/js/components/signup_container.js @@ -3,14 +3,17 @@ import Link from 'react-router/es6/Link'; import SignupForm from './ascribe_forms/form_signup'; -import { getLangText } from '../utils/lang_utils'; +import { whitelabelShape } from './prop_types'; + import { setDocumentTitle } from '../utils/dom_utils'; +import { getLangText } from '../utils/lang_utils'; +import { withWhitelabel } from '../utils/react_utils'; let SignupContainer = React.createClass({ propTypes: { - // Provided from AscribeApp - whitelabel: React.PropTypes.object, + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router location: React.PropTypes.object @@ -31,8 +34,10 @@ let SignupContainer = React.createClass({ }, render() { - const { location, - whitelabel: { name: whitelabelName } } = this.props; + const { + location, + whitelabel: { name: whitelabelName } + } = this.props; const { message, submitted } = this.state; setDocumentTitle(getLangText('Sign up')); @@ -63,4 +68,4 @@ let SignupContainer = React.createClass({ }); -export default SignupContainer; +export default withWhitelabel(SignupContainer); diff --git a/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js b/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js index b0f45e38..fa2849a3 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_landing.js @@ -5,16 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; -import { getLangText } from '../../../../../utils/lang_utils'; +import { whitelabelShape } from '../../../../prop_types'; + import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let Vivi23Landing = React.createClass({ propTypes: { - customThumbnailPlaceholder: React.PropTypes.func, - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object @@ -68,4 +69,4 @@ let Vivi23Landing = React.createClass({ } }); -export default Vivi23Landing; +export default withWhitelabel(Vivi23Landing); 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 0ad8789c..96231b1f 100644 --- a/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js +++ b/js/components/whitelabel/wallet/components/23vivi/23vivi_piece_list.js @@ -8,9 +8,6 @@ import MarketPieceList from '../market/market_piece_list'; let Vivi23PieceList = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object, - // Provided from router location: React.PropTypes.object }, diff --git a/js/components/whitelabel/wallet/components/artcity/artcity_landing.js b/js/components/whitelabel/wallet/components/artcity/artcity_landing.js index 6ecefd8e..766be2da 100644 --- a/js/components/whitelabel/wallet/components/artcity/artcity_landing.js +++ b/js/components/whitelabel/wallet/components/artcity/artcity_landing.js @@ -5,14 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; +import { whitelabelShape } from '../../../../prop_types'; + import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let ArtcityLanding = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired + // Injected through HOCs + whitelabel: whitelabelShape.isRequired }, componentWillMount() { @@ -60,4 +63,4 @@ let ArtcityLanding = React.createClass({ } }); -export default ArtcityLanding; +export default withWhitelabel(ArtcityLanding); diff --git a/js/components/whitelabel/wallet/components/cc/cc_register_piece.js b/js/components/whitelabel/wallet/components/cc/cc_register_piece.js index a89d34c5..1530c453 100644 --- a/js/components/whitelabel/wallet/components/cc/cc_register_piece.js +++ b/js/components/whitelabel/wallet/components/cc/cc_register_piece.js @@ -13,9 +13,6 @@ import { mergeOptions } from '../../../../../utils/general_utils'; let CCRegisterPiece = React.createClass({ propTypes: { - // Provided from AscribeApp - whitelabel: React.PropTypes.object, - // Provided from router location: React.PropTypes.object }, 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 e1885356..ea950308 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 @@ -31,9 +31,6 @@ const CylandPieceContainer = React.createClass({ propTypes: { router: React.PropTypes.object.isRequired, - // Provided from WalletApp - whitelabel: React.PropTypes.object, - // Provided from router location: React.PropTypes.object, params: React.PropTypes.object diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_landing.js b/js/components/whitelabel/wallet/components/cyland/cyland_landing.js index d61837b7..9b9f74d1 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_landing.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_landing.js @@ -6,15 +6,17 @@ import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; +import { whitelabelShape } from '../../../../prop_types'; -import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let CylandLanding = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, }, render() { @@ -62,4 +64,4 @@ let CylandLanding = React.createClass({ } }); -export default CylandLanding; +export default withWhitelabel(CylandLanding); 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 6de2571a..d24d963c 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_piece_list.js @@ -5,19 +5,17 @@ import PieceList from '../../../../piece_list'; import CylandAccordionListItem from './cyland_accordion_list/cyland_accordion_list_item'; -import { currentUserShape } from '../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getLangText } from '../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils'; let CylandPieceList = React.createClass({ propTypes: { // Injected through HOCs - currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + currentUser: currentUserShape.isRequired, + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object @@ -59,4 +57,4 @@ let CylandPieceList = React.createClass({ } }); -export default withCurrentUser(CylandPieceList); +export default withCurrentUser(withWhitelabel(CylandPieceList)); 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 f98769c2..99edb2c0 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 { currentUserShape } from '../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import ApiUrls from '../../../../../constants/api_urls'; @@ -32,7 +32,7 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getAclFormMessage } from '../../../../../utils/form_utils'; import { getLangText } from '../../../../../utils/lang_utils'; import { mergeOptions } from '../../../../../utils/general_utils'; -import { withCurrentUser } from '../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils'; const CylandRegisterPiece = React.createClass({ @@ -41,9 +41,7 @@ const CylandRegisterPiece = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object @@ -223,4 +221,4 @@ const CylandRegisterPiece = React.createClass({ } }); -export default withRouter(withCurrentUser(CylandRegisterPiece)); +export default withRouter(withCurrentUser(withWhitelabel(CylandRegisterPiece))); diff --git a/js/components/whitelabel/wallet/components/demo/demo_landing.js b/js/components/whitelabel/wallet/components/demo/demo_landing.js index 5d6a816a..5b005813 100644 --- a/js/components/whitelabel/wallet/components/demo/demo_landing.js +++ b/js/components/whitelabel/wallet/components/demo/demo_landing.js @@ -5,17 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; -import WhitelabelActions from '../../../../../actions/whitelabel_actions'; -import WhitelabelStore from '../../../../../stores/whitelabel_store'; +import { whitelabelShape } from '../../../../prop_types'; -import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let DemoLanding = React.createClass({ propTypes: { // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired + whitelabel: whitelabelShape.isRequired, }, componentWillMount() { @@ -63,4 +63,4 @@ let DemoLanding = React.createClass({ } }); -export default DemoLanding; +export default withWhitelabel(DemoLanding); 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 28157e97..a0d6d7a2 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js @@ -15,13 +15,13 @@ import OwnershipFetcher from '../../../../../fetchers/ownership_fetcher'; import CopyrightAssociationForm from '../../../../ascribe_forms/form_copyright_association'; import Property from '../../../../ascribe_forms/property'; -import { currentUserShape } from '../../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import AppConstants from '../../../../../constants/application_constants'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getLangText } from '../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils'; const IkonotvContractNotifications = React.createClass({ @@ -30,9 +30,7 @@ const IkonotvContractNotifications = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router location: React.PropTypes.object @@ -203,4 +201,4 @@ const IkonotvContractNotifications = React.createClass({ } }); -export default withRouter(withCurrentUser(IkonotvContractNotifications)); +export default withRouter(withCurrentUser(withWhitelabel(IkonotvContractNotifications))); 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 83ba3cd4..4e12b639 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 @@ -32,9 +32,6 @@ const IkonotvPieceContainer = React.createClass({ propTypes: { router: React.PropTypes.object.isRequired, - // Provided from WalletApp - whitelabel: React.PropTypes.object, - // 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 8b12d9ad..f7f99041 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_landing.js @@ -16,9 +16,6 @@ let IkonotvLanding = React.createClass({ // Injected through HOCs isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types - // Provided from WalletApp - whitelabel: React.PropTypes.object, - // Provided from router location: React.PropTypes.object }, 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 4ff2cfce..1b54ccad 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js @@ -8,20 +8,20 @@ import NotificationStore from '../../../../../stores/notification_store'; import IkonotvAccordionListItem from './ikonotv_accordion_list/ikonotv_accordion_list_item'; -import { currentUserShape } from '../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getLangText } from '../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils'; let IkonotvPieceList = React.createClass({ propTypes: { // Injected through HOCs - currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types + currentUser: currentUserShape.isRequired, + whitelabel: whitelabelShape.isRequired, // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, // Provided from router location: React.PropTypes.object @@ -91,4 +91,4 @@ let IkonotvPieceList = React.createClass({ } }); -export default withCurrentUser(IkonotvPieceList); +export default withCurrentUser(withWhitelabel(IkonotvPieceList)); 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 f18255cb..15ba35ab 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js @@ -22,13 +22,13 @@ import LoanForm from '../../../../ascribe_forms/form_loan'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; -import { currentUserShape } from '../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import ApiUrls from '../../../../../constants/api_urls'; import { mergeOptions } from '../../../../../utils/general_utils'; import { getLangText } from '../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils'; const IkonotvRegisterPiece = React.createClass({ @@ -39,9 +39,7 @@ const IkonotvRegisterPiece = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router location: React.PropTypes.object @@ -248,4 +246,4 @@ const IkonotvRegisterPiece = React.createClass({ } }); -export default withRouter(withCurrentUser(IkonotvRegisterPiece)); +export default withRouter(withCurrentUser(withWhitelabel(IkonotvRegisterPiece))); diff --git a/js/components/whitelabel/wallet/components/lumenus/lumenus_landing.js b/js/components/whitelabel/wallet/components/lumenus/lumenus_landing.js index 7888d0ad..48024ce4 100644 --- a/js/components/whitelabel/wallet/components/lumenus/lumenus_landing.js +++ b/js/components/whitelabel/wallet/components/lumenus/lumenus_landing.js @@ -5,17 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; -import { getLangText } from '../../../../../utils/lang_utils'; +import { whitelabelShape } from '../../../../prop_types'; + import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let LumenusLanding = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, - - // Provided from router - location: React.PropTypes.object + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, }, componentWillMount() { @@ -65,4 +65,4 @@ let LumenusLanding = React.createClass({ } }); -export default LumenusLanding; +export default withWhitelabel(LumenusLanding); diff --git a/js/components/whitelabel/wallet/components/market/market_buttons/market_acl_button_list.js b/js/components/whitelabel/wallet/components/market/market_buttons/market_acl_button_list.js index 9bbc0834..b1b6365c 100644 --- a/js/components/whitelabel/wallet/components/market/market_buttons/market_acl_button_list.js +++ b/js/components/whitelabel/wallet/components/market/market_buttons/market_acl_button_list.js @@ -16,7 +16,6 @@ let MarketAclButtonList = React.createClass({ availableAcls: React.PropTypes.object.isRequired, handleSuccess: React.PropTypes.func.isRequired, pieceOrEditions: React.PropTypes.array.isRequired, - whitelabel: React.PropTypes.object.isRequired, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), @@ -26,12 +25,13 @@ let MarketAclButtonList = React.createClass({ }, render() { - const { availableAcls, - children, - className, - handleSuccess, - pieceOrEditions, - whitelabel } = this.props; + const { + availableAcls, + children, + className, + handleSuccess, + pieceOrEditions + } = this.props; const buttonProps = selectFromObject(this.props, [ 'availableAcls', @@ -44,8 +44,7 @@ let MarketAclButtonList = React.createClass({ + handleSuccess={handleSuccess} /> diff --git a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js index 7d4d77e6..a7ff297d 100644 --- a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js +++ b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js @@ -14,23 +14,23 @@ import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory'; import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper'; import AclProxy from '../../../../../acl_proxy'; -import { currentUserShape } from '../../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../../prop_types'; import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils'; import { getLangText } from '../../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../../utils/react_utils'; +import { withCurrentUser, withWhitelabel } from '../../../../../../utils/react_utils'; let MarketSubmitButton = React.createClass({ propTypes: { availableAcls: React.PropTypes.object.isRequired, editions: React.PropTypes.array.isRequired, - whitelabel: React.PropTypes.object.isRequired, className: React.PropTypes.string, handleSuccess: React.PropTypes.func, // Injected through HOCs - currentUser: currentUserShape.isRequired // eslint-disable-line react/sort-prop-types + currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types + whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types }, canEditionBeSubmitted(edition) { @@ -82,12 +82,14 @@ let MarketSubmitButton = React.createClass({ }, render() { - const { availableAcls, - currentUser, - className, - editions, - handleSuccess, - whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.props; + const { + availableAcls, + currentUser, + className, + editions, + handleSuccess, + whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } + } = this.props; const { solePieceId, canEdit, canSubmit } = this.getAggregateEditionDetails(); const message = getAclFormMessage({ @@ -185,4 +187,4 @@ let MarketSubmitButton = React.createClass({ } }); -export default withCurrentUser(MarketSubmitButton); +export default withCurrentUser(withWhitelabel(MarketSubmitButton)); diff --git a/js/components/whitelabel/wallet/components/market/market_landing.js b/js/components/whitelabel/wallet/components/market/market_landing.js index 15ef4621..026ddec5 100644 --- a/js/components/whitelabel/wallet/components/market/market_landing.js +++ b/js/components/whitelabel/wallet/components/market/market_landing.js @@ -5,17 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; -import WhitelabelActions from '../../../../../actions/whitelabel_actions'; -import WhitelabelStore from '../../../../../stores/whitelabel_store'; +import { whitelabelShape } from '../../../../prop_types'; -import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let MarketLanding = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, }, componentDidUpdate() { @@ -69,4 +69,4 @@ let MarketLanding = React.createClass({ } }); -export default MarketLanding; +export default withWhitelabel(MarketLanding); 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 c0b1d843..5790d083 100644 --- a/js/components/whitelabel/wallet/components/market/market_piece_list.js +++ b/js/components/whitelabel/wallet/components/market/market_piece_list.js @@ -5,11 +5,11 @@ import React from 'react'; import MarketAclButtonList from './market_buttons/market_acl_button_list'; import PieceList from '../../../../piece_list'; -import { currentUserShape } from '../../../../prop_types'; +import { currentUserShape, whitelabelShape } from '../../../../prop_types'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { getLangText } from '../../../../../utils/lang_utils'; -import { withCurrentUser } from '../../../../../utils/react_utils'; +import { withCurrentUser, withWhiteLabel } from '../../../../../utils/react_utils'; let MarketPieceList = React.createClass({ propTypes: { @@ -17,9 +17,7 @@ let MarketPieceList = React.createClass({ // Injected through HOCs currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types - - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + whitelabel: whitelabelShape.isRequired, // eslint-disable-line react/sort-prop-types // Provided from router location: React.PropTypes.object @@ -73,4 +71,4 @@ let MarketPieceList = React.createClass({ } }); -export default withCurrentUser(MarketPieceList); +export default withCurrentUser(withWhitelabel(MarketPieceList)); 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 b10ad699..a943226d 100644 --- a/js/components/whitelabel/wallet/components/market/market_register_piece.js +++ b/js/components/whitelabel/wallet/components/market/market_register_piece.js @@ -17,16 +17,19 @@ import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece'; import SlidesContainer from '../../../../ascribe_slides_container/slides_container'; -import { getLangText } from '../../../../../utils/lang_utils'; +import { whitelabelShape } from '../../../../prop_types'; + import { setDocumentTitle } from '../../../../../utils/dom_utils'; import { mergeOptions } from '../../../../../utils/general_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let MarketRegisterPiece = React.createClass({ propTypes: { router: React.PropTypes.object.isRequired, - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired, + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, // Provided from router location: React.PropTypes.object @@ -98,10 +101,12 @@ let MarketRegisterPiece = React.createClass({ }, render() { - const { location, - whitelabel: { - name: whitelabelName = 'Market' - } } = this.props + const { + location, + whitelabel: { + name: whitelabelName = 'Market' + } + } = this.props const { piece, step } = this.state; setDocumentTitle(getLangText('Register a new piece')); @@ -157,4 +162,4 @@ let MarketRegisterPiece = React.createClass({ } }); -export default withRouter(MarketRegisterPiece); +export default withRouter(withWhitelabel(MarketRegisterPiece)); diff --git a/js/components/whitelabel/wallet/components/polline/polline_landing.js b/js/components/whitelabel/wallet/components/polline/polline_landing.js index 2fa9134e..085975d0 100644 --- a/js/components/whitelabel/wallet/components/polline/polline_landing.js +++ b/js/components/whitelabel/wallet/components/polline/polline_landing.js @@ -5,17 +5,17 @@ import React from 'react'; import Button from 'react-bootstrap/lib/Button'; import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; -import WhitelabelActions from '../../../../../actions/whitelabel_actions'; -import WhitelabelStore from '../../../../../stores/whitelabel_store'; +import { whitelabelShape } from '../../../../prop_types'; -import { getLangText } from '../../../../../utils/lang_utils'; import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { getLangText } from '../../../../../utils/lang_utils'; +import { withWhitelabel } from '../../../../../utils/react_utils'; let PollineLanding = React.createClass({ propTypes: { - // Provided from WalletApp - whitelabel: React.PropTypes.object.isRequired + // Injected through HOCs + whitelabel: whitelabelShape.isRequired, }, componentWillMount() { @@ -63,4 +63,4 @@ let PollineLanding = React.createClass({ } }); -export default PollineLanding; +export default withWhitelabel(PollineLanding); diff --git a/js/components/whitelabel/wallet/wallet_app.js b/js/components/whitelabel/wallet/wallet_app.js index 1064b5ba..0bbfd38d 100644 --- a/js/components/whitelabel/wallet/wallet_app.js +++ b/js/components/whitelabel/wallet/wallet_app.js @@ -15,13 +15,10 @@ let WalletApp = React.createClass({ children: React.PropTypes.element.isRequired, router: React.PropTypes.object.isRequired, routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - - // Provided from AppBase - whitelabel: React.PropTypes.object }, render() { - const { activeRoute, children, router, routes, whitelabel } = this.props; + const { activeRoute, children, router, routes } = this.props; const subdomain = getSubdomain(); const path = activeRoute && activeRoute.path; const Footer = activeRoute && activeRoute.footer; @@ -33,9 +30,7 @@ let WalletApp = React.createClass({ header = (
); } else { header = ( -
+
); } @@ -44,8 +39,7 @@ let WalletApp = React.createClass({ return (
{header} - + {/* Routes are injected here */} {children} diff --git a/js/utils/react_utils.js b/js/utils/react_utils.js index 38a0d78a..da176149 100644 --- a/js/utils/react_utils.js +++ b/js/utils/react_utils.js @@ -1,5 +1,5 @@ import React from 'react'; -import { currentUserShape } from '../components/prop_types'; +import { currentUserShape, whitelabelShape } from '../components/prop_types'; /** @@ -32,3 +32,25 @@ export function withCurrentUser(Component) { return WithCurrentUser; } + +/** + * Similar to react-router's `withRouter`, this injects the `whitelabel` from the Component's + * context into the Component as a prop. + * + * @param {Component} Component Component to inject `context.whitelabel` into + * @return {Component} Wrapped component + */ +export function withWhitelabel(Component) { + const contextTypes = { + whitelabel: whitelabelShape.isRequired + }; + + const WithWhitelabel = (props, { whitelabel }) => ( + + ); + + WithWhitelabel.displayName = `WithWhitelabel(${getDisplayName(Component)})`; + WithWhitelabel.contextTypes = contextTypes; + + return WithWhitelabel; +}