mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-03-14 14:38:29 +03:00
Close #1828 Squashed commit of the following: commit bf96b9f2cc99a94a1289c47b04cde136cf0c9f37 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 20:44:22 2020 +0300 Remove field domain from response tooltip commit bba35fdbed6d1e2e532c8effaf2da69de3f2c078 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 20:29:24 2020 +0300 Unify mobile modal commit 5ee2da41594497fd64eadf0fd64c24afdad94e44 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 19:02:47 2020 +0300 Delete unnecessary comment commit ac3a3f13009ad508ddd7eb31aadf7e590a5c2829 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 18:59:44 2020 +0300 minor commit 4b1969a53ce2fcfc859c228b27816459bd8bd1d0 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 18:56:51 2020 +0300 Fix safari mediaQuery change listener issue commit d85de5c4e90d2460632e593cffe3ceea3137e92c Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 18:10:30 2020 +0300 Fix logs input search markup (for different locales) commit 6d704399c5379dfda663503b3a5b1d12a92732b2 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 16:05:35 2020 +0300 Fix whois_info markup, fix domain name overflow commit 4c900f60a9c6b71b427d968177252eb168c424c0 Merge: a3955c9838366ba8
Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Jul 15 13:42:43 2020 +0300 Merge branch 'master' into fix/1828 commit a3955c989a939866c6772b147547344b3f8769c4 Merge: c91c41cb2759d81a
Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 15:14:47 2020 +0300 Merge branch 'master' into fix/1828 commit c91c41cbc5f616e0af1092424e42b909d2f43f7c Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 13:48:54 2020 +0300 Fix cell overflow commit 19e1d31a40f2e1bb1189a85b72507bcc364d4e0c Merge: af31f48ca33164bf
Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 12:36:44 2020 +0300 Merge branch 'master' into fix/1828 commit af31f48c4d2699ebfbd2034711c51499b42e40f5 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 10:45:57 2020 +0300 minor commit d9507c5f3f5758e587766ae0fa45f1b9ad703ccf Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 10 18:34:22 2020 +0300 - client: Fix query logs UI issues
102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
import React from 'react';
|
|
import { nanoid } from 'nanoid';
|
|
import classNames from 'classnames';
|
|
import PropTypes from 'prop-types';
|
|
import { formatClientCell } from '../../../helpers/formatClientCell';
|
|
import getHintElement from './getHintElement';
|
|
import { checkFiltered } from '../../../helpers/helpers';
|
|
import { BLOCK_ACTIONS } from '../../../helpers/constants';
|
|
|
|
const getClientCell = ({
|
|
row, t, isDetailed, toggleBlocking, autoClients, processingRules,
|
|
}) => {
|
|
const {
|
|
reason, client, domain, info: { name, whois_info },
|
|
} = row.original;
|
|
|
|
const autoClient = autoClients.find((autoClient) => autoClient.name === client);
|
|
const source = autoClient?.source;
|
|
|
|
const id = nanoid();
|
|
|
|
const data = {
|
|
address: client,
|
|
name,
|
|
country: whois_info?.country,
|
|
city: whois_info?.city,
|
|
network: whois_info?.orgname,
|
|
source_label: source,
|
|
};
|
|
|
|
const processedData = Object.entries(data);
|
|
|
|
const isFiltered = checkFiltered(reason);
|
|
|
|
const nameClass = classNames('w-90 o-hidden d-flex flex-column', {
|
|
'mt-2': isDetailed && !name && !whois_info,
|
|
'white-space--nowrap': isDetailed,
|
|
});
|
|
|
|
const hintClass = classNames('icons mr-4 icon--small cursor--pointer icon--light-gray', {
|
|
'my-3': isDetailed,
|
|
});
|
|
|
|
const renderBlockingButton = (isFiltered, domain) => {
|
|
const buttonType = isFiltered ? BLOCK_ACTIONS.UNBLOCK : BLOCK_ACTIONS.BLOCK;
|
|
|
|
const buttonClass = classNames('logs__action button__action', {
|
|
'btn-outline-secondary': isFiltered,
|
|
'btn-outline-danger': !isFiltered,
|
|
'logs__action--detailed': isDetailed,
|
|
});
|
|
|
|
const onClick = () => toggleBlocking(buttonType, domain);
|
|
|
|
return (
|
|
<div className={buttonClass}>
|
|
<button
|
|
type="button"
|
|
className={`btn btn-sm ${buttonClass}`}
|
|
onClick={onClick}
|
|
disabled={processingRules}
|
|
>
|
|
{t(buttonType)}
|
|
</button>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div className="logs__row o-hidden h-100">
|
|
{getHintElement({
|
|
className: hintClass,
|
|
columnClass: 'grid grid--limited',
|
|
tooltipClass: 'px-5 pb-5 pt-4 mw-75',
|
|
xlinkHref: 'question',
|
|
contentItemClass: 'text-truncate key-colon',
|
|
title: 'client_details',
|
|
content: processedData,
|
|
placement: 'bottom',
|
|
})}
|
|
<div
|
|
className={nameClass}>
|
|
<div data-tip={true} data-for={id}>{formatClientCell(row, isDetailed)}</div>
|
|
{isDetailed && name
|
|
&& !whois_info && <div className="detailed-info d-none d-sm-block logs__text"
|
|
title={name}>{name}</div>}
|
|
</div>
|
|
{renderBlockingButton(isFiltered, domain)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
getClientCell.propTypes = {
|
|
row: PropTypes.object.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
isDetailed: PropTypes.bool.isRequired,
|
|
toggleBlocking: PropTypes.func.isRequired,
|
|
autoClients: PropTypes.array.isRequired,
|
|
processingRules: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
export default getClientCell;
|