github.com/mandrigin/go-ethereum@v1.7.4-0.20180116162341-02aeb3d76652/dashboard/assets/components/Footer.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 import AppBar from 'material-ui/AppBar'; 23 import Toolbar from 'material-ui/Toolbar'; 24 import Typography from 'material-ui/Typography'; 25 26 import type {General} from '../types/content'; 27 28 // styles contains styles for the Header component. 29 const styles = theme => ({ 30 footer: { 31 backgroundColor: theme.palette.background.appBar, 32 color: theme.palette.getContrastText(theme.palette.background.appBar), 33 zIndex: theme.zIndex.appBar, 34 }, 35 toolbar: { 36 paddingLeft: theme.spacing.unit, 37 paddingRight: theme.spacing.unit, 38 display: 'flex', 39 justifyContent: 'flex-end', 40 }, 41 light: { 42 color: 'rgba(255, 255, 255, 0.54)', 43 }, 44 }); 45 export type Props = { 46 general: General, 47 classes: Object, 48 }; 49 // TODO (kurkomisi): If the structure is appropriate, make an abstraction of the common parts with the Header. 50 // Footer renders the header of the dashboard. 51 class Footer extends Component<Props> { 52 shouldComponentUpdate(nextProps) { 53 return typeof nextProps.shouldUpdate.logs !== 'undefined'; 54 } 55 56 info = (about: string, data: string) => ( 57 <Typography type="caption" color="inherit"> 58 <span className={this.props.classes.light}>{about}</span> {data} 59 </Typography> 60 ); 61 62 render() { 63 const {classes, general} = this.props; // The classes property is injected by withStyles(). 64 const geth = general.version ? this.info('Geth', general.version) : null; 65 const commit = general.commit ? this.info('Commit', general.commit.substring(0, 7)) : null; 66 67 return ( 68 <AppBar position="static" className={classes.footer}> 69 <Toolbar className={classes.toolbar}> 70 <div> 71 {geth} 72 {commit} 73 </div> 74 </Toolbar> 75 </AppBar> 76 ); 77 } 78 } 79 80 export default withStyles(styles)(Footer);