Added button to reset encryption settings
This commit is contained in:
parent
d42718465d
commit
1dd548c36c
|
@ -233,5 +233,6 @@
|
||||||
"topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings</0>.",
|
"topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings</0>.",
|
||||||
"form_error_port_range": "Enter port value in the range of 80-65535",
|
"form_error_port_range": "Enter port value in the range of 80-65535",
|
||||||
"form_error_equal": "Shouldn't be equal",
|
"form_error_equal": "Shouldn't be equal",
|
||||||
"form_error_password": "Password mismatched"
|
"form_error_password": "Password mismatched",
|
||||||
|
"reset_settings": "Reset settings",
|
||||||
}
|
}
|
|
@ -4,15 +4,17 @@ import { Field, reduxForm } from 'redux-form';
|
||||||
import { Trans, withNamespaces } from 'react-i18next';
|
import { Trans, withNamespaces } from 'react-i18next';
|
||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
|
|
||||||
import { renderField, renderSelectField, required, toNumber, port } from '../../../helpers/form';
|
import { renderField, renderSelectField, toNumber, port } from '../../../helpers/form';
|
||||||
import i18n from '../../../i18n';
|
import i18n from '../../../i18n';
|
||||||
|
|
||||||
const validate = (values) => {
|
const validate = (values) => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
|
|
||||||
if (values.port_dns_over_tls === values.port_https) {
|
if (values.port_dns_over_tls && values.port_https) {
|
||||||
errors.port_dns_over_tls = i18n.t('form_error_equal');
|
if (values.port_dns_over_tls === values.port_https) {
|
||||||
errors.port_https = i18n.t('form_error_equal');
|
errors.port_dns_over_tls = i18n.t('form_error_equal');
|
||||||
|
errors.port_https = i18n.t('form_error_equal');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -22,6 +24,7 @@ const Form = (props) => {
|
||||||
const {
|
const {
|
||||||
t,
|
t,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
reset,
|
||||||
invalid,
|
invalid,
|
||||||
submitting,
|
submitting,
|
||||||
processing,
|
processing,
|
||||||
|
@ -46,7 +49,6 @@ const Form = (props) => {
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={t('encryption_server_enter')}
|
placeholder={t('encryption_server_enter')}
|
||||||
validate={[required]}
|
|
||||||
/>
|
/>
|
||||||
<div className="form__desc">
|
<div className="form__desc">
|
||||||
<Trans>encryption_server_desc</Trans>
|
<Trans>encryption_server_desc</Trans>
|
||||||
|
@ -80,7 +82,7 @@ const Form = (props) => {
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={t('encryption_https')}
|
placeholder={t('encryption_https')}
|
||||||
validate={[required, port]}
|
validate={[port]}
|
||||||
normalize={toNumber}
|
normalize={toNumber}
|
||||||
/>
|
/>
|
||||||
<div className="form__desc">
|
<div className="form__desc">
|
||||||
|
@ -100,7 +102,7 @@ const Form = (props) => {
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={t('encryption_dot')}
|
placeholder={t('encryption_dot')}
|
||||||
validate={[required, port]}
|
validate={[port]}
|
||||||
normalize={toNumber}
|
normalize={toNumber}
|
||||||
/>
|
/>
|
||||||
<div className="form__desc">
|
<div className="form__desc">
|
||||||
|
@ -130,7 +132,6 @@ const Form = (props) => {
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control--textarea"
|
className="form-control form-control--textarea"
|
||||||
placeholder={t('encryption_certificates_input')}
|
placeholder={t('encryption_certificates_input')}
|
||||||
validate={[required]}
|
|
||||||
/>
|
/>
|
||||||
<div className="form__status">
|
<div className="form__status">
|
||||||
{statusCert &&
|
{statusCert &&
|
||||||
|
@ -170,7 +171,6 @@ const Form = (props) => {
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control--textarea"
|
className="form-control form-control--textarea"
|
||||||
placeholder="Copy/paste your PEM-encoded private key for your cerficate here."
|
placeholder="Copy/paste your PEM-encoded private key for your cerficate here."
|
||||||
validate={[required]}
|
|
||||||
/>
|
/>
|
||||||
<div className="form__status">
|
<div className="form__status">
|
||||||
{statusKey &&
|
{statusKey &&
|
||||||
|
@ -188,19 +188,30 @@ const Form = (props) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<div className="btn-list">
|
||||||
type="submit"
|
<button
|
||||||
className="btn btn-success btn-standart"
|
type="submit"
|
||||||
disabled={invalid || submitting || processing}
|
className="btn btn-success btn-standart"
|
||||||
>
|
disabled={invalid || submitting || processing}
|
||||||
{t('save_config')}
|
>
|
||||||
</button>
|
<Trans>save_config</Trans>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-secondary btn-standart"
|
||||||
|
disabled={submitting || processing}
|
||||||
|
onClick={reset}
|
||||||
|
>
|
||||||
|
<Trans>reset_settings</Trans>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Form.propTypes = {
|
Form.propTypes = {
|
||||||
handleSubmit: PropTypes.func.isRequired,
|
handleSubmit: PropTypes.func.isRequired,
|
||||||
|
reset: PropTypes.func.isRequired,
|
||||||
submitting: PropTypes.bool.isRequired,
|
submitting: PropTypes.bool.isRequired,
|
||||||
invalid: PropTypes.bool.isRequired,
|
invalid: PropTypes.bool.isRequired,
|
||||||
initialValues: PropTypes.object.isRequired,
|
initialValues: PropTypes.object.isRequired,
|
||||||
|
|
|
@ -63,7 +63,7 @@ export const isPositive = (value) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const port = (value) => {
|
export const port = (value) => {
|
||||||
if (value < 80 || value > 65535) {
|
if (value && (value < 80 || value > 65535)) {
|
||||||
return <Trans>form_error_port_range</Trans>;
|
return <Trans>form_error_port_range</Trans>;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -329,6 +329,11 @@ const encryption = handleActions({
|
||||||
processingConfig: false,
|
processingConfig: false,
|
||||||
status_cert: '',
|
status_cert: '',
|
||||||
status_key: '',
|
status_key: '',
|
||||||
|
certificate_chain: '',
|
||||||
|
private_key: '',
|
||||||
|
server_name: '',
|
||||||
|
port_https: '',
|
||||||
|
port_dns_over_tls: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default combineReducers({
|
export default combineReducers({
|
||||||
|
|
Loading…
Reference in New Issue