File size: 2,017 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { translate } from 'i18n-calypso';
import useHostingProviderURL from 'calypso/site-profiler/hooks/use-hosting-provider-url';
import HostingProviderName from './hosting-provider-name';
import type { UrlData } from 'calypso/blocks/import/types';
import type { DNS, HostingProvider } from 'calypso/data/site-profiler/types';
import './style.scss';

interface Props {
	dns: DNS[];
	urlData?: UrlData;
	hostingProvider?: HostingProvider;
	hideTitle?: boolean;
}

export default function HostingInformation( props: Props ) {
	const { dns = [], urlData, hostingProvider, hideTitle = false } = props;
	const aRecordIps = dns.filter( ( x ) => x.type === 'A' && x.ip );
	const supportUrl = useHostingProviderURL( 'support', hostingProvider, urlData );

	return (
		<div className="hosting-information">
			{ ! hideTitle && <h3>{ translate( 'Hosting information' ) }</h3> }
			<ul className="hosting-information-details result-list">
				<li>
					<div className="name">{ translate( 'Provider' ) }</div>
					<HostingProviderName hostingProvider={ hostingProvider } urlData={ urlData } />
				</li>
				{ supportUrl && (
					<li>
						<div className="name">{ translate( 'Support' ) }</div>
						<div>
							<a href={ supportUrl } target="_blank" rel="nofollow noreferrer">
								{ translate( 'Contact support' ) }
							</a>
						</div>
					</li>
				) }
				<li className="a-records">
					<div className="name">
						{
							/* translators: "A Records" refer to the DNS records of type "A". */
							translate( 'A Records' )
						}
					</div>
					<div className="col">
						<ul>
							{ aRecordIps.map( ( x, i ) => (
								<li key={ i }>
									{ ! x.ip && '-' }
									{ x.ip && `${ x.ip }` }
								</li>
							) ) }
						</ul>
					</div>
					<div className="col">
						<ul>
							{ aRecordIps.map( ( x, i ) => (
								<li key={ i }>
									{ ! x.host && '-' }
									{ x.host && `${ x.host }` }
								</li>
							) ) }
						</ul>
					</div>
				</li>
			</ul>
		</div>
	);
}