Fix #1325 Squashed commit of the following: commit d8f7de72226855a961051e09b4b78f4dd71baadd Merge: f9bbe86136f3218b
Author: Andrey Meshkov <am@adguard.com> Date: Mon Jul 6 19:34:53 2020 +0300 Merge branch 'master' into feature/1325 commit f9bbe861c9dbd631b5708f8eb073270b83a3f70f Merge: 99710fef4f8138bd
Author: Andrey Meshkov <am@adguard.com> Date: Mon Jul 6 19:33:53 2020 +0300 Merge branch 'master' into feature/1325 commit 99710fef0825966b224e4a30a979e4d45f929af1 Merge: 8329326d a5380ead Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 6 18:04:32 2020 +0300 Merge branch 'feature/1325' of ssh://bit.adguard.com:7999/dns/adguard-home into feature/1325 commit 8329326d6470dfcf2cdc4479e0290f7cc56ddca4 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 6 18:03:56 2020 +0300 Update locales, add title for select modal commit a5380ead56d15eba3f36c38f8fc0eedc89c2c57a Author: Andrey Meshkov <am@adguard.com> Date: Mon Jul 6 17:26:37 2020 +0300 Update readme commit dfe6e254d909ee6994cacef53d417bb073dfd802 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 6 13:44:19 2020 +0300 Change info icon width commit 06120cf3da9065fc9cc3a2864b976563d4cfe06a Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 6 13:38:58 2020 +0300 Review changes commit ae3c6cacc5610a0f95bec2f6ef8a63e90041e4dd Merge: dd56a3bb73c5d9ea
Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 6 12:01:57 2020 +0300 Merge branch 'master' into feature/1325 commit dd56a3bbb851687823242fa653cc3bb63dedf5e4 Author: Andrey Meshkov <am@adguard.com> Date: Fri Jul 3 15:52:01 2020 +0300 Added blocklists commit f08f0eb0cdd8cd488d3a8f1182854b72775cf06e Merge: 854d4f8821dfb5ff
Author: Andrey Meshkov <am@adguard.com> Date: Fri Jul 3 14:06:19 2020 +0300 Merge branch 'master' into feature/1325 commit 854d4f88017a33dc7f788835dc98591cec9b213f Merge: 239462662c47053c
Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jun 22 14:09:31 2020 +0300 Merge branch 'master' into feature/1325 commit 23946266d4913479bcecfcb7702a096983d20685 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue May 26 19:00:26 2020 +0300 Math filters by url commit 661e0482f01ffea0d0f5aa81b3b253143d0ca112 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon May 25 21:07:21 2020 +0300 Change data format commit ac4ff483b6b06ec0be49a41b5ddd3329f4ae2bbb Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu May 14 19:52:45 2020 +0300 + client: Add choosing filter lists
85 lines
2.6 KiB
JavaScript
85 lines
2.6 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Trans, withTranslation } from 'react-i18next';
|
|
import ReactModal from 'react-modal';
|
|
|
|
import { MODAL_TYPE } from '../../../helpers/constants';
|
|
import Form from './Form';
|
|
|
|
const getInitialData = (initial) => {
|
|
if (initial && initial.blocked_services) {
|
|
const { blocked_services } = initial;
|
|
const blocked = {};
|
|
|
|
blocked_services.forEach((service) => {
|
|
blocked[service] = true;
|
|
});
|
|
|
|
return {
|
|
...initial,
|
|
blocked_services: blocked,
|
|
};
|
|
}
|
|
|
|
return initial;
|
|
};
|
|
|
|
const Modal = (props) => {
|
|
const {
|
|
isModalOpen,
|
|
modalType,
|
|
currentClientData,
|
|
handleSubmit,
|
|
toggleClientModal,
|
|
processingAdding,
|
|
processingUpdating,
|
|
tagsOptions,
|
|
} = props;
|
|
const initialData = getInitialData(currentClientData);
|
|
|
|
return (
|
|
<ReactModal
|
|
className="Modal__Bootstrap modal-dialog modal-dialog-centered modal-dialog--clients"
|
|
closeTimeoutMS={0}
|
|
isOpen={isModalOpen}
|
|
onRequestClose={() => toggleClientModal()}
|
|
>
|
|
<div className="modal-content">
|
|
<div className="modal-header">
|
|
<h4 className="modal-title">
|
|
{modalType === MODAL_TYPE.EDIT_FILTERS ? (
|
|
<Trans>client_edit</Trans>
|
|
) : (
|
|
<Trans>client_new</Trans>
|
|
)}
|
|
</h4>
|
|
<button type="button" className="close" onClick={() => toggleClientModal()}>
|
|
<span className="sr-only">Close</span>
|
|
</button>
|
|
</div>
|
|
<Form
|
|
initialValues={{ ...initialData }}
|
|
onSubmit={handleSubmit}
|
|
toggleClientModal={toggleClientModal}
|
|
processingAdding={processingAdding}
|
|
processingUpdating={processingUpdating}
|
|
tagsOptions={tagsOptions}
|
|
/>
|
|
</div>
|
|
</ReactModal>
|
|
);
|
|
};
|
|
|
|
Modal.propTypes = {
|
|
isModalOpen: PropTypes.bool.isRequired,
|
|
modalType: PropTypes.string.isRequired,
|
|
currentClientData: PropTypes.object.isRequired,
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
toggleClientModal: PropTypes.func.isRequired,
|
|
processingAdding: PropTypes.bool.isRequired,
|
|
processingUpdating: PropTypes.bool.isRequired,
|
|
tagsOptions: PropTypes.array.isRequired,
|
|
};
|
|
|
|
export default withTranslation()(Modal);
|