From 90b25300df15c588b4bea1eac02e92017c71d315 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Fri, 28 Feb 2020 14:31:45 +0300 Subject: [PATCH] + client: handle allowlist refresh --- client/src/actions/filtering.js | 4 ++-- client/src/api/Api.js | 9 +++++++-- client/src/components/Filters/DnsAllowlist.js | 7 +++++-- client/src/components/Filters/DnsBlocklist.js | 7 +++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/client/src/actions/filtering.js b/client/src/actions/filtering.js index e1ef2219..e3c2de11 100644 --- a/client/src/actions/filtering.js +++ b/client/src/actions/filtering.js @@ -113,11 +113,11 @@ export const refreshFiltersRequest = createAction('FILTERING_REFRESH_REQUEST'); export const refreshFiltersFailure = createAction('FILTERING_REFRESH_FAILURE'); export const refreshFiltersSuccess = createAction('FILTERING_REFRESH_SUCCESS'); -export const refreshFilters = () => async (dispatch) => { +export const refreshFilters = config => async (dispatch) => { dispatch(refreshFiltersRequest()); dispatch(showLoading()); try { - const data = await apiClient.refreshFilters(); + const data = await apiClient.refreshFilters(config); const { updated } = data; dispatch(refreshFiltersSuccess()); diff --git a/client/src/api/Api.js b/client/src/api/Api.js index a5caaa1c..94a05b19 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -89,9 +89,14 @@ class Api { return this.makeRequest(path, method); } - refreshFilters() { + refreshFilters(config) { const { path, method } = this.FILTERING_REFRESH; - return this.makeRequest(path, method); + const parameters = { + data: config, + headers: { 'Content-Type': 'application/json' }, + }; + + return this.makeRequest(path, method, parameters); } addFilter(config) { diff --git a/client/src/components/Filters/DnsAllowlist.js b/client/src/components/Filters/DnsAllowlist.js index a2eb57ac..da397af5 100644 --- a/client/src/components/Filters/DnsAllowlist.js +++ b/client/src/components/Filters/DnsAllowlist.js @@ -40,11 +40,14 @@ class DnsAllowlist extends Component { this.props.toggleFilterStatus(url, data, whitelist); }; + handleRefresh = () => { + this.props.refreshFilters({ whitelist: true }); + }; + render() { const { t, toggleFilteringModal, - refreshFilters, addFilter, toggleFilterStatus, filtering: { @@ -89,7 +92,7 @@ class DnsAllowlist extends Component { /> toggleFilteringModal({ type: MODAL_TYPE.ADD })} - handleRefresh={refreshFilters} + handleRefresh={this.handleRefresh} processingRefreshFilters={processingRefreshFilters} whitelist={whitelist} /> diff --git a/client/src/components/Filters/DnsBlocklist.js b/client/src/components/Filters/DnsBlocklist.js index 075749d3..e5d182e7 100644 --- a/client/src/components/Filters/DnsBlocklist.js +++ b/client/src/components/Filters/DnsBlocklist.js @@ -37,11 +37,14 @@ class DnsBlocklist extends Component { this.props.toggleFilterStatus(url, data); }; + handleRefresh = () => { + this.props.refreshFilters({ whitelist: false }); + }; + render() { const { t, toggleFilteringModal, - refreshFilters, addFilter, filtering: { filters, @@ -82,7 +85,7 @@ class DnsBlocklist extends Component { /> toggleFilteringModal({ type: MODAL_TYPE.ADD })} - handleRefresh={refreshFilters} + handleRefresh={this.handleRefresh} processingRefreshFilters={processingRefreshFilters} />