2016-11-28 18:47:47 +01:00
|
|
|
import React from 'react'
|
|
|
|
import {connect} from 'react-redux'
|
|
|
|
|
2016-11-30 20:57:35 +01:00
|
|
|
import {Button, Icon, Segment} from 'semantic-ui-react'
|
|
|
|
|
2016-11-28 18:47:47 +01:00
|
|
|
import * as Actions from '../actions'
|
|
|
|
import * as Selectors from '../selectors'
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
2017-01-18 02:41:53 +01:00
|
|
|
format: state.format,
|
2016-12-09 23:07:42 +01:00
|
|
|
isMarkdownFormat: Selectors.isMarkdownFormat(state),
|
2016-12-15 01:06:14 +01:00
|
|
|
saveStatus: state.saveStatus
|
2016-11-28 18:47:47 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
onSetPlaintextFormat: (format) => dispatch(Actions.setPlaintextFormat()),
|
2017-01-18 02:41:53 +01:00
|
|
|
onSetMarkdownFormat: (format) => dispatch(Actions.setMarkdownFormat()),
|
2016-12-15 01:06:14 +01:00
|
|
|
|
2017-01-18 02:41:53 +01:00
|
|
|
// returns an id for the record to be saved
|
|
|
|
onCompare: () => dispatch(Actions.compare())
|
2016-11-28 18:47:47 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
class MainControls extends React.Component {
|
|
|
|
|
2017-01-18 02:41:53 +01:00
|
|
|
onClickMarkdownFormat () {
|
|
|
|
if (this.props.isMarkdownFormat) {
|
2016-11-28 18:47:47 +01:00
|
|
|
this.props.onSetPlaintextFormat()
|
2017-01-18 02:41:53 +01:00
|
|
|
} else {
|
2016-11-28 18:47:47 +01:00
|
|
|
this.props.onSetMarkdownFormat()
|
2017-01-18 02:41:53 +01:00
|
|
|
}
|
2016-11-28 18:47:47 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 02:41:53 +01:00
|
|
|
render () {
|
2016-11-28 18:47:47 +01:00
|
|
|
return (
|
2016-11-30 20:57:35 +01:00
|
|
|
<Segment.Group>
|
|
|
|
<Segment >
|
2016-12-17 06:26:04 +01:00
|
|
|
<Button fluid onClick={this.props.onCompare}>Compare</Button>
|
2016-11-30 20:57:35 +01:00
|
|
|
</Segment>
|
|
|
|
|
|
|
|
<Segment >
|
2017-01-18 02:41:53 +01:00
|
|
|
<Button fluid active={this.props.isMarkdownFormat} type='submit' onClick={this.onClickMarkdownFormat.bind(this)}>
|
|
|
|
{this.props.isMarkdownFormat ? <Icon name='checkmark' /> : <span />}
|
2016-11-30 20:57:35 +01:00
|
|
|
As Markdown
|
|
|
|
</Button>
|
|
|
|
</Segment>
|
|
|
|
</Segment.Group>
|
2016-11-28 18:47:47 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(MainControls)
|
|
|
|
|
|
|
|
/*
|
2017-01-18 02:41:53 +01:00
|
|
|
<a type="button" onClick={this.onClickCompare.bind(this)} className="btn btn-block btn-primary">compare</a> */
|