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

Convert whitelabel to be passed down through context and withWhitelabel HOC

This commit is contained in:
Brett Sun 2016-06-07 14:53:48 +02:00
parent b5eda1cdd2
commit b02695a33a
42 changed files with 217 additions and 229 deletions

View File

@ -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) {
<div>
<App
{...this.props}
activeRoute={activeRoute}
whitelabel={whitelabel} />
activeRoute={activeRoute} />
<GlobalNotification />
<div id="modal" className="container" />
</div>

View File

@ -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);

View File

@ -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 (
<div className="ascribe-app ascribe-default-app">
<Header
routes={routes}
whitelabel={whitelabel} />
<AppRouteWrapper
whitelabel={whitelabel}>
<Header routes={routes} />
<AppRouteWrapper>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>

View File

@ -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({
<EditionSummary
actionPanelButtonListType={actionPanelButtonListType}
edition={edition}
handleSuccess={loadEdition}
whitelabel={whitelabel} />
handleSuccess={loadEdition} />
<CollapsibleParagraph
title={getLangText('Certificate of Authenticity')}
show={edition.acl.acl_coa === true}>
@ -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({
<EditionActionPanel
actionPanelButtonListType={actionPanelButtonListType}
edition={edition}
handleSuccess={handleSuccess}
whitelabel={whitelabel} />
handleSuccess={handleSuccess} />
</DetailProperty>
</AclProxy>
<hr/>

View File

@ -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]} >
<AclProxy
aclObject={edition.acl}
aclName="acl_withdraw_transfer">

View File

@ -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 (

View File

@ -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

View File

@ -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));

View File

@ -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));

View File

@ -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 (
<div className="settings-container">
<AccountSettings
loadUser={this.loadUser}
whitelabel={whitelabel} />
<AccountSettings loadUser={this.loadUser} />
{children}
<AclProxy
aclObject={whitelabel}
@ -67,4 +64,4 @@ let SettingsContainer = React.createClass({
}
});
export default withCurrentUser(SettingsContainer);
export default withCurrentUser(withWhitelabel(SettingsContainer));

View File

@ -18,9 +18,6 @@ import { setDocumentTitle } from '../utils/dom_utils';
let CoaVerifyContainer = React.createClass({
propTypes: {
// Provided from AscribeApp
whitelabel: React.PropTypes.object,
// Provided from router
location: React.PropTypes.object
},

View File

@ -17,21 +17,21 @@ import AclProxy from './acl_proxy';
import HeaderNotifications from './header_notifications';
import HeaderNotificationDebug from './header_notification_debug';
import NavRoutesLinks from './nav_routes_links';
import { currentUserShape } from './prop_types';
import { currentUserShape, whitelabelShape } from './prop_types';
import { constructHead } from '../utils/dom_utils';
import { getLangText } from '../utils/lang_utils';
import { withCurrentUser } from '../utils/react_utils';
import { withCurrentUser, withWhitelabel } from '../utils/react_utils';
let Header = React.createClass({
propTypes: {
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
whitelabel: React.PropTypes.object.isRequired,
// Injected through HOCs
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types
},
getInitialState() {
@ -219,4 +219,4 @@ let Header = React.createClass({
}
});
export default withCurrentUser(Header);
export default withCurrentUser(withWhitelabel(Header));

View File

@ -5,22 +5,27 @@ import Link from 'react-router/es6/Link';
import LoginForm from './ascribe_forms/form_login';
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 LoginContainer = 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
},
render() {
const { whitelabel: { name: whitelabelName },
location } = this.props;
const {
whitelabel: { name: whitelabelName },
location
} = this.props;
setDocumentTitle(getLangText('Log in'));
@ -38,6 +43,4 @@ let LoginContainer = React.createClass({
}
});
export default LoginContainer;
export default withWhitelabel(LoginContainer);

View File

@ -16,9 +16,6 @@ import { setDocumentTitle } from '../utils/dom_utils';
let PasswordResetContainer = React.createClass({
propTypes: {
// Provided from AscribeApp
whitelabel: React.PropTypes.object,
// Provided from router
location: React.PropTypes.object
},

View File

@ -47,9 +47,6 @@ const PieceList = React.createClass({
orderParams: React.PropTypes.array,
orderBy: React.PropTypes.string,
// Provided from AscribeApp
whitelabel: React.PropTypes.object.isRequired,
// Provided from router
location: React.PropTypes.object
},
@ -274,13 +271,14 @@ const PieceList = React.createClass({
},
render() {
const { accordionListItemType: AccordionListItemType,
bulkModalButtonListType: BulkModalButtonListType,
customSubmitButton,
customThumbnailPlaceholder,
filterParams,
orderParams,
whitelabel } = this.props;
const {
customSubmitButton,
customThumbnailPlaceholder,
filterParams,
orderParams,
accordionListItemType: AccordionListItemType,
bulkModalButtonListType: BulkModalButtonListType
} = this.props;
const loadingElement = <AscribeSpinner color='dark-blue' size='lg'/>;
@ -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">
<DeleteButton
handleSuccess={this.handleAclSuccess}
@ -339,8 +336,7 @@ const PieceList = React.createClass({
key={piece.id}
className="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2 ascribe-accordion-list-item"
content={piece}
thumbnailPlaceholder={customThumbnailPlaceholder}
whitelabel={whitelabel}>
thumbnailPlaceholder={customThumbnailPlaceholder}>
<AccordionListItemTableEditions
className="ascribe-accordion-list-item-table col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2"
parentId={piece.id} />

View File

@ -1 +1,2 @@
export { default as currentUserShape } from './current_user_shape';
export { default as whitelabelShape } from './whitelabel_shape';

View File

@ -0,0 +1,11 @@
import React from 'react';
const { shape, string } = React.PropTypes;
export default shape({
name: string,
subdomain: string,
title: string,
user: string
});

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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
},

View File

@ -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);

View File

@ -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
},

View File

@ -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

View File

@ -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);

View File

@ -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));

View File

@ -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)));

View File

@ -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);

View File

@ -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)));

View File

@ -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

View File

@ -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
},

View File

@ -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));

View File

@ -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)));

View File

@ -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);

View File

@ -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({
<MarketSubmitButton
availableAcls={availableAcls}
editions={pieceOrEditions}
handleSuccess={handleSuccess}
whitelabel={whitelabel} />
handleSuccess={handleSuccess} />
<EmailButton {...buttonProps} />
<TransferButton {...buttonProps} />
<UnconsignButton {...buttonProps} />

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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 = (<div className="hero"/>);
} else {
header = (
<Header
routes={routes}
whitelabel={whitelabel} />
<Header routes={routes} />
);
}
@ -44,8 +39,7 @@ let WalletApp = React.createClass({
return (
<div className={classNames('ascribe-app', 'ascribe-wallet-app', `route--${(path ? path.split('/')[0] : 'landing')}`)}>
{header}
<AppRouteWrapper
whitelabel={whitelabel}>
<AppRouteWrapper>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>

View File

@ -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 }) => (
<Component {...props} whitelabel={whitelabel} />
);
WithWhitelabel.displayName = `WithWhitelabel(${getDisplayName(Component)})`;
WithWhitelabel.contextTypes = contextTypes;
return WithWhitelabel;
}