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

Rename AuthProxyHandler to ProxyHandler and remove default export

This commit is contained in:
Tim Daubenschütz 2015-12-08 10:38:32 +01:00
parent e1c2c2514c
commit 7cb5fa6758
4 changed files with 71 additions and 69 deletions

View File

@ -12,6 +12,8 @@ import AppConstants from '../../constants/application_constants';
const { object } = React.PropTypes; const { object } = React.PropTypes;
const WHEN_ENUM = ['loggedIn', 'loggedOut']; const WHEN_ENUM = ['loggedIn', 'loggedOut'];
/** /**
* Can be used in combination with `Route` as an intermediate Handler * Can be used in combination with `Route` as an intermediate Handler
* between the actual component we want to display dependent on a certain state * 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 {string} options.to Any type of route path that is defined in routes.js
* @param {enum/string} options.when ('loggedIn' || 'loggedOut') * @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`. // validate `when`, must be contained in `WHEN_ENUM`.
// Throw an error otherwise. // Throw an error otherwise.
@ -31,7 +33,7 @@ export default function AuthProxyHandler({to, when}) {
return (Component) => { return (Component) => {
return React.createClass({ return React.createClass({
displayName: 'AuthProxyHandler', displayName: 'ProxyHandler',
propTypes: { propTypes: {
location: object location: object

View File

@ -22,7 +22,7 @@ import PasswordResetContainer from '../../password_reset_container';
import CoaVerifyContainer from '../../coa_verify_container'; import CoaVerifyContainer from '../../coa_verify_container';
import ErrorNotFoundPage from '../../error_not_found_page'; 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 = { const ROUTES = {
@ -31,26 +31,26 @@ const ROUTES = {
<IndexRoute component={SPLanding} /> <IndexRoute component={SPLanding} />
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SPLoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPLoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SPSignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPSignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPSettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPSettingsContainer)}/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPRegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SPPieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPPieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route path='pieces/:pieceId' component={SPPieceContainer} /> <Route path='pieces/:pieceId' component={SPPieceContainer} />
@ -64,20 +64,20 @@ const ROUTES = {
<IndexRoute component={PRLanding} /> <IndexRoute component={PRLanding} />
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PRRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(PRRegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPLoginContainer)} /> component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPLoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)} /> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)} />
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPSignupContainer)} /> component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPSignupContainer)} />
<Route <Route
path='password_reset' 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='pieces/:pieceId' component={SPPieceContainer} />
<Route path='*' component={ErrorNotFoundPage} /> <Route path='*' component={ErrorNotFoundPage} />
</Route> </Route>

View File

@ -40,7 +40,7 @@ import LumenusLanding from './components/lumenus/lumenus_landing';
import Vivi23Landing from './components/23vivi/23vivi_landing'; import Vivi23Landing from './components/23vivi/23vivi_landing';
import Vivi23PieceList from './components/23vivi/23vivi_piece_list'; 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'; import WalletApp from './wallet_app';
@ -51,29 +51,29 @@ let ROUTES = {
<IndexRoute component={CylandLanding} /> <IndexRoute component={CylandLanding} />
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' path='contract_settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CylandRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandRegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CylandPieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandPieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route path='editions/:editionId' component={EditionContainer} /> <Route path='editions/:editionId' component={EditionContainer} />
<Route path='verify' component={CoaVerifyContainer} /> <Route path='verify' component={CoaVerifyContainer} />
@ -85,29 +85,29 @@ let ROUTES = {
<Route path='/' component={WalletApp}> <Route path='/' component={WalletApp}>
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' path='contract_settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(CCRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(CCRegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route path='pieces/:pieceId' component={PieceContainer} /> <Route path='pieces/:pieceId' component={PieceContainer} />
<Route path='editions/:editionId' component={EditionContainer} /> <Route path='editions/:editionId' component={EditionContainer} />
@ -120,39 +120,39 @@ let ROUTES = {
<IndexRoute component={IkonotvLanding} /> <IndexRoute component={IkonotvLanding} />
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' path='contract_settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
<Route <Route
path='request_loan' path='request_loan'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SendContractAgreementForm)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(SendContractAgreementForm)}
headerTitle='SEND NEW CONTRACT' headerTitle='SEND NEW CONTRACT'
aclName='acl_create_contractagreement'/> aclName='acl_create_contractagreement'/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvRegisterPiece)}
headerTitle='+ NEW WORK' headerTitle='+ NEW WORK'
aclName='acl_create_piece'/> aclName='acl_create_piece'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvPieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvPieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route <Route
path='contract_notifications' 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='pieces/:pieceId' component={IkonotvPieceContainer} />
<Route path='editions/:editionId' component={EditionContainer} /> <Route path='editions/:editionId' component={EditionContainer} />
<Route path='verify' component={CoaVerifyContainer} /> <Route path='verify' component={CoaVerifyContainer} />
@ -161,32 +161,32 @@ let ROUTES = {
), ),
'lumenus': ( 'lumenus': (
<Route path='/' component={WalletApp}> <Route path='/' component={WalletApp}>
<IndexRoute component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LumenusLanding)} /> <IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LumenusLanding)} />
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' path='contract_settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketPieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketPieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route path='pieces/:pieceId' component={MarketPieceContainer} /> <Route path='pieces/:pieceId' component={MarketPieceContainer} />
<Route path='editions/:editionId' component={MarketEditionContainer} /> <Route path='editions/:editionId' component={MarketEditionContainer} />
@ -196,33 +196,33 @@ let ROUTES = {
), ),
'23vivi': ( '23vivi': (
<Route path='/' component={WalletApp}> <Route path='/' component={WalletApp}>
<IndexRoute component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(Vivi23Landing)} /> <IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(Vivi23Landing)} />
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' path='contract_settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
headerTitle='+ NEW WORK' headerTitle='+ NEW WORK'
aclName='acl_wallet_submit'/> aclName='acl_wallet_submit'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(Vivi23PieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(Vivi23PieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route path='pieces/:pieceId' component={MarketPieceContainer} /> <Route path='pieces/:pieceId' component={MarketPieceContainer} />
<Route path='editions/:editionId' component={MarketEditionContainer} /> <Route path='editions/:editionId' component={MarketEditionContainer} />

View File

@ -25,39 +25,39 @@ import ErrorNotFoundPage from './components/error_not_found_page';
import RegisterPiece from './components/register_piece'; 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 = ( let COMMON_ROUTES = (
<Route path='/' component={App}> <Route path='/' component={App}>
<Route <Route
path='login' path='login'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
<Route <Route
path='register_piece' path='register_piece'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(RegisterPiece)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(RegisterPiece)}
headerTitle='+ NEW WORK'/> headerTitle='+ NEW WORK'/>
<Route <Route
path='collection' path='collection'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)} component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
headerTitle='COLLECTION'/> headerTitle='COLLECTION'/>
<Route <Route
path='signup' path='signup'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
<Route <Route
path='logout' path='logout'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(LogoutContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(LogoutContainer)}/>
<Route path='pieces/:pieceId' component={PieceContainer} /> <Route path='pieces/:pieceId' component={PieceContainer} />
<Route path='editions/:editionId' component={EditionContainer} /> <Route path='editions/:editionId' component={EditionContainer} />
<Route <Route
path='password_reset' path='password_reset'
component={AuthProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} /> component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
<Route <Route
path='settings' path='settings'
component={AuthProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/> component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
<Route <Route
path='contract_settings' 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='coa_verify' component={CoaVerifyContainer} />
<Route path='*' component={ErrorNotFoundPage} /> <Route path='*' component={ErrorNotFoundPage} />
</Route> </Route>