// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. const Utils = require('../utils/utils.jsx'); var Modal = ReactBootstrap.Modal; export default class NewChannelModal extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); this.handleChange = this.handleChange.bind(this); this.state = { displayNameError: '' }; } componentWillReceiveProps(nextProps) { if (nextProps.show === true && this.props.show === false) { this.setState({ displayNameError: '' }); } } handleSubmit(e) { e.preventDefault(); const displayName = ReactDOM.findDOMNode(this.refs.display_name).value.trim(); if (displayName.length < 1) { this.setState({displayNameError: 'This field is required'}); return; } this.props.onSubmitChannel(); } handleChange() { const newData = { displayName: ReactDOM.findDOMNode(this.refs.display_name).value, description: ReactDOM.findDOMNode(this.refs.channel_desc).value }; this.props.onDataChanged(newData); } render() { var displayNameError = null; var serverError = null; var displayNameClass = 'form-group'; if (this.state.displayNameError) { displayNameError =
{this.state.displayNameError}
; displayNameClass += ' has-error'; } if (this.props.serverError) { serverError ={this.props.serverError}