|
1 | 1 | import React, {Component} from '../base-react' |
| 2 | +import {FlatButton} from 'material-ui' |
| 3 | +import {navigateUp} from '../actions/router' |
| 4 | +import {connect} from 'react-redux' |
| 5 | +import {bindActionCreators} from 'redux' |
| 6 | + |
| 7 | +class MetaNavigatorRender extends Component { |
| 8 | + onBack () { |
| 9 | + this.props.navigateUp() |
| 10 | + } |
2 | 11 |
|
3 | | -export default class MetaNavigatorRender extends Component { |
4 | 12 | render () { |
5 | 13 | const {rootComponent, uri, getComponentAtTop} = this.props |
6 | 14 | const {componentAtTop} = getComponentAtTop(rootComponent, uri) |
7 | 15 | const Module = componentAtTop.component |
8 | 16 |
|
9 | 17 | return ( |
10 | | - <Module {...componentAtTop.props} /> |
| 18 | + <div> |
| 19 | + <Module {...componentAtTop.props} /> |
| 20 | + {uri && uri.count() > 1 && <FlatButton onClick={ () => this.onBack() } style={styles.backButton} label='Back'/>} |
| 21 | + </div> |
11 | 22 | ) |
12 | 23 | } |
13 | 24 | } |
14 | 25 |
|
15 | 26 | MetaNavigatorRender.propTypes = { |
16 | 27 | uri: React.PropTypes.object.isRequired, |
17 | 28 | getComponentAtTop: React.PropTypes.func.isRequired, |
18 | | - rootComponent: React.PropTypes.func.isRequired |
| 29 | + rootComponent: React.PropTypes.func.isRequired, |
| 30 | + navigateUp: React.PropTypes.func.isRequired |
| 31 | +} |
| 32 | + |
| 33 | +const styles = { |
| 34 | + backButton: { |
| 35 | + position: 'absolute', |
| 36 | + top: 0, |
| 37 | + right: 0, |
| 38 | + backgroundColor: '#cccccc' |
| 39 | + } |
19 | 40 | } |
| 41 | + |
| 42 | +export default connect(state => state, dispatch => bindActionCreators({navigateUp}, dispatch))(MetaNavigatorRender) |
0 commit comments