// @flow
import * as React from 'react';
import { Component, Text, View } from 'reactxp';
import { Button } from './styled';
import { Layout, Container } from './Layout';
import CustomScrollbars from './CustomScrollbars';
import styles from './AdvancedSettingsStyles';
import Img from './Img';
export class AdvancedSettings extends 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 Component {
props: {
title: string,
values: Array<*>,
value: *,
onSelect: (*) => void,
};
state = { hoveredButtonIndex: -1 };
handleButtonHover = (value) => {
this.setState({ hoveredButtonIndex: value });
};
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) {
return (
);
}
_renderUnselectedCell(value) {
return (
);
}
}
function BaseLayout(props) {
return (
Advanced
{props.children}
);
}