import * as React from 'react' import { withTranslation } from 'react-i18next' import { inject, observer } from 'mobx-react' import { storeKeys } from '@lib/createStore' import { Modal, Input, Row, Col, Alert } from '@components' import { BaseProps, I18nProps } from '@models' import './style.scss' interface ExternalControllerModalProps extends I18nProps, BaseProps {} interface ExternalControllerModalState { hostname: string port: string secret: string } @inject(...storeKeys) @observer class ExternalController extends React.Component { state = { hostname: '', port: '', secret: '' } private handleOk = () => { const { hostname, port, secret } = this.state this.props.store.updateAPIInfo({ hostname, port, secret }) } private handleCancel = () => { this.props.store.setShowAPIModal(false) } async componentWillMount () { await this.props.store.fetchAPIInfo() const info = this.props.store.apiInfo this.setState({ hostname: info.hostname, port: info.port, secret: info.secret }) } render () { const { t } = this.props const { hostname, port, secret } = this.state const show = this.props.store.showAPIModal return (

{t('externalControllerSetting.note')}

{t('externalControllerSetting.host')} this.setState({ hostname })} /> {t('externalControllerSetting.port')} this.setState({ port })} /> {t('externalControllerSetting.secret')} this.setState({ secret })} />
) } } export default withTranslation(['Settings'])(ExternalController)