Pull request: 3846 filter lists ids
Merge in DNS/adguard-home from 3846-list-ids to master Closes #3846. Squashed commit of the following: commit 02a12fc27bc5d3cf1a17fd43c6f05e2c389bd71d Author: Ildar Kamalov <ik@adguard.com> Date: Fri Nov 26 16:58:13 2021 +0300 client: fix name commit 6220570e6e9c968f0d3fa9d02c12099ce66aaaad Author: Ildar Kamalov <ik@adguard.com> Date: Fri Nov 26 16:46:54 2021 +0300 client: handle special filter ids commit dcdeb2d7f4500aab6ce5ffe642bdaacf291f5951 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 26 15:52:06 2021 +0300 all: mv constants, imp config commit 8ceb4a2b351e595929d8b2af564c6d0267afa230 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 26 15:04:36 2021 +0300 all: fix custom list id, log changes commit acb8b456e7f41a556da34cf10647eecee058beec Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Nov 25 20:04:37 2021 +0300 all: rm global ctx, add const flt ids
This commit is contained in:
@@ -625,5 +625,7 @@
|
||||
"filter_allowlist": "WARNING: This action also will exclude the rule \"{{disallowed_rule}}\" from the list of allowed clients.",
|
||||
"last_rule_in_allowlist": "Cannot disallow this client because excluding the rule \"{{disallowed_rule}}\" will DISABLE \"Allowed clients\" list.",
|
||||
"experimental": "Experimental",
|
||||
"use_saved_key": "Use the previously saved key"
|
||||
"use_saved_key": "Use the previously saved key",
|
||||
"parental_control": "Parental control",
|
||||
"safe_browsing": "Safe browsing"
|
||||
}
|
||||
|
||||
@@ -528,8 +528,14 @@ export const DETAILED_DATE_FORMAT_OPTIONS = {
|
||||
month: 'long',
|
||||
};
|
||||
|
||||
export const CUSTOM_FILTERING_RULES_ID = 0;
|
||||
export const SYSTEM_HOSTS_FILTER_ID = -1;
|
||||
export const SPECIAL_FILTER_ID = {
|
||||
CUSTOM_FILTERING_RULES: 0,
|
||||
SYSTEM_HOSTS: -1,
|
||||
BLOCKED_SERVICES: -2,
|
||||
PARENTAL: -3,
|
||||
SAFE_BROWSING: -4,
|
||||
SAFE_SEARCH: -5,
|
||||
};
|
||||
|
||||
export const BLOCK_ACTIONS = {
|
||||
BLOCK: 'block',
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
ADDRESS_TYPES,
|
||||
CHECK_TIMEOUT,
|
||||
COMMENT_LINE_DEFAULT_TOKEN,
|
||||
CUSTOM_FILTERING_RULES_ID,
|
||||
DEFAULT_DATE_FORMAT_OPTIONS,
|
||||
DEFAULT_LANGUAGE,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
@@ -26,7 +25,7 @@ import {
|
||||
STANDARD_DNS_PORT,
|
||||
STANDARD_HTTPS_PORT,
|
||||
STANDARD_WEB_PORT,
|
||||
SYSTEM_HOSTS_FILTER_ID,
|
||||
SPECIAL_FILTER_ID,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
@@ -774,6 +773,30 @@ export const sortIp = (a, b) => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} filterId
|
||||
* @returns {string}
|
||||
*/
|
||||
export const getSpecialFilterName = (filterId) => {
|
||||
switch (filterId) {
|
||||
case SPECIAL_FILTER_ID.CUSTOM_FILTERING_RULES:
|
||||
return i18n.t('custom_filter_rules');
|
||||
case SPECIAL_FILTER_ID.SYSTEM_HOSTS:
|
||||
return i18n.t('system_host_files');
|
||||
case SPECIAL_FILTER_ID.BLOCKED_SERVICES:
|
||||
return i18n.t('blocked_services');
|
||||
case SPECIAL_FILTER_ID.PARENTAL:
|
||||
return i18n.t('parental_control');
|
||||
case SPECIAL_FILTER_ID.SAFE_BROWSING:
|
||||
return i18n.t('safe_browsing');
|
||||
case SPECIAL_FILTER_ID.SAFE_SEARCH:
|
||||
return i18n.t('safe_search');
|
||||
default:
|
||||
return i18n.t('unknown_filter', { filterId });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {array} filters
|
||||
* @param {array} whitelistFilters
|
||||
@@ -785,15 +808,11 @@ export const getFilterName = (
|
||||
filters,
|
||||
whitelistFilters,
|
||||
filterId,
|
||||
customFilterTranslationKey = 'custom_filter_rules',
|
||||
resolveFilterName = (filter) => (filter ? filter.name : i18n.t('unknown_filter', { filterId })),
|
||||
) => {
|
||||
if (filterId === CUSTOM_FILTERING_RULES_ID) {
|
||||
return i18n.t(customFilterTranslationKey);
|
||||
}
|
||||
|
||||
if (filterId === SYSTEM_HOSTS_FILTER_ID) {
|
||||
return i18n.t('system_host_files');
|
||||
const specialFilterIds = Object.values(SPECIAL_FILTER_ID);
|
||||
if (specialFilterIds.includes(filterId)) {
|
||||
return getSpecialFilterName(filterId);
|
||||
}
|
||||
|
||||
const matchIdPredicate = (filter) => filter.id === filterId;
|
||||
|
||||
Reference in New Issue
Block a user