2016-11-10 14:26:24 +01:00
|
|
|
import React, { Component } from 'react';
|
2016-12-04 11:56:41 +01:00
|
|
|
import { Layout, Drawer, Header, Navigation, Content,
|
|
|
|
Footer, FooterSection, FooterDropDownSection, FooterLinkList,
|
2016-12-05 15:15:01 +01:00
|
|
|
Grid, Cell,
|
2016-12-04 11:56:41 +01:00
|
|
|
} from 'react-mdl';
|
2016-11-10 14:26:24 +01:00
|
|
|
import style from './styles.scss';
|
|
|
|
import ErrorContainer from './error/error-container';
|
|
|
|
|
2016-11-24 21:32:29 +01:00
|
|
|
import UserContainer from './user/user-container';
|
2016-11-25 15:37:06 +01:00
|
|
|
import ShowUserContainer from './user/show-user-container';
|
2016-11-24 21:32:29 +01:00
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
export default class App extends Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
this.state = { drawerActive: false };
|
|
|
|
|
|
|
|
this.toggleDrawerActive = () => {
|
|
|
|
this.setState({ drawerActive: !this.state.drawerActive });
|
|
|
|
};
|
|
|
|
}
|
2016-12-04 11:56:41 +01:00
|
|
|
static contextTypes = {
|
|
|
|
router: React.PropTypes.object,
|
|
|
|
}
|
2016-11-10 14:26:24 +01:00
|
|
|
|
2016-12-04 15:23:22 +01:00
|
|
|
componentDidMount () {
|
|
|
|
document.title = `${this.getCurrentSection()} - Unleash Admin`;
|
|
|
|
}
|
|
|
|
|
|
|
|
getCurrentSection () {
|
|
|
|
const { routes } = this.props;
|
|
|
|
const lastRoute = routes[routes.length - 1];
|
|
|
|
return lastRoute ? lastRoute.pageTitle : '';
|
|
|
|
}
|
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
onOverlayClick = () => this.setState({ drawerActive: false });
|
|
|
|
|
|
|
|
render () {
|
2016-12-04 11:56:41 +01:00
|
|
|
const createListItem = (path, caption) =>
|
|
|
|
<a
|
2016-12-05 15:15:01 +01:00
|
|
|
href={this.context.router.createHref(path)}
|
2016-12-04 11:56:41 +01:00
|
|
|
className={this.context.router.isActive(path) ? style.active : ''}>
|
|
|
|
{caption}
|
|
|
|
</a>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{}}>
|
|
|
|
<UserContainer />
|
|
|
|
<Layout fixedHeader>
|
2016-12-04 15:23:22 +01:00
|
|
|
<Header title={<span><span style={{ color: '#ddd' }}>Unleash Admin / </span><strong>{this.getCurrentSection()}</strong></span>}>
|
2016-12-04 11:56:41 +01:00
|
|
|
<Navigation>
|
|
|
|
<a href="https://github.com/Unleash" target="_blank">Github</a>
|
|
|
|
<ShowUserContainer />
|
|
|
|
</Navigation>
|
|
|
|
</Header>
|
|
|
|
<Drawer title="Unleash Admin">
|
|
|
|
<Navigation>
|
|
|
|
{createListItem('/features', 'Feature toggles')}
|
|
|
|
{createListItem('/strategies', 'Strategies')}
|
|
|
|
{createListItem('/history', 'Event history')}
|
|
|
|
{createListItem('/archive', 'Archived toggles')}
|
|
|
|
<hr />
|
2016-12-05 15:15:01 +01:00
|
|
|
{createListItem('/applications', 'Applications')}
|
2016-12-04 11:56:41 +01:00
|
|
|
{createListItem('/metrics', 'Client metrics')}
|
|
|
|
{createListItem('/client-strategies', 'Client strategies')}
|
|
|
|
{createListItem('/client-instances', 'Client instances')}
|
|
|
|
</Navigation>
|
|
|
|
</Drawer>
|
|
|
|
<Content>
|
2016-12-04 15:25:33 +01:00
|
|
|
<Grid>
|
2016-12-04 11:56:41 +01:00
|
|
|
<Cell col={12}>
|
|
|
|
{this.props.children}
|
|
|
|
<ErrorContainer />
|
|
|
|
</Cell>
|
|
|
|
</Grid>
|
|
|
|
<Footer size="mega">
|
|
|
|
<FooterSection type="middle">
|
|
|
|
<FooterDropDownSection title="Menu">
|
|
|
|
<FooterLinkList>
|
|
|
|
{createListItem('/features', 'Feature toggles')}
|
|
|
|
{createListItem('/strategies', 'Strategies')}
|
|
|
|
{createListItem('/history', 'Event history')}
|
|
|
|
{createListItem('/archive', 'Archived toggles')}
|
|
|
|
</FooterLinkList>
|
|
|
|
</FooterDropDownSection>
|
|
|
|
<FooterDropDownSection title="Metrics">
|
|
|
|
<FooterLinkList>
|
2016-12-05 15:15:01 +01:00
|
|
|
{createListItem('/applications', 'Applications')}
|
2016-12-04 11:56:41 +01:00
|
|
|
{createListItem('/metrics', 'Client metrics')}
|
|
|
|
{createListItem('/client-strategies', 'Client strategies')}
|
|
|
|
{createListItem('/client-instances', 'Client instances')}
|
|
|
|
</FooterLinkList>
|
|
|
|
</FooterDropDownSection>
|
|
|
|
<FooterDropDownSection title="FAQ">
|
|
|
|
<FooterLinkList>
|
|
|
|
<a href="#">Help</a>
|
|
|
|
<a href="#">Privacy & Terms</a>
|
|
|
|
<a href="#">Questions</a>
|
|
|
|
<a href="#">Answers</a>
|
|
|
|
<a href="#">Contact Us</a>
|
|
|
|
</FooterLinkList>
|
|
|
|
</FooterDropDownSection>
|
|
|
|
<FooterDropDownSection title="Clients">
|
|
|
|
<FooterLinkList>
|
|
|
|
<a href="https://github.com/Unleash/unleash-node-client/">Node.js</a>
|
|
|
|
<a href="https://github.com/Unleash/unleash-java-client/">Java</a>
|
|
|
|
</FooterLinkList>
|
|
|
|
</FooterDropDownSection>
|
|
|
|
</FooterSection>
|
|
|
|
<FooterSection type="bottom" logo="Unleash Admin">
|
|
|
|
<FooterLinkList>
|
|
|
|
<a href="https://github.com/Unleash/unleash/" target="_blank">
|
|
|
|
GitHub
|
|
|
|
</a>
|
|
|
|
<a href="https://finn.no" target="_blank"><small>A product by</small> FINN.no</a>
|
|
|
|
</FooterLinkList>
|
|
|
|
</FooterSection>
|
|
|
|
</Footer>
|
|
|
|
</Content>
|
|
|
|
</Layout>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
return (
|
|
|
|
<div className={style.container}>
|
2016-11-25 15:37:06 +01:00
|
|
|
<AppBar title="Unleash Admin" leftIcon="menu" onLeftIconClick={this.toggleDrawerActive} className={style.appBar}>
|
2016-12-04 11:56:41 +01:00
|
|
|
|
2016-11-25 15:37:06 +01:00
|
|
|
</AppBar>
|
2016-11-10 14:26:24 +01:00
|
|
|
<div className={style.container} style={{ top: '6.4rem' }}>
|
|
|
|
<Layout>
|
|
|
|
<NavDrawer active={this.state.drawerActive} permanentAt="sm" onOverlayClick={this.onOverlayClick} >
|
|
|
|
<Navigation />
|
|
|
|
</NavDrawer>
|
|
|
|
<Panel scrollY>
|
|
|
|
<div style={{ padding: '1.8rem' }}>
|
2016-12-04 11:56:41 +01:00
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
{this.props.children}
|
|
|
|
</div>
|
|
|
|
</Panel>
|
2016-12-04 11:56:41 +01:00
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
</Layout>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|