// // A modal popup to add a new provider. // import React from 'react' import { FormGroup, ControlLabel, FormControl, HelpBlock, Button, Modal } from 'react-bootstrap' import Spinner from '../spinner' import Validate from '../../lib/validate' import App from '../../app' class AddProviderModal extends React.Component { static get defaultProps() {return{ title: 'Add a provider', onClose: null }} constructor(props) { super(props) this.state = { validationState: null, errorMsg: null, domain: "" } this.accept = this.accept.bind(this) this.cancel = this.cancel.bind(this) this.changed = this.changed.bind(this) } accept() { if (this.state.domain) { App.providers.add(this.state.domain) } this.props.onClose() } cancel() { this.props.onClose() } changed(e) { let domain = e.target.value let newState = null let newMsg = null if (domain.length > 0) { let error = Validate.domain(domain) newState = error ? 'error' : 'success' newMsg = error } this.setState({ domain: domain, validationState: newState, errorMsg: newMsg }) } render() { let help = null if (this.state.errorMsg) { help = {this.state.errorMsg} } else { help =   } let form =
Domain {help}
return( {this.props.title} {form} ) } } export default AddProviderModal