mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Convert withCurrentUser and withWhitelabel to withContext
This commit is contained in:
parent
75247b2594
commit
5073b0988d
@ -20,11 +20,11 @@ import AccordionListItemEditionWidget from './accordion_list_item_edition_widget
|
|||||||
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { whitelabelShape } from '../prop_types';
|
import { whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
import { mergeOptions } from '../../utils/general_utils';
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let AccordionListItemWallet = React.createClass({
|
let AccordionListItemWallet = React.createClass({
|
||||||
@ -165,4 +165,4 @@ let AccordionListItemWallet = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(AccordionListItemWallet);
|
export default withContext(AccordionListItemWallet, 'whitelabel');
|
||||||
|
@ -7,10 +7,10 @@ import Button from 'react-bootstrap/lib/Button';
|
|||||||
import ModalWrapper from '../ascribe_modal/modal_wrapper';
|
import ModalWrapper from '../ascribe_modal/modal_wrapper';
|
||||||
import UnConsignRequestForm from '../ascribe_forms/form_unconsign_request';
|
import UnConsignRequestForm from '../ascribe_forms/form_unconsign_request';
|
||||||
|
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape } from '../prop_types';
|
import { currentUserShape } from '../prop_types';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
|
||||||
@ -50,4 +50,4 @@ ${currentUser.username}`
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(UnConsignRequestButton);
|
export default withContext(UnConsignRequestButton, 'currentUser');
|
||||||
|
@ -22,12 +22,12 @@ import Form from '../ascribe_forms/form';
|
|||||||
import Property from '../ascribe_forms/property';
|
import Property from '../ascribe_forms/property';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +151,7 @@ const Edition = React.createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let EditionSummary = withCurrentUser(React.createClass({
|
let EditionSummary = withContext(React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
edition: React.PropTypes.object.isRequired,
|
edition: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ let EditionSummary = withCurrentUser(React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}));
|
}), 'isLoggedIn');
|
||||||
|
|
||||||
|
|
||||||
let CoaDetails = React.createClass({
|
let CoaDetails = React.createClass({
|
||||||
@ -359,4 +359,4 @@ let SpoolDetails = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(Edition);
|
export default withContext(Edition, 'isLoggedIn');
|
||||||
|
@ -17,14 +17,13 @@ import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
|
|||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape } from '../prop_types';
|
import { currentUserShape } from '../prop_types';
|
||||||
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
import { extractFileExtensionFromUrl } from '../../utils/file_utils';
|
import { extractFileExtensionFromUrl } from '../../utils/file_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const EMBED_IFRAME_HEIGHT = {
|
const EMBED_IFRAME_HEIGHT = {
|
||||||
@ -184,4 +183,4 @@ let MediaContainer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(MediaContainer);
|
export default withContext(MediaContainer, 'currentUser');
|
||||||
|
@ -9,8 +9,9 @@ import Form from '../ascribe_forms/form';
|
|||||||
import Property from '../ascribe_forms/property';
|
import Property from '../ascribe_forms/property';
|
||||||
import InputTextAreaToggable from '../ascribe_forms/input_textarea_toggable';
|
import InputTextAreaToggable from '../ascribe_forms/input_textarea_toggable';
|
||||||
|
|
||||||
|
import withContext from '../context/with_context';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
let Note = React.createClass({
|
let Note = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -78,4 +79,4 @@ let Note = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(Note);
|
export default withContext(Note, 'isLoggedIn');
|
||||||
|
@ -37,13 +37,13 @@ import ListRequestActions from '../ascribe_forms/list_form_request_actions';
|
|||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../utils/dom_utils';
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
import { mergeOptions } from '../../utils/general_utils';
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the component that implements resource/data specific functionality
|
* This is the component that implements resource/data specific functionality
|
||||||
@ -341,4 +341,4 @@ const PieceContainer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(withCurrentUser(PieceContainer));
|
export default withRouter(withContext(PieceContainer, 'isLoggedIn'));
|
||||||
|
@ -12,13 +12,13 @@ import LoanForm from '../ascribe_forms/form_loan';
|
|||||||
import LoanRequestAnswerForm from '../ascribe_forms/form_loan_request_answer';
|
import LoanRequestAnswerForm from '../ascribe_forms/form_loan_request_answer';
|
||||||
import ShareForm from '../ascribe_forms/form_share_email';
|
import ShareForm from '../ascribe_forms/form_share_email';
|
||||||
|
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape } from '../prop_types';
|
import { currentUserShape } from '../prop_types';
|
||||||
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils';
|
import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
let AclFormFactory = React.createClass({
|
let AclFormFactory = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -138,4 +138,4 @@ let AclFormFactory = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(AclFormFactory);
|
export default withContext(AclFormFactory, 'currentUser');
|
||||||
|
@ -8,13 +8,13 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
|
|||||||
import Form from './form';
|
import Form from './form';
|
||||||
import Property from './property';
|
import Property from './property';
|
||||||
|
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape } from '../prop_types';
|
import { currentUserShape } from '../prop_types';
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const { bool } = React.PropTypes;
|
const { bool } = React.PropTypes;
|
||||||
@ -85,4 +85,4 @@ const CopyrightAssociationForm = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(CopyrightAssociationForm);
|
export default withContext(CopyrightAssociationForm, 'currentUser', 'isLoggedIn');
|
||||||
|
@ -11,6 +11,7 @@ import FormSubmitButton from '../ascribe_buttons/form_submit_button';
|
|||||||
import UploadButton from '../ascribe_uploader/ascribe_upload_button/upload_button';
|
import UploadButton from '../ascribe_uploader/ascribe_upload_button/upload_button';
|
||||||
|
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape } from '../prop_types';
|
import { currentUserShape } from '../prop_types';
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
@ -19,7 +20,6 @@ import { validationParts, validationTypes } from '../../constants/uploader_const
|
|||||||
|
|
||||||
import { FileStatus, formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
import { FileStatus, formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let RegisterPieceForm = React.createClass({
|
let RegisterPieceForm = React.createClass({
|
||||||
@ -240,4 +240,4 @@ let RegisterPieceForm = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(RegisterPieceForm);
|
export default withContext(RegisterPieceForm, 'currentUser');
|
||||||
|
@ -5,12 +5,11 @@ import withRouter from 'react-router/es6/withRouter';
|
|||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
|
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../prop_types';
|
import { currentUserShape, whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
import { withCurrentUser, withWhitelabel } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const { bool, object } = React.PropTypes;
|
const { bool, object } = React.PropTypes;
|
||||||
const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
||||||
@ -135,6 +134,6 @@ export function ProxyHandler(...redirectFunctions) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return withRouter(withCurrentUser(withWhitelabel(ProxyHandlerComponent)));
|
return withRouter(withContext(ProxyHandlerComponent, 'currentUser', 'isLoggedIn', 'whitelabel'));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph';
|
|||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../prop_types';
|
import { currentUserShape, whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
let AccountSettings = React.createClass({
|
let AccountSettings = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -112,4 +112,4 @@ let AccountSettings = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(AccountSettings));
|
export default withContext(AccountSettings, 'currentUser', 'whitelabel');
|
||||||
|
@ -16,12 +16,12 @@ import CreateContractForm from '../ascribe_forms/form_create_contract';
|
|||||||
import ActionPanel from '../ascribe_panel/action_panel';
|
import ActionPanel from '../ascribe_panel/action_panel';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../prop_types';
|
import { currentUserShape, whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../utils/dom_utils';
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
import { truncateTextAtCharIndex } from '../../utils/general_utils';
|
import { truncateTextAtCharIndex } from '../../utils/general_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let ContractSettings = React.createClass({
|
let ContractSettings = React.createClass({
|
||||||
@ -183,4 +183,4 @@ let ContractSettings = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(ContractSettings));
|
export default withContext(ContractSettings, 'currentUser', 'whitelabel');
|
||||||
|
@ -10,11 +10,11 @@ import BitcoinWalletSettings from './bitcoin_wallet_settings';
|
|||||||
import WebhookSettings from './webhook_settings';
|
import WebhookSettings from './webhook_settings';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
import withContext from '../context/with_context';
|
||||||
import { whitelabelShape } from '../prop_types';
|
import { whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../utils/dom_utils';
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let SettingsContainer = React.createClass({
|
let SettingsContainer = React.createClass({
|
||||||
@ -64,4 +64,4 @@ let SettingsContainer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(SettingsContainer));
|
export default withContext(SettingsContainer, 'isLoggedIn', 'whitelabel');
|
||||||
|
137
js/components/context/with_context.js
Normal file
137
js/components/context/with_context.js
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { currentUserShape, whitelabelShape } from '../prop_types';
|
||||||
|
|
||||||
|
import { selectFromObject } from '../../utils/general_utils';
|
||||||
|
import { getDisplayName } from '../../utils/react_utils';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContextPropDefinitions
|
||||||
|
* ======================
|
||||||
|
* contextType definitions for `contextProp`s.
|
||||||
|
*
|
||||||
|
* Each definition is of the form:
|
||||||
|
*
|
||||||
|
* contextProp = {
|
||||||
|
* 'contextTypes': {
|
||||||
|
* 'contextType': contextType used by the contextProp,
|
||||||
|
* ...
|
||||||
|
* },
|
||||||
|
* transformToProps: (optional) function that will receive the contextTypes from the component's
|
||||||
|
* context and should return an object containing the props to inject.
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* In the common case where your `contextProp` maps directly to the `contextType` used
|
||||||
|
* (eg. using `currentUser` as a `contextProp` to get the `currentUser` from context), you can omit
|
||||||
|
* the object definition and simply assign the `contextType` to the `contextProp`:
|
||||||
|
*
|
||||||
|
* contextProp = contextType
|
||||||
|
*
|
||||||
|
* as opposed to:
|
||||||
|
*
|
||||||
|
* contextProp = {
|
||||||
|
* 'contextTypes': {
|
||||||
|
* contextProp: contextType
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
const ContextPropDefinitions = {
|
||||||
|
currentUser: currentUserShape.isRequired,
|
||||||
|
isLoggedIn: {
|
||||||
|
contextTypes: {
|
||||||
|
currentUser: currentUserShape.isRequired
|
||||||
|
},
|
||||||
|
transformToProps: ({ currentUser }) => ({ isLoggedIn: !!currentUser.email })
|
||||||
|
},
|
||||||
|
whitelabel: whitelabelShape.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expand any shortform definitions in ContextPropDefinitions into a normalized form that's
|
||||||
|
// easier for withContext to work with
|
||||||
|
Object.entries(ContextPropDefinitions).forEach(([prop, def]) => {
|
||||||
|
if (!def.hasOwnProperty('contextTypes')) {
|
||||||
|
ContextPropDefinitions[prop] = {
|
||||||
|
contextTypes: {
|
||||||
|
[prop]: def
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generalized version of react-router's `withRouter`.
|
||||||
|
* This injects the given `contextProp`s from the WrappedComponent's context into the component as
|
||||||
|
* a prop.
|
||||||
|
*
|
||||||
|
* Given `contextProp`s must have a matching definition in `ContextPropDefinitions`.
|
||||||
|
*
|
||||||
|
* @param {Component} WrappedComponent Component to inject context into
|
||||||
|
* @param {...string} contextProps Argument list of `contextProp`s (that must be registered in
|
||||||
|
* `ContextPropDefinitions`) to be injected into component as
|
||||||
|
* props
|
||||||
|
* @return {Component} Wrapped component
|
||||||
|
*/
|
||||||
|
export default function withContext(WrappedComponent, ...contextProps) {
|
||||||
|
const wrappedComponentName = getDisplayName(WrappedComponent);
|
||||||
|
|
||||||
|
if (!contextProps.length) {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Used withContext on ${wrappedComponentName} without supplying any ` +
|
||||||
|
"items to inject from the component's context. Ignoring...");
|
||||||
|
}
|
||||||
|
|
||||||
|
return WrappedComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextTypes = contextProps.reduce((types, contextProp) => {
|
||||||
|
const contextDef = ContextPropDefinitions[contextProp];
|
||||||
|
|
||||||
|
if (contextDef) {
|
||||||
|
Object.assign(types, contextDef.contextTypes);
|
||||||
|
} else if (process.env.NODE_ENV !== 'production') {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`No context types were found for '${contextProp}' when adding context ` +
|
||||||
|
`to ${wrappedComponentName}. Make sure to add the context information ` +
|
||||||
|
'with_context.js.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const WithContext = (props, context) => {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
// Check if the expected context was available
|
||||||
|
Object.keys(contextTypes).forEach((contextType) => {
|
||||||
|
if (!context[contextType]) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Expected '${contextType}' did not exist in ` +
|
||||||
|
`${wrappedComponentName}'s context during mounting`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const injectedProps = Object.assign({}, ...contextProps.map((contextProp) => {
|
||||||
|
const contextDef = ContextPropDefinitions[contextProp];
|
||||||
|
|
||||||
|
if (contextDef) {
|
||||||
|
const contextForProp = selectFromObject(context, Object.keys(contextDef.contextTypes));
|
||||||
|
return typeof contextDef.transformToProps === 'function'
|
||||||
|
? contextDef.transformToProps(contextForProp)
|
||||||
|
: contextForProp;
|
||||||
|
} else {
|
||||||
|
// Will be ignored by Object.assign()
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WrappedComponent {...props} {...injectedProps} />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
WithContext.displayName = `WithContext(${wrappedComponentName}): ${contextProps.join(', ')}`;
|
||||||
|
WithContext.contextTypes = contextTypes;
|
||||||
|
|
||||||
|
return WithContext;
|
||||||
|
}
|
@ -14,6 +14,7 @@ import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
|||||||
import PieceListStore from '../stores/piece_list_store';
|
import PieceListStore from '../stores/piece_list_store';
|
||||||
|
|
||||||
import AclProxy from './acl_proxy';
|
import AclProxy from './acl_proxy';
|
||||||
|
import withContext from './context/with_context';
|
||||||
import HeaderNotifications from './header_notifications';
|
import HeaderNotifications from './header_notifications';
|
||||||
import HeaderNotificationDebug from './header_notification_debug';
|
import HeaderNotificationDebug from './header_notification_debug';
|
||||||
import NavRoutesLinks from './nav_routes_links';
|
import NavRoutesLinks from './nav_routes_links';
|
||||||
@ -21,7 +22,6 @@ import { currentUserShape, whitelabelShape } from './prop_types';
|
|||||||
|
|
||||||
import { constructHead } from '../utils/dom_utils';
|
import { constructHead } from '../utils/dom_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let Header = React.createClass({
|
let Header = React.createClass({
|
||||||
@ -219,4 +219,4 @@ let Header = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(Header));
|
export default withContext(Header, 'currentUser', 'isLoggedIn', 'whitelabel');
|
||||||
|
@ -10,10 +10,10 @@ import Nav from 'react-bootstrap/lib/Nav';
|
|||||||
import NotificationActions from '../actions/notification_actions';
|
import NotificationActions from '../actions/notification_actions';
|
||||||
import NotificationStore from '../stores/notification_store';
|
import NotificationStore from '../stores/notification_store';
|
||||||
|
|
||||||
|
import withContext from './context/with_context';
|
||||||
import { currentUserShape } from './prop_types';
|
import { currentUserShape } from './prop_types';
|
||||||
|
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let HeaderNotifications = React.createClass({
|
let HeaderNotifications = React.createClass({
|
||||||
@ -158,4 +158,4 @@ let NotificationListItem = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(HeaderNotifications);
|
export default withContext(HeaderNotifications, 'currentUser', 'isLoggedIn');
|
||||||
|
@ -5,11 +5,11 @@ import Link from 'react-router/es6/Link';
|
|||||||
|
|
||||||
import LoginForm from './ascribe_forms/form_login';
|
import LoginForm from './ascribe_forms/form_login';
|
||||||
|
|
||||||
|
import withContext from './context/with_context';
|
||||||
import { whitelabelShape } from './prop_types';
|
import { whitelabelShape } from './prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../utils/dom_utils';
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let LoginContainer = React.createClass({
|
let LoginContainer = React.createClass({
|
||||||
@ -43,4 +43,4 @@ let LoginContainer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(LoginContainer);
|
export default withContext(LoginContainer, 'whitelabel');
|
||||||
|
@ -13,7 +13,9 @@ import GlobalNotificationActions from '../actions/global_notification_actions';
|
|||||||
import Property from './ascribe_forms/property';
|
import Property from './ascribe_forms/property';
|
||||||
import RegisterPieceForm from './ascribe_forms/form_register_piece';
|
import RegisterPieceForm from './ascribe_forms/form_register_piece';
|
||||||
|
|
||||||
|
import withContext from './context/with_context';
|
||||||
import { whitelabelShape } from './prop_types';
|
import { whitelabelShape } from './prop_types';
|
||||||
|
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
import { setDocumentTitle } from '../utils/dom_utils';
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
@ -105,5 +107,4 @@ const RegisterPiece = React.createClass( {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default withRouter(withContext(RegisterPiece, 'whitelabel'));
|
||||||
export default withRouter(RegisterPiece);
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
// FIXME: Input is deprecated
|
||||||
import Input from 'react-bootstrap/lib/Input';
|
import Input from 'react-bootstrap/lib/Input';
|
||||||
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ import Link from 'react-router/es6/Link';
|
|||||||
|
|
||||||
import SignupForm from './ascribe_forms/form_signup';
|
import SignupForm from './ascribe_forms/form_signup';
|
||||||
|
|
||||||
|
import withContext from './context/with_context';
|
||||||
import { whitelabelShape } from './prop_types';
|
import { whitelabelShape } from './prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../utils/dom_utils';
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let SignupContainer = React.createClass({
|
let SignupContainer = React.createClass({
|
||||||
@ -68,4 +68,4 @@ let SignupContainer = React.createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default withWhitelabel(SignupContainer);
|
export default withContext(SignupContainer, 'whitelabel');
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let Vivi23Landing = React.createClass({
|
let Vivi23Landing = React.createClass({
|
||||||
@ -69,4 +69,4 @@ let Vivi23Landing = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(Vivi23Landing);
|
export default withContext(Vivi23Landing, 'whitelabel');
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let ArtcityLanding = React.createClass({
|
let ArtcityLanding = React.createClass({
|
||||||
@ -63,4 +63,4 @@ let ArtcityLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(ArtcityLanding);
|
export default withContext(ArtcityLanding, 'whitelabel');
|
||||||
|
@ -7,10 +7,10 @@ import AclButtonList from '../../../../ascribe_buttons/acl_button_list';
|
|||||||
import DeleteButton from '../../../../ascribe_buttons/delete_button';
|
import DeleteButton from '../../../../ascribe_buttons/delete_button';
|
||||||
|
|
||||||
import AclProxy from '../../../../acl_proxy';
|
import AclProxy from '../../../../acl_proxy';
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape } from '../../../../prop_types';
|
import { currentUserShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { withCurrentUser } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let WalletActionPanel = React.createClass({
|
let WalletActionPanel = React.createClass({
|
||||||
@ -71,4 +71,4 @@ let WalletActionPanel = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(WalletActionPanel);
|
export default withContext(WalletActionPanel, 'currentUser');
|
||||||
|
@ -13,11 +13,11 @@ import Note from '../../../../ascribe_detail/note';
|
|||||||
import Piece from '../../../../../components/ascribe_detail/piece';
|
import Piece from '../../../../../components/ascribe_detail/piece';
|
||||||
|
|
||||||
import AscribeSpinner from '../../../../ascribe_spinner';
|
import AscribeSpinner from '../../../../ascribe_spinner';
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
|
|
||||||
import ApiUrls from '../../../../../constants/api_urls';
|
import ApiUrls from '../../../../../constants/api_urls';
|
||||||
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let WalletPieceContainer = React.createClass({
|
let WalletPieceContainer = React.createClass({
|
||||||
@ -101,4 +101,4 @@ let WalletPieceContainer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(WalletPieceContainer);
|
export default withContext(WalletPieceContainer, 'isLoggedIn');
|
||||||
|
@ -6,11 +6,11 @@ import Button from 'react-bootstrap/lib/Button';
|
|||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let CylandLanding = React.createClass({
|
let CylandLanding = React.createClass({
|
||||||
@ -64,4 +64,4 @@ let CylandLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(CylandLanding);
|
export default withContext(CylandLanding, 'whitelabel');
|
||||||
|
@ -5,11 +5,11 @@ import PieceList from '../../../../piece_list';
|
|||||||
|
|
||||||
import CylandAccordionListItem from './cyland_accordion_list/cyland_accordion_list_item';
|
import CylandAccordionListItem from './cyland_accordion_list/cyland_accordion_list_item';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
let CylandPieceList = React.createClass({
|
let CylandPieceList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -57,4 +57,4 @@ let CylandPieceList = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(CylandPieceList));
|
export default withContext(CylandPieceList, 'currentUser', 'whitelabel');
|
||||||
|
@ -24,6 +24,7 @@ import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece';
|
|||||||
|
|
||||||
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import ApiUrls from '../../../../../constants/api_urls';
|
import ApiUrls from '../../../../../constants/api_urls';
|
||||||
@ -32,7 +33,6 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
import { getAclFormMessage } from '../../../../../utils/form_utils';
|
import { getAclFormMessage } from '../../../../../utils/form_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const CylandRegisterPiece = React.createClass({
|
const CylandRegisterPiece = React.createClass({
|
||||||
@ -221,4 +221,4 @@ const CylandRegisterPiece = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(withCurrentUser(withWhitelabel(CylandRegisterPiece)));
|
export default withRouter(withContext(CylandRegisterPiece, 'currentUser', 'isLoggedIn'));
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let DemoLanding = React.createClass({
|
let DemoLanding = React.createClass({
|
||||||
@ -63,4 +63,4 @@ let DemoLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(DemoLanding);
|
export default withContext(DemoLanding, 'whitelabel');
|
||||||
|
@ -14,11 +14,10 @@ import IkonotvSubmitButton from '../ikonotv_buttons/ikonotv_submit_button';
|
|||||||
import AccordionListItemPiece from '../../../../../ascribe_accordion_list/accordion_list_item_piece';
|
import AccordionListItemPiece from '../../../../../ascribe_accordion_list/accordion_list_item_piece';
|
||||||
|
|
||||||
import AclProxy from '../../../../../acl_proxy';
|
import AclProxy from '../../../../../acl_proxy';
|
||||||
|
import withContext from '../../../../../context/with_context';
|
||||||
import { currentUserShape } from '../../../../../prop_types';
|
import { currentUserShape } from '../../../../../prop_types';
|
||||||
|
|
||||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||||
import { mergeOptions } from '../../../../../../utils/general_utils';
|
|
||||||
import { withCurrentUser } from '../../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let IkonotvAccordionListItem = React.createClass({
|
let IkonotvAccordionListItem = React.createClass({
|
||||||
@ -120,4 +119,4 @@ let IkonotvAccordionListItem = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(IkonotvAccordionListItem);
|
export default withContext(IkonotvAccordionListItem, 'currentUser');
|
||||||
|
@ -15,13 +15,13 @@ import OwnershipFetcher from '../../../../../fetchers/ownership_fetcher';
|
|||||||
import CopyrightAssociationForm from '../../../../ascribe_forms/form_copyright_association';
|
import CopyrightAssociationForm from '../../../../ascribe_forms/form_copyright_association';
|
||||||
import Property from '../../../../ascribe_forms/property';
|
import Property from '../../../../ascribe_forms/property';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import AppConstants from '../../../../../constants/application_constants';
|
import AppConstants from '../../../../../constants/application_constants';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const IkonotvContractNotifications = React.createClass({
|
const IkonotvContractNotifications = React.createClass({
|
||||||
@ -201,4 +201,4 @@ const IkonotvContractNotifications = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(withCurrentUser(withWhitelabel(IkonotvContractNotifications)));
|
export default withRouter(withContext(IkonotvContractNotifications, 'currentUser', 'whitelabel'));
|
||||||
|
@ -6,9 +6,10 @@ import Button from 'react-bootstrap/lib/Button';
|
|||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let IkonotvLanding = React.createClass({
|
let IkonotvLanding = React.createClass({
|
||||||
@ -101,4 +102,4 @@ let IkonotvLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(IkonotvLanding);
|
export default withContext(IkonotvLanding, 'isLoggedIn');
|
||||||
|
@ -8,11 +8,11 @@ import NotificationStore from '../../../../../stores/notification_store';
|
|||||||
|
|
||||||
import IkonotvAccordionListItem from './ikonotv_accordion_list/ikonotv_accordion_list_item';
|
import IkonotvAccordionListItem from './ikonotv_accordion_list/ikonotv_accordion_list_item';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let IkonotvPieceList = React.createClass({
|
let IkonotvPieceList = React.createClass({
|
||||||
@ -91,4 +91,4 @@ let IkonotvPieceList = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(IkonotvPieceList));
|
export default withContext(IkonotvPieceList, 'currentUser', 'whitelabel');
|
||||||
|
@ -22,13 +22,13 @@ import LoanForm from '../../../../ascribe_forms/form_loan';
|
|||||||
|
|
||||||
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import ApiUrls from '../../../../../constants/api_urls';
|
import ApiUrls from '../../../../../constants/api_urls';
|
||||||
|
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
const IkonotvRegisterPiece = React.createClass({
|
const IkonotvRegisterPiece = React.createClass({
|
||||||
@ -246,4 +246,4 @@ const IkonotvRegisterPiece = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(withCurrentUser(withWhitelabel(IkonotvRegisterPiece)));
|
export default withRouter(withContext(IkonotvRegisterPiece, 'currentUser', 'whitelabel'));
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let LumenusLanding = React.createClass({
|
let LumenusLanding = React.createClass({
|
||||||
@ -65,4 +65,4 @@ let LumenusLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(LumenusLanding);
|
export default withContext(LumenusLanding, 'whitelabel');
|
||||||
|
@ -14,11 +14,11 @@ import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory';
|
|||||||
import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper';
|
import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper';
|
||||||
|
|
||||||
import AclProxy from '../../../../../acl_proxy';
|
import AclProxy from '../../../../../acl_proxy';
|
||||||
|
import withContext from '../../../../../context/with_context';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../../prop_types';
|
||||||
|
|
||||||
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
||||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
let MarketSubmitButton = React.createClass({
|
let MarketSubmitButton = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -187,4 +187,4 @@ let MarketSubmitButton = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(MarketSubmitButton));
|
export default withContext(MarketSubmitButton, 'currentUser', 'whitelabel');
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let MarketLanding = React.createClass({
|
let MarketLanding = React.createClass({
|
||||||
@ -69,4 +69,4 @@ let MarketLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(MarketLanding);
|
export default withContext(MarketLanding, 'whitelabel');
|
||||||
|
@ -4,12 +4,12 @@ import React from 'react';
|
|||||||
|
|
||||||
import MarketAclButtonList from './market_buttons/market_acl_button_list';
|
import MarketAclButtonList from './market_buttons/market_acl_button_list';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import PieceList from '../../../../piece_list';
|
import PieceList from '../../../../piece_list';
|
||||||
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
import { currentUserShape, whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser, withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
let MarketPieceList = React.createClass({
|
let MarketPieceList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -71,4 +71,4 @@ let MarketPieceList = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withCurrentUser(withWhitelabel(MarketPieceList));
|
export default withContext(MarketPieceList, 'currentUser', 'whitelabel');
|
||||||
|
@ -17,12 +17,12 @@ import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece';
|
|||||||
|
|
||||||
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
let MarketRegisterPiece = React.createClass({
|
let MarketRegisterPiece = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -162,4 +162,4 @@ let MarketRegisterPiece = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(withWhitelabel(MarketRegisterPiece));
|
export default withRouter(withContext(MarketRegisterPiece, 'whitelabel'));
|
||||||
|
@ -5,11 +5,11 @@ import React from 'react';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
|
import withContext from '../../../../context/with_context';
|
||||||
import { whitelabelShape } from '../../../../prop_types';
|
import { whitelabelShape } from '../../../../prop_types';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withWhitelabel } from '../../../../../utils/react_utils';
|
|
||||||
|
|
||||||
|
|
||||||
let PollineLanding = React.createClass({
|
let PollineLanding = React.createClass({
|
||||||
@ -63,4 +63,4 @@ let PollineLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withWhitelabel(PollineLanding);
|
export default withContext(PollineLanding, 'whitelabel');
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import { currentUserShape, whitelabelShape } from '../components/prop_types';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Taken from react-router (https://github.com/reactjs/react-router/blob/master/modules/withRouter.js)
|
* Taken from react-router (https://github.com/reactjs/react-router/blob/master/modules/withRouter.js)
|
||||||
* FIXME: should be put into react-component's utils
|
* FIXME: should be put into react-component's utils
|
||||||
@ -9,48 +5,3 @@ import { currentUserShape, whitelabelShape } from '../components/prop_types';
|
|||||||
export function getDisplayName(WrappedComponent) {
|
export function getDisplayName(WrappedComponent) {
|
||||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Similar to react-router's `withRouter`, this injects the `currentUser` from the Component's
|
|
||||||
* context into the Component as a prop. It also injects whether the user's logged in or not as
|
|
||||||
* `isLoggedIn`.
|
|
||||||
*
|
|
||||||
* @param {Component} Component Component to inject `context.currentUser` and `isLoggedIn` into
|
|
||||||
* @return {Component} Wrapped component
|
|
||||||
*/
|
|
||||||
export function withCurrentUser(Component) {
|
|
||||||
const contextTypes = {
|
|
||||||
currentUser: currentUserShape.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
const WithCurrentUser = (props, { currentUser }) => (
|
|
||||||
<Component {...props} currentUser={currentUser} isLoggedIn={!!currentUser.email} />
|
|
||||||
);
|
|
||||||
|
|
||||||
WithCurrentUser.displayName = `WithCurrentUser(${getDisplayName(Component)})`;
|
|
||||||
WithCurrentUser.contextTypes = contextTypes;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user