diff --git a/ui/src/kapacitor/components/config/OpsGenieConfig.js b/ui/src/kapacitor/components/config/OpsGenieConfig.js index 3566adb56..e65003262 100644 --- a/ui/src/kapacitor/components/config/OpsGenieConfig.js +++ b/ui/src/kapacitor/components/config/OpsGenieConfig.js @@ -1,31 +1,21 @@ -import React, {PropTypes} from 'react' +import React, {PropTypes, Component} from 'react' import _ from 'lodash' import RedactedInput from './RedactedInput' -const {array, arrayOf, bool, func, shape, string} = PropTypes +class OpsGenieConfig extends Component { + constructor(props) { + super(props) -const OpsGenieConfig = React.createClass({ - propTypes: { - config: shape({ - options: shape({ - 'api-key': bool, - teams: array, - recipients: array, - }).isRequired, - }).isRequired, - onSave: func.isRequired, - }, + const {teams, recipients} = props.config.options - getInitialState() { - const {teams, recipients} = this.props.config.options - return { + this.state = { currentTeams: teams || [], currentRecipients: recipients || [], } - }, + } - handleSaveAlert(e) { + handleSaveAlert = e => { e.preventDefault() const properties = { @@ -35,31 +25,33 @@ const OpsGenieConfig = React.createClass({ } this.props.onSave(properties) - }, + } - handleAddTeam(team) { + handleAddTeam = team => { this.setState({currentTeams: this.state.currentTeams.concat(team)}) - }, + } - handleAddRecipient(recipient) { + handleAddRecipient = recipient => { this.setState({ currentRecipients: this.state.currentRecipients.concat(recipient), }) - }, + } - handleDeleteTeam(team) { + handleDeleteTeam = team => () => { this.setState({ currentTeams: this.state.currentTeams.filter(t => t !== team), }) - }, + } - handleDeleteRecipient(recipient) { + handleDeleteRecipient = recipient => () => { this.setState({ currentRecipients: this.state.currentRecipients.filter( r => r !== recipient ), }) - }, + } + + handleApiKeyRef = r => (this.apiKey = r) render() { const {options} = this.props.config @@ -73,7 +65,7 @@ const OpsGenieConfig = React.createClass({ (this.apiKey = r)} + refFunc={this.handleApiKeyRef} />