badguardhome/client/src/components/Settings/Upstream.js

98 lines
3.8 KiB
JavaScript
Raw Normal View History

2018-08-30 14:25:33 +00:00
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
2018-10-25 10:33:44 +00:00
import { Trans, withNamespaces } from 'react-i18next';
2018-08-30 14:25:33 +00:00
import Card from '../ui/Card';
2018-10-25 10:33:44 +00:00
class Upstream extends Component {
2018-08-30 14:25:33 +00:00
handleChange = (e) => {
const { value } = e.currentTarget;
this.props.handleUpstreamChange(value);
};
handleSubmit = (e) => {
e.preventDefault();
this.props.handleUpstreamSubmit();
};
handleTest = () => {
this.props.handleUpstreamTest();
}
2018-08-30 14:25:33 +00:00
render() {
const testButtonClass = classnames({
'btn btn-primary btn-standart mr-2': true,
'btn btn-primary btn-standart mr-2 btn-loading': this.props.processingTestUpstream,
});
2018-10-25 10:33:44 +00:00
const { t } = this.props;
2018-08-30 14:25:33 +00:00
return (
<Card
2018-11-09 06:51:28 +00:00
title={ t('upstream_dns') }
subtitle={ t('upstream_dns_hint') }
2018-08-30 14:25:33 +00:00
bodyType="card-body box-body--settings"
>
<div className="row">
<div className="col">
<form>
<textarea
className="form-control form-control--textarea"
value={this.props.upstreamDns}
2018-08-30 14:25:33 +00:00
onChange={this.handleChange}
/>
<div className="card-actions">
<button
className={testButtonClass}
type="button"
onClick={this.handleTest}
>
2018-11-09 06:51:28 +00:00
<Trans>test_upstream_btn</Trans>
</button>
2018-08-30 14:25:33 +00:00
<button
className="btn btn-success btn-standart"
type="submit"
onClick={this.handleSubmit}
>
2018-11-09 06:51:28 +00:00
<Trans>apply_btn</Trans>
2018-08-30 14:25:33 +00:00
</button>
</div>
</form>
2018-11-26 12:00:17 +00:00
<hr/>
<div className="list leading-loose">
<Trans>examples_title</Trans>:
<ol className="leading-loose">
<li>
<code>1.1.1.1</code> - { t('example_upstream_regular') }
</li>
<li>
2018-11-26 12:12:04 +00:00
<code>tls://1dot1dot1dot1.cloudflare-dns.com</code> - <span dangerouslySetInnerHTML={{ __html: t('example_upstream_dot') }} />
2018-11-26 12:00:17 +00:00
</li>
<li>
2018-11-26 12:12:04 +00:00
<code>https://cloudflare-dns.com/dns-query</code> - <span dangerouslySetInnerHTML={{ __html: t('example_upstream_doh') }} />
2018-11-26 12:00:17 +00:00
</li>
<li>
<code>tcp://1.1.1.1</code> - { t('example_upstream_tcp') }
</li>
<li>
<code>sdns://...</code> - <span dangerouslySetInnerHTML={{ __html: t('example_upstream_sdns') }} />
</li>
2018-11-26 12:00:17 +00:00
</ol>
</div>
2018-08-30 14:25:33 +00:00
</div>
</div>
</Card>
);
}
}
Upstream.propTypes = {
upstreamDns: PropTypes.string,
processingTestUpstream: PropTypes.bool,
2018-08-30 14:25:33 +00:00
handleUpstreamChange: PropTypes.func,
handleUpstreamSubmit: PropTypes.func,
handleUpstreamTest: PropTypes.func,
2018-10-25 10:33:44 +00:00
t: PropTypes.func,
2018-08-30 14:25:33 +00:00
};
2018-10-25 10:33:44 +00:00
export default withNamespaces()(Upstream);