Skip to content

Commit

Permalink
Add topic selection to topic drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Nordquist committed Jan 20, 2019
1 parent 9f48301 commit 3b049d2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/src/components/Sidebar/Topic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import * as React from 'react'
import * as q from '../../../../backend/src/Model'
import Button from '@material-ui/core/Button'
import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles'
import { treeActions } from '../../actions'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

interface Props {
classes: any
theme: Theme
node?: q.TreeNode
selected?: q.TreeNode
actions: typeof treeActions
didSelectNode: (node: q.TreeNode) => void
}

Expand All @@ -33,7 +37,7 @@ class Topic extends React.Component<Props, {}> {
.map(edge =>
[(
<Button
onClick={() => this.setState({ node: edge!.target })}
onClick={() => this.props.actions.selectTopic(edge!.target)}
size="small"
color="secondary"
className={this.props.classes.button}
Expand All @@ -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))

0 comments on commit 3b049d2

Please sign in to comment.