// Tinode config panel. import React from 'react'; import { FormattedMessage } from 'react-intl'; import CheckBox from '../widgets/checkbox.jsx'; import HostSelector from '../widgets/host-selector.jsx'; export default class SettingsView extends React.PureComponent { constructor(props) { super(props); this.state = { transport: props.transport || 'def', serverAddress: props.serverAddress, secureConnection: props.secureConnection, }; this.handleSubmit = this.handleSubmit.bind(this); this.handleTransportSelected = this.handleTransportSelected.bind(this); this.handleServerAddressChange = this.handleServerAddressChange.bind(this); this.handleToggleSecure = this.handleToggleSecure.bind(this); } handleSubmit(e) { e.preventDefault(); this.props.onUpdate({ transport: this.state.transport, serverAddress: this.state.serverAddress, secureConnection: this.state.secureConnection, }); } handleTransportSelected(e) { this.setState({transport: e.currentTarget.value}); } handleServerAddressChange(name) { this.setState({serverAddress: name}); } handleToggleSecure(e) { this.setState({secureConnection: !this.state.secureConnection}); } render() { const names = {def: "default", ws: "websocket", lp: "long polling"}; const transportOptions = []; ['def', 'ws', 'lp'].forEach(item => { const id = 'transport-' + item; const name = names[item]; transportOptions.push(