Main.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @flow
  2. // Copyright 2017 The go-ethereum Authors
  3. // This file is part of the go-ethereum library.
  4. //
  5. // The go-ethereum library is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // The go-ethereum library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  17. import React, {Component} from 'react';
  18. import withStyles from 'material-ui/styles/withStyles';
  19. import Home from './Home';
  20. import {MENU} from './Common';
  21. import type {Content} from '../types/content';
  22. // Styles for the Content component.
  23. const styles = theme => ({
  24. content: {
  25. flexGrow: 1,
  26. backgroundColor: theme.palette.background.default,
  27. padding: theme.spacing.unit * 3,
  28. overflow: 'auto',
  29. },
  30. });
  31. export type Props = {
  32. classes: Object,
  33. active: string,
  34. content: Content,
  35. shouldUpdate: Object,
  36. };
  37. // Main renders the chosen content.
  38. class Main extends Component<Props> {
  39. render() {
  40. const {
  41. classes, active, content, shouldUpdate,
  42. } = this.props;
  43. let children = null;
  44. switch (active) {
  45. case MENU.get('home').id:
  46. children = <Home memory={content.home.memory} traffic={content.home.traffic} shouldUpdate={shouldUpdate} />;
  47. break;
  48. case MENU.get('chain').id:
  49. case MENU.get('txpool').id:
  50. case MENU.get('network').id:
  51. case MENU.get('system').id:
  52. children = <div>Work in progress.</div>;
  53. break;
  54. case MENU.get('logs').id:
  55. children = <div>{content.logs.log.map((log, index) => <div key={index}>{log}</div>)}</div>;
  56. }
  57. return <div className={classes.content}>{children}</div>;
  58. }
  59. }
  60. export default withStyles(styles)(Main);