-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAdminDomainList.js
More file actions
104 lines (103 loc) · 2.84 KB
/
Copy pathAdminDomainList.js
File metadata and controls
104 lines (103 loc) · 2.84 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
import React from 'react'
import { IconButton, Text } from '@chakra-ui/react'
import { ListOf } from '../components/ListOf'
import { Trans } from '@lingui/react/macro'
import { EditIcon, MinusIcon } from '@chakra-ui/icons'
import { AdminDomainCard } from './AdminDomainCard'
import { array, bool, func, string } from 'prop-types'
export function AdminDomainList({
nodes,
verified,
permission,
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,
cvdEnrollment,
highAvailability,
},
index,
) => (
<React.Fragment key={`admindomain-${index}`}>
<AdminDomainCard
url={domain}
tags={claimTags}
assetState={assetState}
isArchived={archived}
rcode={rcode}
cvdEnrollment={cvdEnrollment}
highAvailability={highAvailability}
flexGrow={1}
fontSize={{ base: '75%', sm: '100%' }}
>
{(!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}
mr="1"
/>
)}
<IconButton
data-testid={`edit-${index}`}
variant="primary"
px="2"
onClick={() => {
setModalProps({
archived,
mutation: 'update',
assetState,
tagInputList: claimTags,
editingDomainId: domainId,
editingDomainUrl: domain,
orgCount: organizations.totalCount,
cvdEnrollment,
highAvailability,
permission,
})
updateOnOpen()
}}
icon={<EditIcon />}
aria-label={'Edit ' + domain}
mr="2"
/>
</AdminDomainCard>
</React.Fragment>
)}
</ListOf>
)
}
AdminDomainList.propTypes = {
nodes: array.isRequired,
verified: bool,
permission: string,
setSelectedRemoveProps: func.isRequired,
removeOnOpen: func.isRequired,
setModalProps: func.isRequired,
updateOnOpen: func.isRequired,
}