644a9b5565
Close #2451
Squashed commit of the following:
commit f6d0a8fe4fa575dff67b2d2f4c9f6aaf6a6414d3
Merge: 3b13e529d 955b735c8
Author: Artem Baskal <a.baskal@adguard.com>
Date: Fri Dec 25 14:53:16 2020 +0300
Merge branch 'master' into feature/2451
commit 3b13e529da01823cbc674d81be065b68cd08bbd3
Author: Artem Baskal <a.baskal@adguard.com>
Date: Thu Dec 24 12:53:13 2020 +0300
Update JSXElement in jsdocs
commit f0749cd0466ef69d964b1c2575dffacb33f71b31
Author: Artem Baskal <a.baskal@adguard.com>
Date: Mon Dec 21 13:23:48 2020 +0300
minor
commit bd014b00e762a1895c132bc962c06f107c50fe17
Author: Artem Baskal <a.baskal@adguard.com>
Date: Mon Dec 21 12:49:29 2020 +0300
Minor helper update
commit 260a66b7b78eb80596b88fec14f409838727e4bb
Author: Artem Baskal <a.baskal@adguard.com>
Date: Mon Dec 21 12:31:08 2020 +0300
Rule locale update
commit c960cf9f658e52cb587676dceb97506880a9db94
Author: Artem Baskal <a.baskal@adguard.com>
Date: Mon Dec 21 12:27:50 2020 +0300
Add styles for filters list
commit 6f3b2176fd52598cddb147ad7828adb95abf08f0
Author: Artem Baskal <a.baskal@adguard.com>
Date: Fri Dec 18 18:34:17 2020 +0300
client: 2451 Support multiple matched rules in the UI
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
import React from 'react';
|
|
import { normalizeWhois } from './helpers';
|
|
import { WHOIS_ICONS } from './constants';
|
|
|
|
const getFormattedWhois = (whois) => {
|
|
const whoisInfo = normalizeWhois(whois);
|
|
return (
|
|
Object.keys(whoisInfo)
|
|
.map((key) => {
|
|
const icon = WHOIS_ICONS[key];
|
|
return (
|
|
<span className="logs__whois text-muted" key={key} title={whoisInfo[key]}>
|
|
{icon && (
|
|
<>
|
|
<svg className="logs__whois-icon icons icon--18">
|
|
<use xlinkHref={`#${icon}`} />
|
|
</svg>
|
|
|
|
</>
|
|
)}{whoisInfo[key]}
|
|
</span>
|
|
);
|
|
})
|
|
);
|
|
};
|
|
|
|
/**
|
|
* @param {string} value
|
|
* @param {object} info
|
|
* @param {string} info.name
|
|
* @param {object} info.whois_info
|
|
* @param {boolean} [isDetailed]
|
|
* @param {boolean} [isLogs]
|
|
* @returns {JSXElement}
|
|
*/
|
|
export const renderFormattedClientCell = (value, info, isDetailed = false, isLogs = false) => {
|
|
let whoisContainer = null;
|
|
let nameContainer = value;
|
|
|
|
if (info) {
|
|
const { name, whois_info } = info;
|
|
const whoisAvailable = whois_info && Object.keys(whois_info).length > 0;
|
|
|
|
if (name) {
|
|
const nameValue = <div className="logs__text logs__text--nowrap" title={`${name} (${value})`}>
|
|
{name} <small>{`(${value})`}</small>
|
|
</div>;
|
|
|
|
if (!isLogs) {
|
|
nameContainer = nameValue;
|
|
} else {
|
|
nameContainer = !whoisAvailable && isDetailed
|
|
? <small title={value}>{value}</small>
|
|
: nameValue;
|
|
}
|
|
}
|
|
|
|
if (whoisAvailable && isDetailed) {
|
|
whoisContainer = <div className="logs__text logs__text--wrap logs__text--whois">
|
|
{getFormattedWhois(whois_info)}
|
|
</div>;
|
|
}
|
|
}
|
|
|
|
return <div className="logs__text mw-100" title={value}>
|
|
{nameContainer}
|
|
{whoisContainer}
|
|
</div>;
|
|
};
|