Pull request: add persistent client from the query log context menu
Updates #6679
Squashed commit of the following:
commit 2e051c9528085182a22ec40a1df11780012a5001
Merge: a001f52ab 56b98080f
Author: Ildar Kamalov <ik@adguard.com>
Date: Thu Feb 8 15:02:22 2024 +0300
Merge branch 'master' into ADG-8179
commit a001f52ab5dadcfc1116ac46da01c0344e51b656
Author: Ildar Kamalov <ik@adguard.com>
Date: Mon Feb 5 18:59:13 2024 +0300
fix changelog
commit 5bac6a2446413b157da6bb404e0e21bb35ac6a10
Author: Ildar Kamalov <ik@adguard.com>
Date: Mon Feb 5 16:01:01 2024 +0300
fix
commit 14a7190ebb18fbed99a897723c27b80144d56825
Author: Ildar Kamalov <ik@adguard.com>
Date: Mon Feb 5 15:59:35 2024 +0300
ADG-8179 add persistent client from query log context menu
This commit is contained in:
@@ -3,7 +3,7 @@ import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||
import { nanoid } from 'nanoid';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link, useHistory } from 'react-router-dom';
|
||||
import propTypes from 'prop-types';
|
||||
|
||||
import { checkFiltered, getBlockingClientName } from '../../../helpers/helpers';
|
||||
@@ -25,12 +25,14 @@ const ClientCell = ({
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory();
|
||||
const autoClients = useSelector((state) => state.dashboard.autoClients, shallowEqual);
|
||||
const isDetailed = useSelector((state) => state.queryLogs.isDetailed);
|
||||
const allowedСlients = useSelector((state) => state.access.allowed_clients, shallowEqual);
|
||||
const [isOptionsOpened, setOptionsOpened] = useState(false);
|
||||
|
||||
const autoClient = autoClients.find((autoClient) => autoClient.name === client);
|
||||
const clients = useSelector((state) => state.dashboard.clients);
|
||||
const source = autoClient?.source;
|
||||
const whoisAvailable = client_info && Object.keys(client_info.whois).length > 0;
|
||||
const clientName = client_info?.name || client_id;
|
||||
@@ -55,6 +57,8 @@ const ClientCell = ({
|
||||
|
||||
const isFiltered = checkFiltered(reason);
|
||||
|
||||
const clientIds = clients.map((c) => c.ids).flat();
|
||||
|
||||
const nameClass = classNames('w-90 o-hidden d-flex flex-column', {
|
||||
'mt-2': isDetailed && !client_info?.name && !whoisAvailable,
|
||||
'white-space--nowrap': isDetailed,
|
||||
@@ -66,7 +70,6 @@ const ClientCell = ({
|
||||
|
||||
const renderBlockingButton = (isFiltered, domain) => {
|
||||
const buttonType = isFiltered ? BLOCK_ACTIONS.UNBLOCK : BLOCK_ACTIONS.BLOCK;
|
||||
const clients = useSelector((state) => state.dashboard.clients);
|
||||
|
||||
const {
|
||||
confirmMessage,
|
||||
@@ -118,6 +121,15 @@ const ClientCell = ({
|
||||
},
|
||||
];
|
||||
|
||||
if (!clientIds.includes(client)) {
|
||||
BUTTON_OPTIONS.push({
|
||||
name: 'add_persistent_client',
|
||||
onClick: () => {
|
||||
history.push(`/#clients?clientId=${client}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const getOptions = (options) => {
|
||||
if (options.length === 0) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user