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
|
|
|
|
2019-09-24 12:28:59 +00:00
|
|
|
const getFormattedWhois = (whois, t) => {
|
|
|
|
const whoisInfo = normalizeWhois(whois);
|
|
|
|
return (
|
2020-06-17 21:36:19 +00:00
|
|
|
Object.keys(whoisInfo)
|
|
|
|
.map((key) => {
|
|
|
|
const icon = WHOIS_ICONS[key];
|
|
|
|
return (
|
|
|
|
<span className="logs__whois text-muted" key={key} title={t(key)}>
|
2019-09-24 12:28:59 +00:00
|
|
|
{icon && (
|
2020-07-03 16:17:58 +00:00
|
|
|
<>
|
2019-09-24 12:28:59 +00:00
|
|
|
<svg className="logs__whois-icon icons">
|
|
|
|
<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-06-17 21:36:19 +00:00
|
|
|
export const formatClientCell = (row, t, isDetailed = false) => {
|
2020-06-18 11:21:54 +00:00
|
|
|
const { value, original: { info } } = row;
|
2019-09-24 12:28:59 +00:00
|
|
|
let whoisContainer = '';
|
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;
|
2019-09-23 13:02:47 +00:00
|
|
|
|
2019-11-28 14:59:55 +00:00
|
|
|
if (name) {
|
2020-06-18 11:21:54 +00:00
|
|
|
nameContainer = isDetailed
|
|
|
|
? <small title={value}>{value}</small>
|
|
|
|
: <div className="logs__text logs__text--nowrap" title={`${name} (${value})`}>
|
2020-06-19 11:44:23 +00:00
|
|
|
{name}
|
|
|
|
{' '}
|
|
|
|
<small>{`(${value})`}</small>
|
2020-06-17 21:36:19 +00:00
|
|
|
</div>;
|
2019-11-28 14:59:55 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 11:31:38 +00:00
|
|
|
if (whois_info) {
|
2019-11-28 14:59:55 +00:00
|
|
|
whoisContainer = (
|
|
|
|
<div className="logs__text logs__text--wrap logs__text--whois">
|
2019-12-11 11:31:38 +00:00
|
|
|
{getFormattedWhois(whois_info, t)}
|
2019-11-28 14:59:55 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2019-09-24 12:28:59 +00:00
|
|
|
}
|
|
|
|
|
2019-09-23 13:02:47 +00:00
|
|
|
return (
|
2020-06-18 11:21:54 +00:00
|
|
|
<div className="logs__text" title={value}>
|
2020-06-17 21:36:19 +00:00
|
|
|
<>
|
2019-09-24 12:28:59 +00:00
|
|
|
{nameContainer}
|
|
|
|
{whoisContainer}
|
2020-06-17 21:36:19 +00:00
|
|
|
</>
|
|
|
|
</div>
|
2019-09-23 13:02:47 +00:00
|
|
|
);
|
|
|
|
};
|