forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminDomainList.js
More file actions
103 lines (102 loc) · 3.3 KB
/
AdminDomainList.js
File metadata and controls
103 lines (102 loc) · 3.3 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
import React from 'react'
import { Divider, Flex, IconButton, Stack, Text } from '@chakra-ui/react'
import { ListOf } from '../components/ListOf'
import { Trans } from '@lingui/macro'
import { EditIcon, MinusIcon } from '@chakra-ui/icons'
import { AdminDomainCard } from './AdminDomainCard'
import { ABTestVariant, ABTestWrapper } from '../app/ABTestWrapper'
import SubdomainDiscoveryButton from '../domains/SubdomainDiscoveryButton'
import { array, bool, func, object, string } from 'prop-types'
export function AdminDomainList({
nodes,
verified,
permission,
orgId,
orgSlug,
i18n,
setSelectedRemoveProps,
removeOnOpen,
setModalProps,
updateOnOpen,
}) {
return (
<ListOf
elements={nodes}
ifEmpty={() => (
<Text layerStyle="loadingMessage">
<Trans>No Domains</Trans>
</Text>
)}
>
{({ id: domainId, domain, claimTags, archived, rcode, organizations, assetState }, index) => (
<React.Fragment key={`admindomain-${index}`}>
{index === 0 && <Divider borderBottomColor="gray.400" />}
<Flex p="1" align="center" rounded="md" mb="1">
<Stack direction="row" flexGrow="0" mr="2">
{(!verified || permission === 'SUPER_ADMIN' || rcode === 'NXDOMAIN') && (
<IconButton
data-testid={`remove-${index}`}
onClick={() => {
setSelectedRemoveProps({ domain, domainId, rcode })
removeOnOpen()
}}
variant="danger"
px="2"
icon={<MinusIcon />}
aria-label={'Remove ' + domain}
/>
)}
<IconButton
data-testid={`edit-${index}`}
variant="primary"
px="2"
onClick={() => {
setModalProps({
archived,
mutation: 'update',
assetState,
tagInputList: claimTags,
editingDomainId: domainId,
editingDomainUrl: domain,
orgCount: organizations.totalCount,
})
updateOnOpen()
}}
icon={<EditIcon />}
aria-label={'Edit ' + domain}
/>
</Stack>
<AdminDomainCard
url={domain}
tags={claimTags}
assetState={assetState}
isArchived={archived}
rcode={rcode}
locale={i18n.locale}
flexGrow={1}
fontSize={{ base: '75%', sm: '100%' }}
/>
<ABTestWrapper>
<ABTestVariant name="B">
<SubdomainDiscoveryButton domainUrl={domain} orgId={orgId} orgSlug={orgSlug} ml="2" />
</ABTestVariant>
</ABTestWrapper>
</Flex>
<Divider borderBottomColor="gray.400" />
</React.Fragment>
)}
</ListOf>
)
}
AdminDomainList.propTypes = {
nodes: array.isRequired,
verified: bool,
permission: string,
orgId: string.isRequired,
orgSlug: string,
i18n: object.isRequired,
setSelectedRemoveProps: func.isRequired,
removeOnOpen: func.isRequired,
setModalProps: func.isRequired,
updateOnOpen: func.isRequired,
}