-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5926997
commit de63c1f
Showing
9 changed files
with
142 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,79 @@ | ||
import React, {Component, PropTypes} from 'react' | ||
import {connect} from 'react-redux' | ||
import {Row, Col, Button, ButtonGroup, Glyph} from 'elemental' | ||
import {Row, Col, Button, ButtonGroup, Glyph, Spinner} from 'elemental' | ||
|
||
import {buttons} from '../actions' | ||
import Hash from '../components/hash' | ||
|
||
class Home extends Component { | ||
class ActionButtons extends Component { | ||
static propTypes = { | ||
simulate: PropTypes.func.isRequired, | ||
sync: PropTypes.func.isRequired, | ||
star: PropTypes.func.isRequired | ||
star: PropTypes.func.isRequired, | ||
head: PropTypes.string, | ||
processing: PropTypes.shape({ | ||
simulate: PropTypes.bool.isRequired, | ||
sync: PropTypes.bool.isRequired, | ||
star: PropTypes.bool.isRequired | ||
}).isRequired | ||
}; | ||
|
||
_onClick = (prop) => { | ||
return () => { | ||
this.props[prop]() | ||
} | ||
} | ||
|
||
render () { | ||
let head | ||
|
||
if (this.props.head) { | ||
head = ( | ||
<h3 className='current-head'> | ||
<em>Head</em> <Hash value={this.props.head} /> | ||
</h3> | ||
) | ||
} | ||
return ( | ||
<Col sm='1' className='action-buttons'> | ||
<h2 className='title'> | ||
libp2p <Glyph icon='heart' type='danger' /> ethereum | ||
</h2> | ||
<ButtonGroup> | ||
<Button type='hollow-primary' onClick={this.props.simulate} > | ||
Simulation | ||
<Button type='hollow-primary' onClick={this._onClick('simulate')} > | ||
{this.props.processing.simulate ? | ||
<Spinner type='primary' /> : | ||
'Simulation' | ||
} | ||
</Button> | ||
<Button type='hollow-primary' onClick={this.props.sync} > | ||
Sync | ||
<Button type='hollow-primary' onClick={this._onClick('sync')} > | ||
{this.props.processing.sync ? | ||
<Spinner type='primary' /> : | ||
'Sync' | ||
} | ||
</Button> | ||
<Button type='hollow-primary' onClick={this.props.star} > | ||
<Glyph icon='star' type='primary' /> | ||
<Button type='hollow-primary' onClick={this._onClick('star')} > | ||
{this.props.processing.star ? | ||
<Spinner type='primary' /> : | ||
<Glyph icon='star' type='primary' /> | ||
} | ||
</Button> | ||
</ButtonGroup> | ||
{head} | ||
</Col> | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps (state) { | ||
return {} | ||
return { | ||
head: state.head, | ||
processing: state.processing | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, { | ||
simulate: buttons.simulate, | ||
sync: buttons.sync, | ||
star: buttons.star | ||
})(Home) | ||
})(ActionButtons) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {buttons as actions} from '../actions' | ||
|
||
const defaultState = { | ||
simulate: false, | ||
sync: false, | ||
star: false | ||
} | ||
|
||
export default function processing (state = defaultState, action) { | ||
const {type, prop} = action | ||
|
||
switch (type) { | ||
case actions.START: | ||
return { | ||
...state, | ||
[prop]: true | ||
} | ||
case actions.STOP: | ||
return { | ||
...state, | ||
[prop]: false | ||
} | ||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters