github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/dashboard/assets/components/Main.jsx (about)

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