Refactor HipchatConfig.

pull/1887/head
Hunter Trujillo 2017-08-15 16:34:51 -06:00 committed by Andrew Watkins
parent d23dd6a82c
commit a92b1eb95a
1 changed files with 25 additions and 19 deletions

View File

@ -1,24 +1,15 @@
import React, {PropTypes} from 'react' import React, {PropTypes, Component} from 'react'
import QuestionMarkTooltip from 'shared/components/QuestionMarkTooltip' import QuestionMarkTooltip from 'shared/components/QuestionMarkTooltip'
import {HIPCHAT_TOKEN_TIP} from 'src/kapacitor/copy' import {HIPCHAT_TOKEN_TIP} from 'src/kapacitor/copy'
import RedactedInput from './RedactedInput' import RedactedInput from './RedactedInput'
const {bool, func, shape, string} = PropTypes class HipchatConfig extends Component {
constructor(props) {
super(props)
}
const HipchatConfig = React.createClass({ handleSaveAlert = e => {
propTypes: {
config: shape({
options: shape({
room: string.isRequired,
token: bool.isRequired,
url: string.isRequired,
}).isRequired,
}).isRequired,
onSave: func.isRequired,
},
handleSaveAlert(e) {
e.preventDefault() e.preventDefault()
const properties = { const properties = {
@ -28,7 +19,9 @@ const HipchatConfig = React.createClass({
} }
this.props.onSave(properties) this.props.onSave(properties)
}, }
handleTokenRef = r => (this.token = r)
render() { render() {
const {options} = this.props.config const {options} = this.props.config
@ -72,7 +65,7 @@ const HipchatConfig = React.createClass({
<RedactedInput <RedactedInput
defaultValue={token} defaultValue={token}
id="token" id="token"
refFunc={r => (this.token = r)} refFunc={this.handleTokenRef}
/> />
</div> </div>
@ -83,7 +76,20 @@ const HipchatConfig = React.createClass({
</div> </div>
</form> </form>
) )
}, }
}) }
const {bool, func, shape, string} = PropTypes
HipchatConfig.propTypes = {
config: shape({
options: shape({
room: string.isRequired,
token: bool.isRequired,
url: string.isRequired,
}).isRequired,
}).isRequired,
onSave: func.isRequired,
}
export default HipchatConfig export default HipchatConfig