@@ -3,8 +3,8 @@ import type { ReactNode } from 'react';
33import { c } from 'ttag' ;
44
55import { Button } from '@proton/atoms/Button/Button' ;
6- import { Tooltip } from '@proton/atoms/Tooltip/Tooltip' ;
76import Info from '@proton/components/components/link/Info' ;
7+ import withPermissionGuard from '@proton/components/components/orgPermissions/withPermissionGuard' ;
88import { SetupOrgSpotlight } from '@proton/components/containers/account/spotlights/passB2bOnboardingSpotlights/PassB2bOnboardingSpotlights' ;
99import {
1010 getInvitationAcceptLimit ,
@@ -13,6 +13,9 @@ import {
1313import type { UseUserMemberActions } from '@proton/components/containers/members/UsersAndAddressesSection/useMemberActions' ;
1414import type { APP_NAMES } from '@proton/shared/lib/constants' ;
1515
16+ const GuardedAddUserButton = withPermissionGuard ( 'account.user.create' ) ( Button ) ;
17+ const GuardedAddAddressButton = withPermissionGuard ( 'account.user.update' ) ( Button ) ;
18+
1619export const MembersTableHeader = ( {
1720 app,
1821 searchInput,
@@ -23,13 +26,9 @@ export const MembersTableHeader = ({
2326 membersHook : UseUserMemberActions ;
2427} ) => {
2528 const createUserButtonWithTooltip = (
26- < Tooltip title = { ! meta . canAddUser ? c ( 'Label' ) . t `You don't have permissions` : undefined } openDelay = { 100 } >
27- < span >
28- < Button color = "norm" disabled = { meta . disableAddUserButton } onClick = { actions . handleAddUser } >
29- { c ( 'Action' ) . t `Add user` }
30- </ Button >
31- </ span >
32- </ Tooltip >
29+ < GuardedAddUserButton color = "norm" disabled = { meta . disableAddUserButton } onClick = { actions . handleAddUser } >
30+ { c ( 'Action' ) . t `Add user` }
31+ </ GuardedAddUserButton >
3332 ) ;
3433 return (
3534 < div className = "mb-4 flex items-start" >
@@ -43,20 +42,13 @@ export const MembersTableHeader = ({
4342 { meta . showAddAddress && (
4443 < >
4544 { meta . isOrgAFamilyPlan ? (
46- < Tooltip
47- title = { ! meta . canAddUser ? c ( 'Label' ) . t `You don't have permissions` : undefined }
48- openDelay = { 100 }
45+ < GuardedAddUserButton
46+ color = "norm"
47+ disabled = { meta . disableInviteUserButton }
48+ onClick = { actions . handleInviteUser }
4949 >
50- < span >
51- < Button
52- color = "norm"
53- disabled = { meta . disableInviteUserButton }
54- onClick = { actions . handleInviteUser }
55- >
56- { c ( 'Action' ) . t `Invite user` }
57- </ Button >
58- </ span >
59- </ Tooltip >
50+ { c ( 'Action' ) . t `Invite user` }
51+ </ GuardedAddUserButton >
6052 ) : (
6153 createUserButtonWithTooltip
6254 ) }
@@ -75,20 +67,13 @@ export const MembersTableHeader = ({
7567 ) ) }
7668
7769 { meta . hasMaxAddresses && (
78- < Tooltip
79- title = { ! meta . canUpdateUser ? c ( 'Label' ) . t `You don't have permissions` : undefined }
80- openDelay = { 100 }
70+ < GuardedAddAddressButton
71+ shape = "outline"
72+ disabled = { meta . disableAddAddressButton }
73+ onClick = { ( ) => actions . handleAddAddress ( ) }
8174 >
82- < span >
83- < Button
84- shape = "outline"
85- disabled = { meta . disableAddAddressButton }
86- onClick = { ( ) => actions . handleAddAddress ( ) }
87- >
88- { c ( 'Action' ) . t `Add address` }
89- </ Button >
90- </ span >
91- </ Tooltip >
75+ { c ( 'Action' ) . t `Add address` }
76+ </ GuardedAddAddressButton >
9277 ) }
9378 </ >
9479 ) }
0 commit comments