1
1
import { useUserStore } from 'context/User/useUserContextStore' ;
2
2
import { useCallback , useMemo } from 'react' ;
3
3
import { useIntl } from 'react-intl' ;
4
- import { useEntitiesStore_capabilities_adminable } from 'stores/Entities/hooks' ;
4
+ import {
5
+ useEntitiesStore_capabilities_adminable ,
6
+ useEntitiesStore_capabilities_readable ,
7
+ } from 'stores/Entities/hooks' ;
5
8
import { BaseGrant , Grant_UserExt } from 'types' ;
6
9
import { ESTUARY_SUPPORT_ROLE , isGrant_UserExt } from 'utils/misc-utils' ;
7
10
import { useShallow } from 'zustand/react/shallow' ;
@@ -25,10 +28,9 @@ function useAccessGrantRemovalDescriptions() {
25
28
) ;
26
29
27
30
const adminable = useEntitiesStore_capabilities_adminable ( ) ;
28
-
29
- const probablyNewUser = useMemo ( ( ) => adminable . length === 1 , [ adminable ] ) ;
30
-
31
- console . log ( 'adminable' , adminable ) ;
31
+ const readable = useEntitiesStore_capabilities_readable ( ) ;
32
+ const singleAdmin = useMemo ( ( ) => adminable . length === 1 , [ adminable ] ) ;
33
+ const singleReadable = useMemo ( ( ) => readable . length === 1 , [ readable ] ) ;
32
34
33
35
const describeAccessGrantRemovals = useCallback (
34
36
( value : Grant_UserExt | BaseGrant ) : AccessGrantRemovalDescription => {
@@ -41,7 +43,10 @@ function useAccessGrantRemovalDescriptions() {
41
43
// Figure out what the of the grant is
42
44
if ( isGrant_UserExt ( value ) ) {
43
45
if ( value . user_email === userEmail ) {
44
- if ( probablyNewUser ) {
46
+ if (
47
+ ( singleAdmin && what === 'admin' ) ||
48
+ ( singleReadable && what === 'read' )
49
+ ) {
45
50
grantScope = 'finalEmail' ;
46
51
} else {
47
52
grantScope = 'ownEmail' ;
@@ -81,7 +86,7 @@ function useAccessGrantRemovalDescriptions() {
81
86
} ) ,
82
87
] ;
83
88
} ,
84
- [ intl , probablyNewUser , userEmail ]
89
+ [ intl , singleAdmin , singleReadable , userEmail ]
85
90
) ;
86
91
87
92
return {
0 commit comments