aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/assets/components/Main.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard/assets/components/Main.jsx')
-rw-r--r--dashboard/assets/components/Main.jsx123
1 files changed, 41 insertions, 82 deletions
diff --git a/dashboard/assets/components/Main.jsx b/dashboard/assets/components/Main.jsx
index b119d1ffd..6f1668a29 100644
--- a/dashboard/assets/components/Main.jsx
+++ b/dashboard/assets/components/Main.jsx
@@ -1,3 +1,5 @@
+// @flow
+
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
@@ -15,95 +17,52 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
import React, {Component} from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
-import {withStyles} from 'material-ui/styles';
-
-import {TAGS, DRAWER_WIDTH} from "./Common.jsx";
-import Home from './Home.jsx';
-// ContentSwitch chooses and renders the proper page content.
-class ContentSwitch extends Component {
- render() {
- switch(this.props.active) {
- case TAGS.home.id:
- return <Home memory={this.props.memory} traffic={this.props.traffic} shouldUpdate={this.props.shouldUpdate} />;
- case TAGS.chain.id:
- return null;
- case TAGS.transactions.id:
- return null;
- case TAGS.network.id:
- // Only for testing.
- return null;
- case TAGS.system.id:
- return null;
- case TAGS.logs.id:
- return <div>{this.props.logs.map((log, index) => <div key={index}>{log}</div>)}</div>;
- }
- return null;
- }
-}
+import withStyles from 'material-ui/styles/withStyles';
-ContentSwitch.propTypes = {
- active: PropTypes.string.isRequired,
- shouldUpdate: PropTypes.object.isRequired,
-};
+import Home from './Home';
+import {MENU} from './Common';
+import type {Content} from '../types/content';
-// styles contains the styles for the Main component.
+// Styles for the Content component.
const styles = theme => ({
- content: {
- width: '100%',
- marginLeft: -DRAWER_WIDTH,
- flexGrow: 1,
- backgroundColor: theme.palette.background.default,
- padding: theme.spacing.unit * 3,
- transition: theme.transitions.create('margin', {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen,
- }),
- marginTop: 56,
- overflow: 'auto',
- [theme.breakpoints.up('sm')]: {
- content: {
- height: 'calc(100% - 64px)',
- marginTop: 64,
- },
- },
- },
- contentShift: {
- marginLeft: 0,
- transition: theme.transitions.create('margin', {
- easing: theme.transitions.easing.easeOut,
- duration: theme.transitions.duration.enteringScreen,
- }),
- },
+ content: {
+ flexGrow: 1,
+ backgroundColor: theme.palette.background.default,
+ padding: theme.spacing.unit * 3,
+ overflow: 'auto',
+ },
});
+export type Props = {
+ classes: Object,
+ active: string,
+ content: Content,
+ shouldUpdate: Object,
+};
+// Main renders the chosen content.
+class Main extends Component<Props> {
+ render() {
+ const {
+ classes, active, content, shouldUpdate,
+ } = this.props;
-// Main renders a component for the page content.
-class Main extends Component {
- render() {
- // The classes property is injected by withStyles().
- const {classes} = this.props;
+ let children = null;
+ switch (active) {
+ case MENU.get('home').id:
+ children = <Home memory={content.home.memory} traffic={content.home.traffic} shouldUpdate={shouldUpdate} />;
+ break;
+ case MENU.get('chain').id:
+ case MENU.get('txpool').id:
+ case MENU.get('network').id:
+ case MENU.get('system').id:
+ children = <div>Work in progress.</div>;
+ break;
+ case MENU.get('logs').id:
+ children = <div>{content.logs.log.map((log, index) => <div key={index}>{log}</div>)}</div>;
+ }
- return (
- <main className={classNames(classes.content, this.props.opened && classes.contentShift)}>
- <ContentSwitch
- active={this.props.active}
- memory={this.props.memory}
- traffic={this.props.traffic}
- logs={this.props.logs}
- shouldUpdate={this.props.shouldUpdate}
- />
- </main>
- );
- }
+ return <div className={classes.content}>{children}</div>;
+ }
}
-Main.propTypes = {
- classes: PropTypes.object.isRequired,
- opened: PropTypes.bool.isRequired,
- active: PropTypes.string.isRequired,
- shouldUpdate: PropTypes.object.isRequired,
-};
-
export default withStyles(styles)(Main);