-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ client: Move "Blocked services" to a separate page under "Filters" …
…menu: Merge pull request #649 in DNS/adguard-home from feature/1744 to master Close #1744 Squashed commit of the following: commit 912a80b Merge: bb5a77f 5ce98bd Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jun 5 12:47:21 2020 +0300 Merge branch 'master' into feature/1744 commit bb5a77f Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jun 4 18:07:26 2020 +0300 + client: Move "Blocked services" to a separate page under "Filters" menu
- Loading branch information
1 parent
5ce98bd
commit 4a81abb
Showing
8 changed files
with
89 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { useDispatch, useSelector } from 'react-redux'; | ||
import Form from './Form'; | ||
import Card from '../../ui/Card'; | ||
import { getBlockedServices, setBlockedServices } from '../../../actions/services'; | ||
import PageTitle from '../../ui/PageTitle'; | ||
|
||
const getInitialDataForServices = (initial) => (initial ? initial.reduce( | ||
(acc, service) => { | ||
acc.blocked_services[service] = true; | ||
return acc; | ||
}, { blocked_services: {} }, | ||
) : initial); | ||
|
||
const Services = () => { | ||
const [t] = useTranslation(); | ||
const dispatch = useDispatch(); | ||
const services = useSelector((store) => store && store.services); | ||
|
||
useEffect(() => { | ||
dispatch(getBlockedServices()); | ||
}, []); | ||
|
||
const handleSubmit = (values) => { | ||
if (!values || !values.blocked_services) { | ||
return; | ||
} | ||
|
||
const blocked_services = Object | ||
.keys(values.blocked_services) | ||
.filter((service) => values.blocked_services[service]); | ||
|
||
dispatch(setBlockedServices(blocked_services)); | ||
}; | ||
|
||
const initialValues = getInitialDataForServices(services.list); | ||
|
||
return ( | ||
<> | ||
<PageTitle | ||
title={t('blocked_services')} | ||
subtitle={t('blocked_services_desc')} | ||
/> | ||
<Card | ||
bodyType="card-body box-body--settings" | ||
> | ||
<div className="form"> | ||
<Form | ||
initialValues={initialValues} | ||
processing={services.processing} | ||
processingSet={services.processingSet} | ||
onSubmit={handleSubmit} | ||
/> | ||
</div> | ||
</Card> | ||
</> | ||
); | ||
}; | ||
|
||
Services.propTypes = {}; | ||
|
||
export default Services; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters