Close #1770
Squashed commit of the following:
commit c1f75ea643623af78de020bd1bc49aa5b66e25c4
Merge: a5df78ad a869ec4c
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Wed Jun 10 18:56:24 2020 +0300
Merge branch 'master' into fix/1770
commit a5df78ad303305efcafcfa2a170ff567a3a06db5
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Wed Jun 10 12:50:50 2020 +0300
Revert "Update locales"
This reverts commit 4b2b4499dea12949c53bce4ceeed595c17df84c6.
commit 4b2b4499dea12949c53bce4ceeed595c17df84c6
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Tue Jun 9 19:56:34 2020 +0300
Update locales
commit 790cff0db84b5905362d2e2702b2cbca5c3c90b0
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Jun 5 17:56:01 2020 +0300
Update Upstream component with new api, extract reduxForm HOC names in constant
commit 72de3d5a92cc33d5b234c837879fc6990291e07b
Merge: 92a4a6ae 501a4e06
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Jun 5 15:55:39 2020 +0300
Merge remote-tracking branch 'origin/update-dnsproxy' into fix/1770
commit 501a4e06ab350e46ff78656141d925de9f2e4996
Author: Simon Zolin <s.zolin@adguard.com>
Date: Fri Jun 5 12:47:13 2020 +0300
openapi
commit 3930bd196572924f164ed011629356a0ac0ec631
Author: Simon Zolin <s.zolin@adguard.com>
Date: Fri Jun 5 12:21:32 2020 +0300
* DNS API: new setting "upstream_mode"; remove "fastest_addr", "parallel_requests"
* use dnsproxy v0.29.0
commit 92a4a6ae24793a2a9ca05ad3ef2078573fd4d059
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu Jun 4 18:53:42 2020 +0300
- client: Add default mode in the DNS settings
110 lines
3.4 KiB
JavaScript
110 lines
3.4 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Field, reduxForm } from 'redux-form';
|
|
import { withTranslation, Trans } from 'react-i18next';
|
|
import flow from 'lodash/flow';
|
|
|
|
import i18n from '../../i18n';
|
|
import Controls from './Controls';
|
|
import { renderInputField } from '../../helpers/form';
|
|
import { FORM_NAME } from '../../helpers/constants';
|
|
|
|
const required = (value) => {
|
|
if (value || value === 0) {
|
|
return false;
|
|
}
|
|
return <Trans>form_error_required</Trans>;
|
|
};
|
|
|
|
const validate = (values) => {
|
|
const errors = {};
|
|
|
|
if (values.confirm_password !== values.password) {
|
|
errors.confirm_password = i18n.t('form_error_password');
|
|
}
|
|
|
|
return errors;
|
|
};
|
|
|
|
const Auth = (props) => {
|
|
const {
|
|
handleSubmit,
|
|
pristine,
|
|
invalid,
|
|
t,
|
|
} = props;
|
|
|
|
return (
|
|
<form className="setup__step" onSubmit={handleSubmit}>
|
|
<div className="setup__group">
|
|
<div className="setup__subtitle">
|
|
<Trans>install_auth_title</Trans>
|
|
</div>
|
|
<p className="setup__desc">
|
|
<Trans>install_auth_desc</Trans>
|
|
</p>
|
|
<div className="form-group">
|
|
<label>
|
|
<Trans>install_auth_username</Trans>
|
|
</label>
|
|
<Field
|
|
name="username"
|
|
component={renderInputField}
|
|
type="text"
|
|
className="form-control"
|
|
placeholder={ t('install_auth_username_enter') }
|
|
validate={[required]}
|
|
autoComplete="username"
|
|
/>
|
|
</div>
|
|
<div className="form-group">
|
|
<label>
|
|
<Trans>install_auth_password</Trans>
|
|
</label>
|
|
<Field
|
|
name="password"
|
|
component={renderInputField}
|
|
type="password"
|
|
className="form-control"
|
|
placeholder={ t('install_auth_password_enter') }
|
|
validate={[required]}
|
|
autoComplete="new-password"
|
|
/>
|
|
</div>
|
|
<div className="form-group">
|
|
<label>
|
|
<Trans>install_auth_confirm</Trans>
|
|
</label>
|
|
<Field
|
|
name="confirm_password"
|
|
component={renderInputField}
|
|
type="password"
|
|
className="form-control"
|
|
placeholder={ t('install_auth_confirm') }
|
|
validate={[required]}
|
|
autoComplete="new-password"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<Controls pristine={pristine} invalid={invalid} />
|
|
</form>
|
|
);
|
|
};
|
|
|
|
Auth.propTypes = {
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
pristine: PropTypes.bool.isRequired,
|
|
invalid: PropTypes.bool.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default flow([
|
|
withTranslation(),
|
|
reduxForm({
|
|
form: FORM_NAME.INSTALL,
|
|
destroyOnUnmount: false,
|
|
forceUnregisterOnUnmount: true,
|
|
validate,
|
|
}),
|
|
])(Auth);
|