// Copyright (c) 2015 Spinpunch, 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 = React.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: React.findDOMNode(this.refs.display_name).value, description: React.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}

; } var channelTerm = ''; var channelSwitchText = ''; switch (this.props.channelType) { case 'P': channelTerm = 'Group'; channelSwitchText = (
{'Create a new private group with restricted membership. '} {'Create a public channel'}
); break; case 'O': channelTerm = 'Channel'; channelSwitchText = (
{'Create a new public channel anyone can join. '} {'Create a private group'}
); break; } const prettyTeamURL = Utils.getShortenedTeamURL(); return ( {'New ' + channelTerm}
{channelSwitchText}
{displayNameError}

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