// @flow import React from 'react'; import { Layout, Container, Header } from './Layout'; import CustomScrollbars from './CustomScrollbars'; export class AdvancedSettings extends React.Component { props: { protocol: string, port: string | number, onUpdate: (protocol: string, port: string | number) => void, onClose: () => void, }; render() { let portSelector = null; let protocol = this.props.protocol.toUpperCase(); if (protocol === 'AUTOMATIC') { protocol = 'Automatic'; } else { portSelector = this._createPortSelector(); } return { this.props.onUpdate(protocol, 'Automatic'); }}/>
{ portSelector }
; } _createPortSelector() { const protocol = this.props.protocol.toUpperCase(); const ports = protocol === 'TCP' ? ['Automatic', 80, 443] : ['Automatic', 1194, 1195, 1196, 1197, 1300, 1301, 1302]; return { this.props.onUpdate(protocol, port); }} />; } } class Selector extends React.Component { props: { title: string, values: Array<*>, value: *, onSelect: (*) => void, } render() { return
{ this.props.title }
{ this.props.values.map(value => this._renderCell(value)) }
; } _renderCell(value) { const selected = value === this.props.value; if (selected) { return this._renderSelectedCell(value); } else { return this._renderUnselectedCell(value); } } _renderSelectedCell(value) { const onCellClick = () => this.props.onSelect(value); return
{ value }
; } _renderUnselectedCell(value) { const onCellClick = () => this.props.onSelect(value); return
{ value }
; } } function BaseLayout(props) { return