Skip to content

Commit 03c47db

Browse files
committed
tweaking how we style
only checking admin and read for final tenant
1 parent d765117 commit 03c47db

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

src/components/tables/RowActions/AccessGrants/GrantWhatIsChanging.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function GrantWhatIsChanging({
1717
sx={{
1818
'flexWrap': 'wrap',
1919
'lineBreak': 'anywhere',
20-
'& span:nth-child(odd)': {
20+
'& span:nth-of-type(odd)': {
2121
fontWeight: 500,
2222
},
2323
}}

src/components/tables/RowActions/Shared/ConfirmationWithExplination.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ import { useIntl } from 'react-intl';
1818
import { AccessGrantRowConfirmation } from '../AccessGrants/types';
1919
import { ConfirmationWithExplinationProps } from './types';
2020

21-
const leftSideWidth = '50%';
22-
const rightSideWidth = '50%';
23-
2421
function ConfirmationWithExplination({
2522
message,
2623
selected,
@@ -60,6 +57,8 @@ function ConfirmationWithExplination({
6057
sx={{
6158
color,
6259
fontWeight,
60+
pr: 0,
61+
textAlign: 'right',
6362
}}
6463
>
6564
{dangerous ? <WarningTriangle /> : null}
@@ -102,13 +101,13 @@ function ConfirmationWithExplination({
102101
<Table size="small" sx={{ ml: 2 }}>
103102
<TableHead>
104103
<TableRow style={{ width: '100%' }}>
105-
<TableCell style={{ width: leftSideWidth }}>
104+
<TableCell style={{ width: '50%' }}>
106105
{intl.formatMessage({
107106
id: 'accessGrants.actions.extra.confirmation.whatIsChanging',
108107
})}
109108
</TableCell>
110109
<TableCell />
111-
<TableCell style={{ width: rightSideWidth }}>
110+
<TableCell style={{ width: '50%' }}>
112111
{intl.formatMessage({
113112
id: 'accessGrants.actions.extra.confirmation.whatThatMeans',
114113
})}

src/hooks/useAccessGrantRemovalDescriptions.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { useUserStore } from 'context/User/useUserContextStore';
22
import { useCallback, useMemo } from 'react';
33
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';
58
import { BaseGrant, Grant_UserExt } from 'types';
69
import { ESTUARY_SUPPORT_ROLE, isGrant_UserExt } from 'utils/misc-utils';
710
import { useShallow } from 'zustand/react/shallow';
@@ -25,10 +28,9 @@ function useAccessGrantRemovalDescriptions() {
2528
);
2629

2730
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]);
3234

3335
const describeAccessGrantRemovals = useCallback(
3436
(value: Grant_UserExt | BaseGrant): AccessGrantRemovalDescription => {
@@ -41,7 +43,10 @@ function useAccessGrantRemovalDescriptions() {
4143
// Figure out what the of the grant is
4244
if (isGrant_UserExt(value)) {
4345
if (value.user_email === userEmail) {
44-
if (probablyNewUser) {
46+
if (
47+
(singleAdmin && what === 'admin') ||
48+
(singleReadable && what === 'read')
49+
) {
4550
grantScope = 'finalEmail';
4651
} else {
4752
grantScope = 'ownEmail';
@@ -81,7 +86,7 @@ function useAccessGrantRemovalDescriptions() {
8186
}),
8287
];
8388
},
84-
[intl, probablyNewUser, userEmail]
89+
[intl, singleAdmin, singleReadable, userEmail]
8590
);
8691

8792
return {

src/lang/en-US/AccessGrants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export const AccessGrants: Record<string, string> = {
6161
'accessGrants.descriptions.removing.read.email': `${prefixes.email} see anything on the tenant.`,
6262

6363
// When a user removes their own email and it is the last one they have
64+
// We do not check if they are removing their final "write"
6465
'accessGrants.descriptions.removing.admin.finalEmail': `${prefixes.finalEmail} create or manage ${suffixes.finalEmail}`,
65-
'accessGrants.descriptions.removing.write.finalEmail': `${prefixes.finalEmail} create ${suffixes.finalEmail}`,
6666
'accessGrants.descriptions.removing.read.finalEmail': `${prefixes.finalEmail} view ${suffixes.finalEmail}`,
6767

6868
// When a user removes their own email

src/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export interface InferredSchemas {
263263
}
264264

265265
export interface BaseGrant {
266-
capability: string;
266+
capability: Capability;
267267
object_role: string;
268268
subject_role: string;
269269
}

0 commit comments

Comments
 (0)