Merge: + client: handle client block and unblock from the top clients table

Closes 

Squashed commit of the following:

commit 776de2ae0a62823b8968cff79a9fa7ba350d7f1c
Author: Ildar Kamalov <i.kamalov@adguard.com>
Date:   Thu Jan 30 11:13:41 2020 +0300

    - client: fix normalizeTextarea and blocking button

commit 399e6bc3893093632b09247eaf6493521a668c84
Author: Ildar Kamalov <i.kamalov@adguard.com>
Date:   Wed Jan 29 17:19:50 2020 +0300

    + client: handle client block and unblock from the top clients table
This commit is contained in:
Ildar Kamalov 2020-01-30 13:58:54 +03:00
parent 76be272787
commit 5c814b29e1
14 changed files with 195 additions and 39 deletions
client/src/helpers

View file

@ -122,6 +122,17 @@ export const addClientInfo = (data, clients, param) => (
})
);
export const addClientStatus = (data, disallowedClients, param) => (
data.map((row) => {
const clientIp = row[param];
const blocked = !!(disallowedClients && disallowedClients.includes(clientIp));
return {
...row,
blocked,
};
})
);
export const normalizeFilteringStatus = (filteringStatus) => {
const {
enabled, filters, user_rules: userRules, interval,
@ -275,7 +286,13 @@ export const redirectToCurrentProtocol = (values, httpPort = 80) => {
}
};
export const normalizeTextarea = text => text && text.replace(/[;, ]/g, '\n').split('\n').filter(n => n);
export const normalizeTextarea = (text) => {
if (!text) {
return [];
}
return text.replace(/[;, ]/g, '\n').split('\n').filter(n => n);
};
/**
* Normalizes the topClients array