badguardhome/client/src/components/App/index.js

152 lines
5.8 KiB
JavaScript
Raw Normal View History

2018-08-30 14:25:33 +00:00
import React, { Component, Fragment } from 'react';
import { HashRouter, Route } from 'react-router-dom';
import PropTypes from 'prop-types';
+ client: Update packages - Merge pull request #613 in DNS/adguard-home from fix/1597 to master Close #1597 Squashed commit of the following: commit 1eb89586dd71260e561420fe669abc8b56a506a1 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed May 20 14:54:10 2020 +0300 Fix translation in install options commit 1ebdc9ebfe12a609f978e47db6505c7095b10f7e Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed May 20 13:11:34 2020 +0300 Remove commented code commit 2a8302c65a2a3cf7b6b1596115d1153dac32a794 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 19:02:49 2020 +0300 Update i18n packages, add development browserlist, downgrade eslint to match peerDepencancies version commit 3fcf73fb14cd9da508522d1a300b66af24da95e5 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 17:30:37 2020 +0300 Remove all unused dependencies commit e761810e3e54e188ada41245bdce7414cd0f03e8 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 16:35:24 2020 +0300 Remove unused dependencies commit d89d27da6befcaabcdc12bf5e7e94cbb24140010 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 16:14:09 2020 +0300 Update regular dependencies commit d2dfd01233d059870d5173ffd748cf61a477936f Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 15:34:10 2020 +0300 Update all dev dependancies commit 02b6fb480e9d310039fbe9b7aae062a41128f070 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 14:14:44 2020 +0300 Update all postcss packages commit 5e1fa5f99ad75f77e5e429b28ee1ca0b5e65a9a0 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:45:02 2020 +0300 Prevent git from converting linebreaks in .js files commit 0b9b3b0dccd47cfa50c9531fb61729e6b5a04523 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:43:01 2020 +0300 Prevent git from converting linebreaks in .js files commit 18b7495e9ef7130b1ac4dbba84c54127d16c6350 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:24:47 2020 +0300 Remove linebreak-style eslint rule commit df893dec53adebb1d662fe805fab508fd4ed5e06 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 20:55:47 2020 +0300 Add prop types commit 36178ecfc5c7fa11a6ee08d7705ca8560941af40 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 18:52:07 2020 +0300 Update eslint and babel, fix eslint warnings commit f045b4a2e6b9b78f7e88e3b5d1419c29966a8230 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 16:45:49 2020 +0300 Update css loading webpack rules commit 247fa1ed548ef0706a03fdada8309c1454d191f8 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 16:13:49 2020 +0300 Suppress linebreak-style eslint error for Windows commit d6499aac507100d6918c849c06d739d80f2229f0 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 14:55:07 2020 +0300 Suppress eslint exit code commit ae2d6c614ea23a90d515168f8752e959298894ef Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 14:05:18 2020 +0300 Edit css file warnings commit 60675050f2a5baebc679fc05da7e033e5c740d90 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 13:10:26 2020 +0300 Remove uglifyjs plugin commit a27806434dd8672e71a26c7a2e810d77e5e229fa Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 01:29:17 2020 +0300 Fix DefinePlugin value commit 8f2966ca59195c2f70bca5072d20515d536f42a6 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 01:05:03 2020 +0300 Update webpack
2020-05-22 14:06:05 +00:00
import { withTranslation } from 'react-i18next';
import LoadingBar from 'react-redux-loading-bar';
2018-08-30 14:25:33 +00:00
import 'react-table/react-table.css';
import '../ui/Tabler.css';
import '../ui/ReactTable.css';
import './index.css';
import Header from '../../containers/Header';
import Dashboard from '../../containers/Dashboard';
import Settings from '../../containers/Settings';
import CustomRules from '../../containers/CustomRules';
import DnsBlocklist from '../../containers/DnsBlocklist';
import DnsAllowlist from '../../containers/DnsAllowlist';
import DnsRewrites from '../../containers/DnsRewrites';
import Dns from '../../containers/Dns';
import Encryption from '../../containers/Encryption';
import Dhcp from '../../containers/Dhcp';
import Clients from '../../containers/Clients';
2018-08-30 14:25:33 +00:00
import Logs from '../../containers/Logs';
import SetupGuide from '../../containers/SetupGuide';
2018-09-14 12:37:35 +00:00
import Toasts from '../Toasts';
import Footer from '../ui/Footer';
2018-08-30 14:25:33 +00:00
import Status from '../ui/Status';
2019-02-20 13:54:14 +00:00
import UpdateTopline from '../ui/UpdateTopline';
2019-05-16 14:24:30 +00:00
import UpdateOverlay from '../ui/UpdateOverlay';
import EncryptionTopline from '../ui/EncryptionTopline';
2019-05-23 09:32:51 +00:00
import Icons from '../ui/Icons';
2018-11-22 14:56:57 +00:00
import i18n from '../../i18n';
import Loading from '../ui/Loading';
2018-08-30 14:25:33 +00:00
class App extends Component {
componentDidMount() {
this.props.getDnsStatus();
}
2018-11-22 14:56:57 +00:00
componentDidUpdate(prevProps) {
if (this.props.dashboard.language !== prevProps.dashboard.language) {
this.setLanguage();
}
}
reloadPage = () => {
window.location.reload();
2018-08-30 14:25:33 +00:00
};
2019-05-16 14:24:30 +00:00
handleUpdate = () => {
this.props.getUpdate();
};
2019-05-16 14:24:30 +00:00
2018-11-22 14:56:57 +00:00
setLanguage = () => {
const { processing, language } = this.props.dashboard;
if (!processing) {
if (language) {
2018-11-22 14:56:57 +00:00
i18n.changeLanguage(language);
}
}
i18n.on('languageChanged', (lang) => {
this.props.changeLanguage(lang);
});
};
2018-11-22 14:56:57 +00:00
2018-08-30 14:25:33 +00:00
render() {
2019-09-05 16:07:14 +00:00
const { dashboard, encryption, getVersion } = this.props;
2019-06-25 14:56:50 +00:00
const updateAvailable = dashboard.isCoreRunning && dashboard.isUpdateAvailable;
2018-09-21 12:20:41 +00:00
2018-08-30 14:25:33 +00:00
return (
<HashRouter hashType="noslash">
2018-08-30 14:25:33 +00:00
<Fragment>
{updateAvailable && (
2019-05-16 14:24:30 +00:00
<Fragment>
<UpdateTopline
url={dashboard.announcementUrl}
version={dashboard.newVersion}
canAutoUpdate={dashboard.canAutoUpdate}
getUpdate={this.handleUpdate}
processingUpdate={dashboard.processingUpdate}
/>
<UpdateOverlay processingUpdate={dashboard.processingUpdate} />
</Fragment>
)}
{!encryption.processing && (
<EncryptionTopline notAfter={encryption.not_after} />
)}
<LoadingBar className="loading-bar" updateTime={1000} />
2018-08-30 14:25:33 +00:00
<Route component={Header} />
<div className="container container--wrap">
{dashboard.processing && <Loading />}
{!dashboard.isCoreRunning && (
2018-08-30 14:25:33 +00:00
<div className="row row-cards">
<div className="col-lg-12">
<Status reloadPage={this.reloadPage}
message="dns_start"
/>
<Loading />
2018-08-30 14:25:33 +00:00
</div>
</div>
)}
{!dashboard.processing && dashboard.isCoreRunning && (
2018-08-30 14:25:33 +00:00
<Fragment>
<Route path="/" exact component={Dashboard} />
<Route path="/settings" component={Settings} />
<Route path="/dns" component={Dns} />
<Route path="/encryption" component={Encryption} />
<Route path="/dhcp" component={Dhcp} />
<Route path="/clients" component={Clients} />
<Route path="/filters" component={DnsBlocklist} />
<Route path="/dns_allowlists" component={DnsAllowlist} />
<Route path="/dns_rewrites" component={DnsRewrites} />
<Route path="/custom_rules" component={CustomRules} />
2018-08-30 14:25:33 +00:00
<Route path="/logs" component={Logs} />
<Route path="/guide" component={SetupGuide} />
2018-08-30 14:25:33 +00:00
</Fragment>
)}
2018-08-30 14:25:33 +00:00
</div>
2019-09-05 16:07:14 +00:00
<Footer
dnsVersion={dashboard.dnsVersion}
dnsPort={dashboard.dnsPort}
processingVersion={dashboard.processingVersion}
getVersion={getVersion}
checkUpdateFlag={dashboard.checkUpdateFlag}
2019-09-05 16:07:14 +00:00
/>
2018-09-14 12:37:35 +00:00
<Toasts />
2019-05-23 09:32:51 +00:00
<Icons />
2018-08-30 14:25:33 +00:00
</Fragment>
</HashRouter>
);
}
}
App.propTypes = {
getDnsStatus: PropTypes.func,
2019-05-16 14:24:30 +00:00
getUpdate: PropTypes.func,
2018-08-30 14:25:33 +00:00
enableDns: PropTypes.func,
dashboard: PropTypes.object,
isCoreRunning: PropTypes.bool,
2018-09-14 12:37:35 +00:00
error: PropTypes.string,
2018-11-22 14:56:57 +00:00
changeLanguage: PropTypes.func,
encryption: PropTypes.object,
2019-09-05 16:07:14 +00:00
getVersion: PropTypes.func,
2018-08-30 14:25:33 +00:00
};
+ client: Update packages - Merge pull request #613 in DNS/adguard-home from fix/1597 to master Close #1597 Squashed commit of the following: commit 1eb89586dd71260e561420fe669abc8b56a506a1 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed May 20 14:54:10 2020 +0300 Fix translation in install options commit 1ebdc9ebfe12a609f978e47db6505c7095b10f7e Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed May 20 13:11:34 2020 +0300 Remove commented code commit 2a8302c65a2a3cf7b6b1596115d1153dac32a794 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 19:02:49 2020 +0300 Update i18n packages, add development browserlist, downgrade eslint to match peerDepencancies version commit 3fcf73fb14cd9da508522d1a300b66af24da95e5 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 17:30:37 2020 +0300 Remove all unused dependencies commit e761810e3e54e188ada41245bdce7414cd0f03e8 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 16:35:24 2020 +0300 Remove unused dependencies commit d89d27da6befcaabcdc12bf5e7e94cbb24140010 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 16:14:09 2020 +0300 Update regular dependencies commit d2dfd01233d059870d5173ffd748cf61a477936f Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 15:34:10 2020 +0300 Update all dev dependancies commit 02b6fb480e9d310039fbe9b7aae062a41128f070 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 14:14:44 2020 +0300 Update all postcss packages commit 5e1fa5f99ad75f77e5e429b28ee1ca0b5e65a9a0 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:45:02 2020 +0300 Prevent git from converting linebreaks in .js files commit 0b9b3b0dccd47cfa50c9531fb61729e6b5a04523 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:43:01 2020 +0300 Prevent git from converting linebreaks in .js files commit 18b7495e9ef7130b1ac4dbba84c54127d16c6350 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 19 12:24:47 2020 +0300 Remove linebreak-style eslint rule commit df893dec53adebb1d662fe805fab508fd4ed5e06 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 20:55:47 2020 +0300 Add prop types commit 36178ecfc5c7fa11a6ee08d7705ca8560941af40 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 18:52:07 2020 +0300 Update eslint and babel, fix eslint warnings commit f045b4a2e6b9b78f7e88e3b5d1419c29966a8230 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 18 16:45:49 2020 +0300 Update css loading webpack rules commit 247fa1ed548ef0706a03fdada8309c1454d191f8 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 16:13:49 2020 +0300 Suppress linebreak-style eslint error for Windows commit d6499aac507100d6918c849c06d739d80f2229f0 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 14:55:07 2020 +0300 Suppress eslint exit code commit ae2d6c614ea23a90d515168f8752e959298894ef Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 14:05:18 2020 +0300 Edit css file warnings commit 60675050f2a5baebc679fc05da7e033e5c740d90 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 13:10:26 2020 +0300 Remove uglifyjs plugin commit a27806434dd8672e71a26c7a2e810d77e5e229fa Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 01:29:17 2020 +0300 Fix DefinePlugin value commit 8f2966ca59195c2f70bca5072d20515d536f42a6 Author: ArtemBaskal <a.baskal@adguard.com> Date: Sat May 16 01:05:03 2020 +0300 Update webpack
2020-05-22 14:06:05 +00:00
export default withTranslation()(App);