Incorporate new RedirectProxyRoute into whitelabel pages

This commit is contained in:
Tim Daubenschütz 2015-10-09 15:19:24 +02:00
parent cee8d7cae7
commit 69afc6165a
5 changed files with 169 additions and 44 deletions

View File

@ -75,7 +75,8 @@ class AppGateway {
subdomain = settings.subdomain;
}
if(subdomain) {
// www and cc do not have a landing page
if(subdomain && subdomain !== 'cc') {
redirectRoute = null;
}

View File

@ -20,13 +20,19 @@ let PrizeApp = React.createClass({
},
render() {
const { history, routes } = this.props;
let header = null;
let subdomain = getSubdomain();
if (this.props.history.isActive('/') || this.props.history.isActive('/login') || this.props.history.isActive('/signup')) {
// The second element of routes is always the active component object, where we can
// extract the path.
let path = routes[1] ? routes[1].path : null;
// if the path of the current activeRoute is not defined, then this is the IndexRoute
if (!path || history.isActive('/login') || history.isActive('/signup')) {
header = <Hero />;
} else {
header = <Header showAddWork={false} routes={this.props.routes}/>;
header = <Header showAddWork={false} routes={routes}/>;
}
return (

View File

@ -1,7 +1,7 @@
'use strict';
import React from 'react';
import { Route } from 'react-router';
import { Route, IndexRoute } from 'react-router';
import Landing from './components/prize_landing';
import LoginContainer from './components/prize_login_container';
@ -19,22 +19,49 @@ import ErrorNotFoundPage from '../../../components/error_not_found_page';
import App from './prize_app';
import AppConstants from '../../../constants/application_constants';
import ProxyRoute from '../../../components/ascribe_routes/proxy_route';
import RedirectProxyHandler from '../../../components/ascribe_routes/proxy_routes/redirect_proxy_handler';
let baseUrl = AppConstants.baseUrl;
function getRoutes() {
return (
<Route path={baseUrl} component={App}>
<Route path={baseUrl} component={Landing} />
<Route path="login" component={LoginContainer} />
<Route path="logout" component={LogoutContainer} />
<Route path="signup" component={SignupContainer} />
<Route path="password_reset" component={PasswordResetContainer} />
<Route path="register_piece" component={PrizeRegisterPiece} headerTitle="+ NEW WORK" />
<Route path="collection" component={PrizePieceList} headerTitle="COLLECTION" />
<IndexRoute component={Landing} />
<ProxyRoute
path="login"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={LoginContainer} />
<ProxyRoute
path="logout"
proxyHandler={RedirectProxyHandler({to: '/', when: 'loggedOut'})}
component={LogoutContainer}/>
<ProxyRoute
path="signup"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={SignupContainer} />
<ProxyRoute
path="password_reset"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={PasswordResetContainer} />
<ProxyRoute
path="settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={SettingsContainer}/>
<ProxyRoute
path="register_piece"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={PrizeRegisterPiece}
headerTitle="+ NEW WORK"/>
<ProxyRoute
path="collection"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={PrizePieceList}
headerTitle="COLLECTION"/>
<Route path="pieces/:pieceId" component={PrizePieceContainer} />
<Route path="editions/:editionId" component={EditionContainer} />
<Route path="settings" component={SettingsContainer} />
<Route path="verify" component={CoaVerifyContainer} />
<Route path="*" component={ErrorNotFoundPage} />
</Route>

View File

@ -22,20 +22,20 @@ let WalletApp = React.createClass({
},
render() {
let header = null;
let subdomain = getSubdomain();
const { history, routes, children } = this.props;
// The second element of routes is always the active component object, where we can
// extract the path.
let [, { path } ] = this.props.routes;
let header = null;
let path = routes[1] ? routes[1].path : null;
// if the path of the current activeRoute is not defined, then this is the IndexRoute
if ((!path || this.props.history.isActive('/login') || this.props.history.isActive('/signup') || this.props.history.isActive('/contract_notifications'))
if ((!path || history.isActive('/login') || history.isActive('/signup') || history.isActive('/contract_notifications'))
&& (['ikonotv', 'cyland']).indexOf(subdomain) > -1) {
header = (<div className="hero"/>);
} else {
header = <Header showAddWork={true} routes={this.props.routes} />;
header = <Header showAddWork={true} routes={routes} />;
}
// In react-router 1.0, Routes have no 'name' property anymore. To keep functionality however,
@ -44,7 +44,7 @@ let WalletApp = React.createClass({
<div className={classNames('ascribe-wallet-app', 'route--' + (path ? path.split('/')[0] : 'landing'))}>
<div className='container'>
{header}
{this.props.children}
{children}
<GlobalNotification />
<div id="modal" className="container"></div>
<Footer />

View File

@ -30,6 +30,9 @@ import IkonotvContractNotifications from './components/ikonotv/ikonotv_contract_
import CCRegisterPiece from './components/cc/cc_register_piece';
import ProxyRoute from '../../../components/ascribe_routes/proxy_route';
import RedirectProxyHandler from '../../../components/ascribe_routes/proxy_routes/redirect_proxy_handler';
import WalletApp from './wallet_app';
import AppConstants from '../../../constants/application_constants';
@ -40,51 +43,139 @@ let ROUTES = {
'cyland': (
<Route path={baseUrl} component={WalletApp}>
<IndexRoute component={CylandLanding} />
<Route path="login" component={LoginContainer} />
<Route path="logout" component={LogoutContainer} />
<Route path="signup" component={SignupContainer} />
<Route path="password_reset" component={PasswordResetContainer} />
<Route path="register_piece" component={CylandRegisterPiece} headerTitle="+ NEW WORK" />
<Route path="collection" component={CylandPieceList} headerTitle="COLLECTION" />
<Route path="pieces/:pieceId" component={CylandPieceContainer} />
<ProxyRoute
path="login"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={LoginContainer} />
<ProxyRoute
path="logout"
proxyHandler={RedirectProxyHandler({to: '/', when: 'loggedOut'})}
component={LogoutContainer}/>
<ProxyRoute
path="signup"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={SignupContainer} />
<ProxyRoute
path="password_reset"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={PasswordResetContainer} />
<ProxyRoute
path="settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={SettingsContainer}/>
<ProxyRoute
path="contract_settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={ContractSettings}/>
<ProxyRoute
path="register_piece"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={CylandRegisterPiece}
headerTitle="+ NEW WORK"/>
<ProxyRoute
path="collection"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={CylandPieceList}
headerTitle="COLLECTION"/>
<Route path="editions/:editionId" component={EditionContainer} />
<Route path="verify" component={CoaVerifyContainer} />
<Route path="settings" component={SettingsContainer} />
<Route path="contract_settings" component={ContractSettings} />
<Route path="pieces/:pieceId" component={CylandPieceContainer} />
<Route path="*" component={ErrorNotFoundPage} />
</Route>
),
'cc': (
<Route path={baseUrl} component={WalletApp}>
<Route path="login" component={LoginContainer} />
<Route path="logout" component={LogoutContainer} />
<Route path="signup" component={SignupContainer} />
<Route path="password_reset" component={PasswordResetContainer} />
<Route path="register_piece" component={CCRegisterPiece} headerTitle="+ NEW WORK" />
<Route path="collection" component={PieceList} headerTitle="COLLECTION" />
<ProxyRoute
path="login"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={LoginContainer} />
<ProxyRoute
path="logout"
proxyHandler={RedirectProxyHandler({to: '/', when: 'loggedOut'})}
component={LogoutContainer}/>
<ProxyRoute
path="signup"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={SignupContainer} />
<ProxyRoute
path="password_reset"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={PasswordResetContainer} />
<ProxyRoute
path="settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={SettingsContainer}/>
<ProxyRoute
path="contract_settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={ContractSettings}/>
<ProxyRoute
path="register_piece"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={CCRegisterPiece}
headerTitle="+ NEW WORK"/>
<ProxyRoute
path="collection"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={PieceList}
headerTitle="COLLECTION"/>
<Route path="pieces/:pieceId" component={PieceContainer} />
<Route path="editions/:editionId" component={EditionContainer} />
<Route path="verify" component={CoaVerifyContainer} />
<Route path="settings" component={SettingsContainer} />
<Route path="*" component={ErrorNotFoundPage} />
</Route>
),
'ikonotv': (
<Route path={baseUrl} component={WalletApp}>
<IndexRoute component={IkonotvLanding} />
<Route path="login" component={LoginContainer} />
<Route path="logout" component={LogoutContainer} />
<Route path="signup" component={SignupContainer} />
<Route path="password_reset" component={PasswordResetContainer} />
<Route path="request_loan" component={ContractAgreementForm} headerTitle="SEND NEW CONTRACT" aclName="acl_create_contractagreement" />
<Route path="register_piece" component={IkonotvRegisterPiece} headerTitle="+ NEW WORK" aclName="acl_create_piece"/>
<Route path="collection" component={IkonotvPieceList} headerTitle="COLLECTION"/>
<ProxyRoute
path="login"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={LoginContainer} />
<ProxyRoute
path="logout"
proxyHandler={RedirectProxyHandler({to: '/', when: 'loggedOut'})}
component={LogoutContainer}/>
<ProxyRoute
path="signup"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={SignupContainer} />
<ProxyRoute
path="password_reset"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={PasswordResetContainer} />
<ProxyRoute
path="settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={SettingsContainer}/>
<ProxyRoute
path="contract_settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={ContractSettings}/>
<ProxyRoute
path="request_loan"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={ContractAgreementForm}
headerTitle="SEND NEW CONTRACT"
aclName="acl_create_contractagreement"/>
<ProxyRoute
path="register_piece"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={IkonotvRegisterPiece}
headerTitle="+ NEW WORK"
aclName="acl_create_piece"/>
<ProxyRoute
path="collection"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={IkonotvPieceList}
headerTitle="COLLECTION"/>
<ProxyRoute
path="contract_notifications"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={IkonotvContractNotifications}/>
<Route path="pieces/:pieceId" component={IkonotvPieceContainer} />
<Route path="editions/:editionId" component={EditionContainer} />
<Route path="verify" component={CoaVerifyContainer} />
<Route path="settings" component={SettingsContainer} />
<Route path="contract_settings" component={ContractSettings} />
<Route path="contract_notifications" component={IkonotvContractNotifications} />
<Route path="*" component={ErrorNotFoundPage} />
</Route>
)