import React from 'react'; import ChannelLoginForm from '../ChannelLoginForm'; import ChannelCreateForm from '../ChannelCreateForm'; const LOGIN = 'Existing'; const CREATE = 'New'; class ChannelSelect extends React.Component { constructor (props) { super(props); this.state = { selectedOption: LOGIN, }; this.toggleAnonymousPublish = this.toggleAnonymousPublish.bind(this); this.handleSelection = this.handleSelection.bind(this); this.selectOption = this.selectOption.bind(this); } componentWillMount () { console.log('ChannelSelector will mount'); if (this.props.loggedInChannelName) { this.selectOption(this.props.loggedInChannelName); } } componentWillReceiveProps ({ loggedInChannelName }) { if (loggedInChannelName) { this.selectOption(loggedInChannelName); } } toggleAnonymousPublish (event) { const value = event.target.value; if (value === 'anonymous') { this.props.onPublishInChannelChange(false); } else { this.props.onPublishInChannelChange(true); } } handleSelection (event) { const selectedOption = event.target.selectedOptions[0].value; this.selectOption(selectedOption); } selectOption (option) { this.setState({selectedOption: option}); } render () { return (
{this.props.channelError}