forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganizationDomains.js
More file actions
121 lines (112 loc) · 3.55 KB
/
OrganizationDomains.js
File metadata and controls
121 lines (112 loc) · 3.55 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import React, { useState } from 'react'
import { t, Trans } from '@lingui/macro'
import { Box, Divider, Text } from '@chakra-ui/react'
import { ErrorBoundary } from 'react-error-boundary'
import { number, string } from 'prop-types'
import { DomainCard } from '../domains/DomainCard'
import { ListOf } from '../components/ListOf'
import { LoadingMessage } from '../components/LoadingMessage'
import { ErrorFallbackMessage } from '../components/ErrorFallbackMessage'
import { RelayPaginationControls } from '../components/RelayPaginationControls'
import { InfoButton, InfoBox, InfoPanel } from '../components/InfoPanel'
import { usePaginatedCollection } from '../utilities/usePaginatedCollection'
import { PAGINATED_ORG_DOMAINS as FORWARD } from '../graphql/queries'
export function OrganizationDomains({ domainsPerPage = 10, orgSlug }) {
const {
loading,
isLoadingMore,
error,
nodes,
next,
previous,
hasNextPage,
hasPreviousPage,
} = usePaginatedCollection({
fetchForward: FORWARD,
variables: { slug: orgSlug },
recordsPerPage: domainsPerPage,
relayRoot: 'findOrganizationBySlug.domains',
})
const [infoState, changeInfoState] = useState({
isVisible: false,
})
if (error) return <ErrorFallbackMessage error={error} />
if (loading)
return (
<LoadingMessage>
<Trans>Domains</Trans>
</LoadingMessage>
)
return (
<Box>
<InfoButton
w="100%"
label="Glossary"
state={infoState}
changeState={changeInfoState}
/>
<InfoPanel state={infoState}>
<InfoBox title={t`Domain`} info={t`The domain address.`} />
<InfoBox
title={t`Last scanned`}
info={t`The time the domain was last scanned by the system.`}
/>
<InfoBox
title={t`HTTPS`}
info={t`Shows if the domain meets the Hypertext Transfer Protocol Secure (HTTPS) requirments.`}
/>
<InfoBox
title={t`SSL`}
info={t`Shows if the domain meets the Secure Sockets Layer (SSL) requirements.`}
/>
<InfoBox
title={t`SPF`}
info={t`Shows if the domain meets the Sender Policy Framework (SPF) requiremtns.`}
/>
<InfoBox
title={t`DKIM`}
info={t`Shows if the domain meets the DomainKeys Identified Mail (DKIM) requirements.`}
/>
<InfoBox
title={t`DMARC`}
info={t`Shows if the domain meets the Message Authentication, Reporting, and Conformance (DMARC) requirements.`}
/>
</InfoPanel>
<ListOf
elements={nodes}
ifEmpty={() => (
<Text layerStyle="loadingMessage">
<Trans>No Domains</Trans>
</Text>
)}
mb="4"
>
{({ id, domain, lastRan, status, hasDMARCReport }, index) => (
<ErrorBoundary
key={`${id}:${index}`}
FallbackComponent={ErrorFallbackMessage}
>
<Box>
<DomainCard
url={domain}
lastRan={lastRan}
status={status}
hasDMARCReport={hasDMARCReport}
/>
<Divider borderColor="gray.900" />
</Box>
</ErrorBoundary>
)}
</ListOf>
<RelayPaginationControls
onlyPagination={true}
hasNextPage={hasNextPage}
hasPreviousPage={hasPreviousPage}
next={next}
previous={previous}
isLoadingMore={isLoadingMore}
/>
</Box>
)
}
OrganizationDomains.propTypes = { domainsPerPage: number, orgSlug: string }