1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

add router/navigation integration into whole project

This commit is contained in:
Tim Daubenschütz 2015-08-27 14:34:15 +02:00
parent b67466d196
commit 9d7a9bd028
8 changed files with 37 additions and 52 deletions

View File

@ -6,15 +6,16 @@ import Header from '../components/header';
import Footer from '../components/footer';
import GlobalNotification from './global_notification';
// let Link = Router.Link;
let RouteHandler = Router.RouteHandler;
import getRoutes from '../routes';
let RouteHandler = Router.RouteHandler;
let AscribeApp = React.createClass({
render() {
return (
<div className="container ascribe-default-app">
<Header />
<Header routes={getRoutes()} />
<RouteHandler />
<Footer />
<GlobalNotification />

View File

@ -93,8 +93,6 @@ let Header = React.createClass({
render() {
let account = null;
let signup = null;
let collection = null;
let addNewWork = null;
if (this.state.currentUser.username){
account = (
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
@ -103,9 +101,6 @@ let Header = React.createClass({
<MenuItemLink eventKey="3" to="logout">{getLangText('Log out')}</MenuItemLink>
</DropdownButton>
);
collection = <NavItemLink to="pieces" query={this.getQuery()}>{getLangText('COLLECTION')}</NavItemLink>;
addNewWork = this.props.showAddWork ? <NavItemLink to="register_piece" query={{'slide_num': 0}}>+ {getLangText('NEW WORK')}</NavItemLink> : null;
}
else {
account = <NavItemLink to="login">{getLangText('LOGIN')}</NavItemLink>;
@ -126,8 +121,6 @@ let Header = React.createClass({
</Nav>
<Nav navbar right>
<HeaderNotificationDebug show={false}/>
{addNewWork}
{collection}
{account}
{signup}
</Nav>

View File

@ -16,6 +16,9 @@ let NavRoutesLinks = React.createClass({
},
extractLinksFromRoutes(node, i) {
if(!node) {
return;
}
node = node.props;
@ -35,11 +38,11 @@ let NavRoutesLinks = React.createClass({
// if the node's child is actually a node of level one (a child of a node), we're
// returning a DropdownButton matching MenuItemLink
return (
<MenuItemLink to={child.props.path} key={j}>{child.props.headerTitle}</MenuItemLink>
<MenuItemLink to={child.props.name} key={j}>{child.props.headerTitle}</MenuItemLink>
);
} else if(i === 0) {
return (
<NavItemLink to={child.props.path} key={j}>{child.props.headerTitle}</NavItemLink>
<NavItemLink to={child.props.name} key={j}>{child.props.headerTitle}</NavItemLink>
);
} else {
return null;

View File

@ -1,25 +0,0 @@
'use strict';
import React from 'react';
import Router from 'react-router';
import App from './ascribe_app';
import AppConstants from '../constants/application_constants';
let Route = Router.Route;
let Redirect = Router.Redirect;
let baseUrl = AppConstants.baseUrl;
function getRoutes(commonRoutes) {
return (
<Route name="app" path={baseUrl} handler={App}>
<Redirect from={baseUrl} to="login" />
<Redirect from={baseUrl + '/'} to="login" />
{commonRoutes}
</Route>
);
}
export default getRoutes;

View File

@ -7,6 +7,8 @@ import Header from '../../header';
import Footer from '../../footer';
import GlobalNotification from '../../global_notification';
import getRoutes from './prize_routes';
let RouteHandler = Router.RouteHandler;
let PrizeApp = React.createClass({
@ -14,10 +16,14 @@ let PrizeApp = React.createClass({
render() {
let header = null;
let subdomain = window.location.host.split('.')[0];
let ROUTES = getRoutes(null, subdomain);
if (this.isActive('landing') || this.isActive('login') || this.isActive('signup')) {
header = <Hero />;
} else {
header = <Header showAddWork={false} />;
header = <Header showAddWork={false} routes={ROUTES}/>;
}
return (

View File

@ -29,8 +29,8 @@ function getRoutes() {
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={PrizeRegisterPiece} />
<Route name="pieces" path="collection" handler={PrizePieceList} />
<Route name="register_piece" path="register_piece" handler={PrizeRegisterPiece} headerTitle="+ NEW WORK" />
<Route name="pieces" path="collection" handler={PrizePieceList} headerTitle="COLLECTION" />
<Route name="piece" path="pieces/:pieceId" handler={PrizePieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} />

View File

@ -41,8 +41,8 @@ let ROUTES = {
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={CylandRegisterPiece} />
<Route name="pieces" path="collection" handler={CylandPieceList} />
<Route name="register_piece" path="register_piece" handler={CylandRegisterPiece} headerTitle="+ NEW WORK" />
<Route name="pieces" path="collection" handler={CylandPieceList} headerTitle="COLLECTION" />
<Route name="piece" path="pieces/:pieceId" handler={CylandPieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} />
@ -56,8 +56,8 @@ let ROUTES = {
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={CCRegisterPiece} />
<Route name="pieces" path="collection" handler={PieceList} />
<Route name="register_piece" path="register_piece" handler={CCRegisterPiece} headerTitle="+ NEW WORK" />
<Route name="pieces" path="collection" handler={PieceList} headerTitle="COLLECTION" />
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} />
@ -70,9 +70,9 @@ let ROUTES = {
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="request_loan" path="request_loan" handler={IkonotvRequestLoan} headerTitle="Send new contract" />
<Route name="register_piece" path="register_piece" handler={IkonotvRegisterPiece} />
<Route name="pieces" path="collection" handler={IkonotvPieceList} />
<Route name="request_loan" path="request_loan" handler={IkonotvRequestLoan} headerTitle="SEND NEW CONTRACT" />
<Route name="register_piece" path="register_piece" handler={IkonotvRegisterPiece} headerTitle="+ NEW WORK"/>
<Route name="pieces" path="collection" handler={IkonotvPieceList} headerTitle="COLLECTION"/>
<Route name="piece" path="pieces/:pieceId" handler={CylandPieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} />

View File

@ -5,7 +5,8 @@ import Router from 'react-router';
import getPrizeRoutes from './components/whitelabel/prize/prize_routes';
import getWalletRoutes from './components/whitelabel/wallet/wallet_routes';
import getDefaultRoutes from './components/routes';
import App from './components/ascribe_app';
import PieceList from './components/piece_list';
import PieceContainer from './components/ascribe_detail/piece_container';
@ -23,19 +24,25 @@ import RegisterPiece from './components/register_piece';
import PrizesDashboard from './components/ascribe_prizes_dashboard/prizes_dashboard';
import AppConstants from './constants/application_constants';
let Route = Router.Route;
let Redirect = Router.Redirect;
let baseUrl = AppConstants.baseUrl;
const COMMON_ROUTES = (
<Route>
<Route name="app" path={baseUrl} handler={App}>
<Redirect from={baseUrl} to="login" />
<Redirect from={baseUrl + '/'} to="login" />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="login" path="login" handler={LoginContainer} />
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="pieces" path="collection" handler={PieceList} />
<Route name="register_piece" path="register_piece" handler={RegisterPiece} headerTitle="+ NEW WORK" />
<Route name="pieces" path="collection" handler={PieceList} headerTitle="COLLECTION" />
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={RegisterPiece} />
<Route name="settings" path="settings" handler={SettingsContainer} />
<Route name="coa_verify" path="verify" handler={CoaVerifyContainer} />
<Route name="prizes" path="prizes" handler={PrizesDashboard} />
@ -51,7 +58,7 @@ function getRoutes(type, subdomain) {
} else if(type === 'wallet') {
routes = getWalletRoutes(COMMON_ROUTES, subdomain);
} else {
routes = getDefaultRoutes(COMMON_ROUTES);
routes = COMMON_ROUTES;
}
return routes;