From 0ea0233c50dbccc498cb53481b9fdf18d027e5b2 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Sep 2015 13:56:58 -0400 Subject: New add channel modal using react-bootstrap. --- web/react/components/new_channel_modal.jsx | 198 +++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 web/react/components/new_channel_modal.jsx (limited to 'web/react/components/new_channel_modal.jsx') diff --git a/web/react/components/new_channel_modal.jsx b/web/react/components/new_channel_modal.jsx new file mode 100644 index 000000000..2bf645dc5 --- /dev/null +++ b/web/react/components/new_channel_modal.jsx @@ -0,0 +1,198 @@ +// 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'} + + {')'} +

+
+
+
+
+ + +
+
+