From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- webapp/components/new_channel_modal.jsx | 288 ++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 webapp/components/new_channel_modal.jsx (limited to 'webapp/components/new_channel_modal.jsx') diff --git a/webapp/components/new_channel_modal.jsx b/webapp/components/new_channel_modal.jsx new file mode 100644 index 000000000..628687f27 --- /dev/null +++ b/webapp/components/new_channel_modal.jsx @@ -0,0 +1,288 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import $ from 'jquery'; +import ReactDOM from 'react-dom'; +import * as Utils from 'utils/utils.jsx'; + +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl'; + +import {Modal} from 'react-bootstrap'; + +const holders = defineMessages({ + nameEx: { + id: 'channel_modal.nameEx', + defaultMessage: 'E.g.: "Bugs", "Marketing", "办公室恋情"' + } +}); + +import React from 'react'; + +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 + ' ('} + + + + {')'} +

+
+
+
+
+ + +
+
+