Close #1687
Squashed commit of the following:
commit 5287da0b98d154d4243abdb4b9021006499c225f
Merge: c6b50c70 83b9b701
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri May 29 12:47:23 2020 +0300
Merge branch 'master' into fix/1687
commit c6b50c70a5089fcadfd2606b07b3b84769db2760
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri May 29 12:42:12 2020 +0300
minor
commit dab9fa9ee0502838b4e10aef93d037c2fb5bf41b
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu May 28 16:56:08 2020 +0300
Add support for exact matching of long and short ipv6 notations, add tests
commit e72e86cda81af2c5e54f93abb2890438fd3648b0
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu May 28 13:57:22 2020 +0300
Update helper, write tests
commit 92f4c34224ab7927b02edde829f2d9653a00a854
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Wed May 27 18:35:05 2020 +0300
Make variable names more expressive
commit 3d38f21281237e9cccbba26afc1ab641947c5dc0
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Wed May 27 17:09:08 2020 +0300
Add ipv6 cidr support
commit 7db0a2fb18ccd96d8d1def73f12138e4f4e37f71
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Tue May 26 12:48:57 2020 +0300
Minor
commit 65e87f3899aab3417cac57bab0a8fa371cafd4ec
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Tue May 26 12:46:30 2020 +0300
Add breaks between helpers
commit 3f38bdfe7bc17e019bf048c79c9e8f1336b6f3d3
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu May 21 20:17:27 2020 +0300
- client: Match client IP strictly
88 lines
2.6 KiB
JavaScript
88 lines
2.6 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Field, reduxForm } from 'redux-form';
|
|
import { Trans, withTranslation } from 'react-i18next';
|
|
import flow from 'lodash/flow';
|
|
import { renderTextareaField } from '../../../../helpers/form';
|
|
import { normalizeMultiline } from '../../../../helpers/helpers';
|
|
|
|
const fields = [
|
|
{
|
|
id: 'allowed_clients',
|
|
title: 'access_allowed_title',
|
|
subtitle: 'access_allowed_desc',
|
|
},
|
|
{
|
|
id: 'disallowed_clients',
|
|
title: 'access_disallowed_title',
|
|
subtitle: 'access_disallowed_desc',
|
|
},
|
|
{
|
|
id: 'blocked_hosts',
|
|
title: 'access_blocked_title',
|
|
subtitle: 'access_blocked_desc',
|
|
},
|
|
];
|
|
|
|
const Form = (props) => {
|
|
const {
|
|
handleSubmit, submitting, invalid, processingSet,
|
|
} = props;
|
|
|
|
const renderField = ({
|
|
id, title, subtitle, disabled = processingSet,
|
|
}) => <div key={id} className="form__group mb-5">
|
|
<label className="form__label form__label--with-desc" htmlFor={id}>
|
|
<Trans>{title}</Trans>
|
|
</label>
|
|
<div className="form__desc form__desc--top">
|
|
<Trans>{subtitle}</Trans>
|
|
</div>
|
|
<Field
|
|
id={id}
|
|
name={id}
|
|
component={renderTextareaField}
|
|
type="text"
|
|
className="form-control form-control--textarea font-monospace"
|
|
disabled={disabled}
|
|
normalizeOnBlur={normalizeMultiline}
|
|
/>
|
|
</div>;
|
|
|
|
renderField.propTypes = {
|
|
id: PropTypes.string,
|
|
title: PropTypes.string,
|
|
subtitle: PropTypes.string,
|
|
disabled: PropTypes.bool,
|
|
};
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit}>
|
|
{fields.map(renderField)}
|
|
<div className="card-actions">
|
|
<div className="btn-list">
|
|
<button
|
|
type="submit"
|
|
className="btn btn-success btn-standard"
|
|
disabled={submitting || invalid || processingSet}
|
|
>
|
|
<Trans>save_config</Trans>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
);
|
|
};
|
|
|
|
Form.propTypes = {
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
submitting: PropTypes.bool.isRequired,
|
|
invalid: PropTypes.bool.isRequired,
|
|
initialValues: PropTypes.object.isRequired,
|
|
processingSet: PropTypes.bool.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
textarea: PropTypes.bool,
|
|
};
|
|
|
|
export default flow([withTranslation(), reduxForm({ form: 'accessForm' })])(Form);
|