@@ -27,37 +27,24 @@ type DomainListProps = GetDomainsParams & {
27
27
fallback ?: React . ReactNode ;
28
28
} ;
29
29
30
- const useDomainList = ( ) => {
31
- const { isAuthorizedUser : canDeleteDomain } = useGate ( { permission : 'org:sys_domains:delete' } ) ;
32
- const { isAuthorizedUser : canVerifyDomain } = useGate ( { permission : 'org:sys_domains:manage' } ) ;
33
-
34
- return {
35
- showDotMenu : canDeleteDomain || canVerifyDomain ,
36
- canVerifyDomain,
37
- canDeleteDomain,
38
- } ;
39
- } ;
40
-
41
30
const buildDomainListRelativeURL = ( parentPath : string , domainId : string , mode ?: 'verify' | 'remove' ) =>
42
31
trimLeadingSlash ( stripOrigin ( toURL ( `${ parentPath } /${ domainId } /${ mode || '' } ` ) ) ) ;
43
32
44
33
const useMenuActions = (
45
34
parentPath : string ,
46
35
domainId : string ,
47
36
) : { label : LocalizationKey ; onClick : ( ) => Promise < unknown > ; isDestructive ?: boolean } [ ] => {
48
- const { canDeleteDomain , canVerifyDomain } = useDomainList ( ) ;
37
+ const { isAuthorizedUser : canManageDomain } = useGate ( { permission : 'org:sys_domains:manage' } ) ;
49
38
const { navigate } = useRouter ( ) ;
50
39
51
40
const menuActions = [ ] ;
52
41
53
- if ( canVerifyDomain ) {
42
+ if ( canManageDomain ) {
54
43
menuActions . push ( {
55
44
label : localizationKeys ( 'organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__verify' ) ,
56
45
onClick : ( ) => navigate ( buildDomainListRelativeURL ( parentPath , domainId , 'verify' ) ) ,
57
46
} ) ;
58
- }
59
47
60
- if ( canDeleteDomain ) {
61
48
menuActions . push ( {
62
49
label : localizationKeys ( 'organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__remove' ) ,
63
50
isDestructive : true ,
@@ -88,7 +75,7 @@ export const DomainList = withGate(
88
75
} ,
89
76
} ) ;
90
77
91
- const { showDotMenu } = useDomainList ( ) ;
78
+ const { isAuthorizedUser : canManageDomain } = useGate ( { permission : 'org:sys_domains:manage' } ) ;
92
79
const { ref } = useInView ( {
93
80
threshold : 0 ,
94
81
onChange : inView => {
@@ -127,7 +114,7 @@ export const DomainList = withGate(
127
114
< Col >
128
115
{ domainList . length === 0 && ! domains ?. isLoading && fallback }
129
116
{ domainList . map ( d => {
130
- if ( ! ( d . verification && d . verification . status === 'verified' ) || ! showDotMenu ) {
117
+ if ( ! ( d . verification && d . verification . status === 'verified' ) || ! canManageDomain ) {
131
118
return (
132
119
< BlockWithTrailingComponent
133
120
key = { d . id }
@@ -140,7 +127,7 @@ export const DomainList = withGate(
140
127
} ) }
141
128
badge = { < EnrollmentBadge organizationDomain = { d } /> }
142
129
trailingComponent = {
143
- showDotMenu ? (
130
+ canManageDomain ? (
144
131
< DomainListDotMenu
145
132
redirectSubPath = { redirectSubPath }
146
133
domainId = { d . id }
0 commit comments