Add topic selection to topic drawer
This commit is contained in:
@@ -2,12 +2,16 @@ import * as React from 'react'
|
|||||||
import * as q from '../../../../backend/src/Model'
|
import * as q from '../../../../backend/src/Model'
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles'
|
import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles'
|
||||||
|
import { treeActions } from '../../actions'
|
||||||
|
import { bindActionCreators } from 'redux'
|
||||||
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
classes: any
|
classes: any
|
||||||
theme: Theme
|
theme: Theme
|
||||||
node?: q.TreeNode
|
node?: q.TreeNode
|
||||||
selected?: q.TreeNode
|
selected?: q.TreeNode
|
||||||
|
actions: typeof treeActions
|
||||||
didSelectNode: (node: q.TreeNode) => void
|
didSelectNode: (node: q.TreeNode) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +37,7 @@ class Topic extends React.Component<Props, {}> {
|
|||||||
.map(edge =>
|
.map(edge =>
|
||||||
[(
|
[(
|
||||||
<Button
|
<Button
|
||||||
onClick={() => this.setState({ node: edge!.target })}
|
onClick={() => this.props.actions.selectTopic(edge!.target)}
|
||||||
size="small"
|
size="small"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
className={this.props.classes.button}
|
className={this.props.classes.button}
|
||||||
@@ -56,4 +60,10 @@ class Topic extends React.Component<Props, {}> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withStyles(styles, { withTheme: true })(Topic)
|
const mapDispatchToProps = (dispatch: any) => {
|
||||||
|
return {
|
||||||
|
actions: bindActionCreators(treeActions, dispatch),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps)(withStyles(styles, { withTheme: true })(Topic))
|
||||||
|
|||||||
Reference in New Issue
Block a user