mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Rename AuthProxyHandler to ProxyHandler and remove default export
This commit is contained in:
parent
e1c2c2514c
commit
7cb5fa6758
@ -12,6 +12,8 @@ import AppConstants from '../../constants/application_constants';
|
||||
const { object } = React.PropTypes;
|
||||
const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Can be used in combination with `Route` as an intermediate Handler
|
||||
* between the actual component we want to display dependent on a certain state
|
||||
@ -20,7 +22,7 @@ const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
||||
* @param {string} options.to Any type of route path that is defined in routes.js
|
||||
* @param {enum/string} options.when ('loggedIn' || 'loggedOut')
|
||||
*/
|
||||
export default function AuthProxyHandler({to, when}) {
|
||||
export function ProxyHandler({to, when}) {
|
||||
|
||||
// validate `when`, must be contained in `WHEN_ENUM`.
|
||||
// Throw an error otherwise.
|
||||
@ -31,7 +33,7 @@ export default function AuthProxyHandler({to, when}) {
|
||||
|
||||
return (Component) => {
|
||||
return React.createClass({
|
||||
displayName: 'AuthProxyHandler',
|
||||
displayName: 'ProxyHandler',
|
||||
|
||||
propTypes: {
|
||||
location: object
|
@ -22,7 +22,7 @@ import PasswordResetContainer from '../../password_reset_container';
|
||||
import CoaVerifyContainer from '../../coa_verify_container';
|
||||
import ErrorNotFoundPage from '../../error_not_found_page';
|
||||
|
||||
import AuthProxyHandler from '../../../components/ascribe_routes/auth_proxy_handler';
|
||||
import { ProxyHandler } from '../../../components/ascribe_routes/proxy_handler';
|
||||
|
||||
|
||||
const ROUTES = {
|
||||
@ -31,26 +31,26 @@ const ROUTES = {
|
||||
<IndexRoute component={SPLanding} />
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SPLoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPLoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SPSignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPSignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPSettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPSettingsContainer)}/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPPieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPPieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
|
||||
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
||||
@ -64,20 +64,20 @@ const ROUTES = {
|
||||
<IndexRoute component={PRLanding} />
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PRRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PRRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPLoginContainer)} />
|
||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPLoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)} />
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)} />
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPSignupContainer)} />
|
||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPSignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/register_piece', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
||||
<Route path='*' component={ErrorNotFoundPage} />
|
||||
</Route>
|
||||
|
@ -40,7 +40,7 @@ import LumenusLanding from './components/lumenus/lumenus_landing';
|
||||
import Vivi23Landing from './components/23vivi/23vivi_landing';
|
||||
import Vivi23PieceList from './components/23vivi/23vivi_piece_list';
|
||||
|
||||
import AuthProxyHandler from '../../../components/ascribe_routes/auth_proxy_handler';
|
||||
import { ProxyHandler } from '../../../components/ascribe_routes/proxy_handler';
|
||||
|
||||
import WalletApp from './wallet_app';
|
||||
|
||||
@ -51,29 +51,29 @@ let ROUTES = {
|
||||
<IndexRoute component={CylandLanding} />
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CylandRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CylandPieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandPieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route path='editions/:editionId' component={EditionContainer} />
|
||||
<Route path='verify' component={CoaVerifyContainer} />
|
||||
@ -85,29 +85,29 @@ let ROUTES = {
|
||||
<Route path='/' component={WalletApp}>
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CCRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CCRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route path='pieces/:pieceId' component={PieceContainer} />
|
||||
<Route path='editions/:editionId' component={EditionContainer} />
|
||||
@ -120,39 +120,39 @@ let ROUTES = {
|
||||
<IndexRoute component={IkonotvLanding} />
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route
|
||||
path='request_loan'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SendContractAgreementForm)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SendContractAgreementForm)}
|
||||
headerTitle='SEND NEW CONTRACT'
|
||||
aclName='acl_create_contractagreement'/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'
|
||||
aclName='acl_create_piece'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvPieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvPieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route
|
||||
path='contract_notifications'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvContractNotifications)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvContractNotifications)}/>
|
||||
<Route path='pieces/:pieceId' component={IkonotvPieceContainer} />
|
||||
<Route path='editions/:editionId' component={EditionContainer} />
|
||||
<Route path='verify' component={CoaVerifyContainer} />
|
||||
@ -161,32 +161,32 @@ let ROUTES = {
|
||||
),
|
||||
'lumenus': (
|
||||
<Route path='/' component={WalletApp}>
|
||||
<IndexRoute component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LumenusLanding)} />
|
||||
<IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LumenusLanding)} />
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketPieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketPieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
||||
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
||||
@ -196,33 +196,33 @@ let ROUTES = {
|
||||
),
|
||||
'23vivi': (
|
||||
<Route path='/' component={WalletApp}>
|
||||
<IndexRoute component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(Vivi23Landing)} />
|
||||
<IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(Vivi23Landing)} />
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
||||
headerTitle='+ NEW WORK'
|
||||
aclName='acl_wallet_submit'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(Vivi23PieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(Vivi23PieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
||||
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
||||
|
18
js/routes.js
18
js/routes.js
@ -25,39 +25,39 @@ import ErrorNotFoundPage from './components/error_not_found_page';
|
||||
|
||||
import RegisterPiece from './components/register_piece';
|
||||
|
||||
import AuthProxyHandler from './components/ascribe_routes/auth_proxy_handler';
|
||||
import { ProxyHandler } from './components/ascribe_routes/proxy_handler';
|
||||
|
||||
|
||||
let COMMON_ROUTES = (
|
||||
<Route path='/' component={App}>
|
||||
<Route
|
||||
path='login'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
||||
<Route
|
||||
path='register_piece'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(RegisterPiece)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(RegisterPiece)}
|
||||
headerTitle='+ NEW WORK'/>
|
||||
<Route
|
||||
path='collection'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
||||
headerTitle='COLLECTION'/>
|
||||
<Route
|
||||
path='signup'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
||||
<Route
|
||||
path='logout'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(LogoutContainer)}/>
|
||||
<Route path='pieces/:pieceId' component={PieceContainer} />
|
||||
<Route path='editions/:editionId' component={EditionContainer} />
|
||||
<Route
|
||||
path='password_reset'
|
||||
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
||||
<Route
|
||||
path='settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
||||
<Route
|
||||
path='contract_settings'
|
||||
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
||||
<Route path='coa_verify' component={CoaVerifyContainer} />
|
||||
<Route path='*' component={ErrorNotFoundPage} />
|
||||
</Route>
|
||||
|
Loading…
Reference in New Issue
Block a user