// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Utils from '../utils/utils.jsx'; import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl'; var Modal = ReactBootstrap.Modal; const holders = defineMessages({ nameEx: { id: 'channel_modal.nameEx', defaultMessage: 'E.g.: "Bugs", "Marketing", "办公室恋情"' } }); 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: '' }); } } componentDidMount() { if (Utils.isBrowserIE()) { $('body').addClass('browser--IE'); } } handleSubmit(e) { e.preventDefault(); const displayName = ReactDOM.findDOMNode(this.refs.display_name).value.trim(); if (displayName.length < 1) { this.setState({displayNameError: true}); return; } this.props.onSubmitChannel(); } handleChange() { const newData = { displayName: ReactDOM.findDOMNode(this.refs.display_name).value, purpose: ReactDOM.findDOMNode(this.refs.channel_purpose).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}

; } var channelTerm = ''; var channelSwitchText = ''; switch (this.props.channelType) { case 'P': channelTerm = ( ); channelSwitchText = (
); break; case 'O': channelTerm = ( ); channelSwitchText = (
); break; } const prettyTeamURL = Utils.getShortenedTeamURL(); return ( {channelTerm}
{channelSwitchText}
{displayNameError}

{'URL: ' + prettyTeamURL + this.props.channelData.name + ' ('} {')'}