Add clear topic button

Resolves #29
This commit is contained in:
Thomas Nordquist
2019-01-18 10:21:20 +01:00
parent 8a72a0224d
commit 96c7c56f64

View File

@@ -16,6 +16,10 @@ import {
RadioGroup, RadioGroup,
TextField, TextField,
Typography, Typography,
IconButton,
FormControl,
InputLabel,
Input,
} from '@material-ui/core' } from '@material-ui/core'
import { makePublishEvent, rendererEvents } from '../../../../../events' import { makePublishEvent, rendererEvents } from '../../../../../events'
@@ -24,6 +28,7 @@ import { AppState } from '../../../reducers'
import History from '../History' import History from '../History'
import Message from './Model/Message' import Message from './Model/Message'
import Navigation from '@material-ui/icons/Navigation' import Navigation from '@material-ui/icons/Navigation'
import Clear from '@material-ui/icons/Clear'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { sidebarActions } from '../../../actions' import { sidebarActions } from '../../../actions'
@@ -96,21 +101,28 @@ class Publish extends React.Component<Props, State> {
return (topic !== undefined) ? topic : selectedNodePath return (topic !== undefined) ? topic : selectedNodePath
} }
private clearTopic = () => {
this.props.actions.setPublishTopic(undefined)
}
private topic() { private topic() {
const topicStr = this.currentTopic() || '' const topicStr = this.currentTopic() || ''
return ( return (
<div> <div>
<Typography>Topic</Typography> <FormControl style={{ width: '100%' }}>
<TextField <InputLabel htmlFor="publish-topic">Topic</InputLabel>
placeholder="example/topic" <Input
style={{ width: '100%' }} id="publish-topic"
margin="normal"
value={topicStr} value={topicStr}
multiline={true} startAdornment={<span/>}
endAdornment={<IconButton style={{ padding: '4px' }} onClick={this.clearTopic}><Clear style={{ fontSize: '14px' }} /></IconButton>}
onBlur={this.onTopicBlur}
onChange={this.updateTopic} onChange={this.updateTopic}
InputProps={{ onBlur: this.onTopicBlur }} multiline={true}
placeholder="example/topic"
/> />
</FormControl>
</div> </div>
) )
} }