Update RuleMessage to remove anyonymous functions from props

pull/1887/head
Andrew Watkins 2017-08-15 17:33:38 -07:00
parent f29db011e5
commit a70014352e
2 changed files with 13 additions and 7 deletions

View File

@ -12,9 +12,12 @@ class RuleMessageTemplates extends Component {
super(props) super(props)
} }
render() { handleClickTemplate = template => () => {
const {rule, updateMessage} = this.props const {updateMessage, rule} = this.props
updateMessage(rule.id, `${rule.message} ${template.label}`)
}
render() {
return ( return (
<div className="rule-section--row rule-section--row-last rule-section--border-top"> <div className="rule-section--row rule-section--row-last rule-section--border-top">
<p>Templates:</p> <p>Templates:</p>
@ -23,8 +26,7 @@ class RuleMessageTemplates extends Component {
<CodeData <CodeData
key={key} key={key}
template={template} template={template}
onClickTemplate={() => onClickTemplate={this.handleClickTemplate(template)}
updateMessage(rule.id, `${rule.message} ${template.label}`)}
/> />
) )
})} })}

View File

@ -5,14 +5,18 @@ class RuleMessageText extends Component {
super(props) super(props)
} }
render() { handleChange = e => {
const {rule, updateMessage} = this.props const {rule, updateMessage} = this.props
updateMessage(rule, e.targe.value)
}
render() {
const {rule} = this.props
return ( return (
<textarea <textarea
className="form-control form-malachite monotype rule-builder--message" className="form-control form-malachite monotype rule-builder--message"
ref={r => (this.message = r)} onChange={this.handleChange}
onChange={() => updateMessage(rule.id, this.message.value)}
placeholder="Example: {{ .ID }} is {{ .Level }} value: {{ index .Fields &quot;value&quot; }}" placeholder="Example: {{ .ID }} is {{ .Level }} value: {{ index .Fields &quot;value&quot; }}"
value={rule.message} value={rule.message}
spellCheck={false} spellCheck={false}