github.com/anthdm/go-ethereum@v1.8.4-0.20180412101906-60516c83b011/dashboard/assets/components/Main.jsx (about)

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