2020-07-03 16:17:58 +00:00
|
|
|
import React from 'react';
|
2019-11-28 14:59:55 +00:00
|
|
|
import { normalizeWhois } from './helpers';
|
2019-09-24 12:28:59 +00:00
|
|
|
import { WHOIS_ICONS } from './constants';
|
2019-09-23 13:02:47 +00:00
|
|
|
|
2020-07-15 17:55:13 +00:00
|
|
|
const getFormattedWhois = (whois) => {
|
2019-09-24 12:28:59 +00:00
|
|
|
const whoisInfo = normalizeWhois(whois);
|
|
|
|
return (
|
2020-06-17 21:36:19 +00:00
|
|
|
Object.keys(whoisInfo)
|
|
|
|
.map((key) => {
|
|
|
|
const icon = WHOIS_ICONS[key];
|
|
|
|
return (
|
2020-09-07 07:36:17 +00:00
|
|
|
<span className="logs__whois text-muted" key={key} title={whoisInfo[key]}>
|
2019-09-24 12:28:59 +00:00
|
|
|
{icon && (
|
2020-07-03 16:17:58 +00:00
|
|
|
<>
|
2020-09-02 13:09:59 +00:00
|
|
|
<svg className="logs__whois-icon icons icon--18">
|
2019-09-24 12:28:59 +00:00
|
|
|
<use xlinkHref={`#${icon}`} />
|
2020-06-17 21:36:19 +00:00
|
|
|
</svg>
|
|
|
|
|
2020-07-03 16:17:58 +00:00
|
|
|
</>
|
2019-09-24 12:28:59 +00:00
|
|
|
)}{whoisInfo[key]}
|
|
|
|
</span>
|
2020-06-17 21:36:19 +00:00
|
|
|
);
|
|
|
|
})
|
2019-09-24 12:28:59 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-09-01 13:30:30 +00:00
|
|
|
/**
|
|
|
|
* @param {string} value
|
|
|
|
* @param {object} info
|
|
|
|
* @param {string} info.name
|
|
|
|
* @param {object} info.whois_info
|
|
|
|
* @param {boolean} [isDetailed]
|
|
|
|
* @param {boolean} [isLogs]
|
2020-12-25 12:03:37 +00:00
|
|
|
* @returns {JSXElement}
|
2020-09-01 13:30:30 +00:00
|
|
|
*/
|
|
|
|
export const renderFormattedClientCell = (value, info, isDetailed = false, isLogs = false) => {
|
|
|
|
let whoisContainer = null;
|
2020-06-18 11:21:54 +00:00
|
|
|
let nameContainer = value;
|
2019-09-23 13:02:47 +00:00
|
|
|
|
2019-11-28 14:59:55 +00:00
|
|
|
if (info) {
|
2019-12-11 11:31:38 +00:00
|
|
|
const { name, whois_info } = info;
|
2020-07-24 14:17:11 +00:00
|
|
|
const whoisAvailable = whois_info && Object.keys(whois_info).length > 0;
|
2019-09-23 13:02:47 +00:00
|
|
|
|
2019-11-28 14:59:55 +00:00
|
|
|
if (name) {
|
2020-09-01 13:30:30 +00:00
|
|
|
const nameValue = <div className="logs__text logs__text--nowrap" title={`${name} (${value})`}>
|
|
|
|
{name} <small>{`(${value})`}</small>
|
|
|
|
</div>;
|
|
|
|
|
|
|
|
if (!isLogs) {
|
|
|
|
nameContainer = nameValue;
|
2020-07-20 12:25:28 +00:00
|
|
|
} else {
|
2020-09-01 13:30:30 +00:00
|
|
|
nameContainer = !whoisAvailable && isDetailed
|
|
|
|
? <small title={value}>{value}</small>
|
|
|
|
: nameValue;
|
2020-07-20 12:25:28 +00:00
|
|
|
}
|
2019-11-28 14:59:55 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 14:17:11 +00:00
|
|
|
if (whoisAvailable && isDetailed) {
|
2020-09-01 13:30:30 +00:00
|
|
|
whoisContainer = <div className="logs__text logs__text--wrap logs__text--whois">
|
2020-07-15 17:55:13 +00:00
|
|
|
{getFormattedWhois(whois_info)}
|
2020-09-01 13:30:30 +00:00
|
|
|
</div>;
|
2019-11-28 14:59:55 +00:00
|
|
|
}
|
2019-09-24 12:28:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 13:30:30 +00:00
|
|
|
return <div className="logs__text mw-100" title={value}>
|
|
|
|
{nameContainer}
|
|
|
|
{whoisContainer}
|
|
|
|
</div>;
|
2019-09-23 13:02:47 +00:00
|
|
|
};
|