forked from AdguardTeam/AdGuardHome
-
Notifications
You must be signed in to change notification settings - Fork 0
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
- Loading branch information
1 parent
eac1b80
commit bb5a77f
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