import React, { Component } from 'react'; import { Layout, Drawer, Header, Navigation, Content, Footer, FooterSection, FooterDropDownSection, FooterLinkList, Grid, Cell, } from 'react-mdl'; import { Link } from 'react-router'; import style from './styles.scss'; import ErrorContainer from './error/error-container'; import UserContainer from './user/user-container'; import ShowUserContainer from './user/show-user-container'; const base = { name: 'Unleash', link: '/', }; function replace (input, params) { if (!params) { return input; } Object.keys(params).forEach(key => { input = input.replace(`:${key}`, params[key]); }); return input; } export default class App extends Component { constructor (props) { super(props); this.state = { drawerActive: false }; this.toggleDrawerActive = () => { this.setState({ drawerActive: !this.state.drawerActive }); }; } static contextTypes = { router: React.PropTypes.object, } componentDidMount () { document.title = `${this.getCurrentSection()} - Unleash Admin`; } getCurrentSection () { const { routes } = this.props; const lastRoute = routes[routes.length - 1]; return lastRoute ? lastRoute.pageTitle : ''; } getTitleWithLinks () { const { routes, params } = this.props; const unique = {}; let result = [base].concat(routes.splice(1).map((routeEntry) => ({ name: replace(routeEntry.pageTitle, params), link: replace(routeEntry.link || routeEntry.path, params), }))).filter(entry => { if (!unique[entry.link]) { unique[entry.link] = true; return true; } return false; }); if (result.length > 2) { result = result.splice(1); } return ( {result.map((entry, index) => ( {entry.name} {(index + 1) < result.length ? ' / ' : null} ))} ); } onOverlayClick = () => this.setState({ drawerActive: false }); render () { const createListItem = (path, caption) => {caption} ; return (
Github
{createListItem('/features', 'Feature toggles')} {createListItem('/strategies', 'Strategies')} {createListItem('/history', 'Event history')} {createListItem('/archive', 'Archived toggles')}
{createListItem('/applications', 'Applications')} {createListItem('/metrics', 'Client metrics')} {createListItem('/client-strategies', 'Client strategies')} {createListItem('/client-instances', 'Client instances')}
{this.props.children}
); return (
{this.props.children}
); } };