Skip to content

Commit bdf62e2

Browse files
committed
🔥(frontend) remove button delete invitation
We can already remove a invitation directly from the role dropdown, so having a delete button in the more actions menu is redundant.
1 parent 29104df commit bdf62e2

File tree

2 files changed

+15
-70
lines changed

2 files changed

+15
-70
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-member-create.spec.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test.describe('Document create member', () => {
8484

8585
// Validate
8686
await page.getByRole('menuitem', { name: 'Administrator' }).click();
87-
await page.getByRole('button', { name: /^Invite / }).click();
87+
await page.getByTestId('doc-share-invite-button').click();
8888

8989
// Check invitation added
9090
await expect(
@@ -135,7 +135,7 @@ test.describe('Document create member', () => {
135135
(response) =>
136136
response.url().includes('/invitations/') && response.status() === 201,
137137
);
138-
await page.getByRole('button', { name: /^Invite / }).click();
138+
await page.getByTestId('doc-share-invite-button').click();
139139

140140
// Check invitation sent
141141

@@ -154,7 +154,7 @@ test.describe('Document create member', () => {
154154
response.url().includes('/invitations/') && response.status() === 400,
155155
);
156156

157-
await page.getByRole('button', { name: /^Invite / }).click();
157+
await page.getByTestId('doc-share-invite-button').click();
158158
await expect(
159159
page.getByText(`"${email}" is already invited to the document.`),
160160
).toBeVisible();
@@ -191,7 +191,7 @@ test.describe('Document create member', () => {
191191
response.url().includes('/invitations/') && response.status() === 201,
192192
);
193193

194-
await page.getByRole('button', { name: /^Invite / }).click();
194+
await page.getByTestId('doc-share-invite-button').click();
195195

196196
// Check invitation sent
197197
const responseCreateInvitation = await responsePromiseCreateInvitation;
@@ -216,12 +216,8 @@ test.describe('Document create member', () => {
216216
const responsePatchInvitation = await responsePromisePatchInvitation;
217217
expect(responsePatchInvitation.ok()).toBeTruthy();
218218

219-
const moreActions = userInvitation.getByRole('button', {
220-
name: 'Open invitation actions menu',
221-
});
222-
await moreActions.click();
223-
224-
await page.getByRole('menuitem', { name: 'Delete' }).click();
219+
await userInvitation.getByTestId('doc-role-dropdown').click();
220+
await page.getByRole('menuitem', { name: 'Remove access' }).click();
225221

226222
await expect(userInvitation).toBeHidden();
227223
});

src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareInvitation.tsx

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@ import { useMemo } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { css } from 'styled-components';
55

6-
import {
7-
Box,
8-
DropdownMenu,
9-
DropdownMenuOption,
10-
Icon,
11-
IconOptions,
12-
LoadMoreText,
13-
Text,
14-
} from '@/components';
6+
import { Box, BoxButton, Icon, LoadMoreText, Text } from '@/components';
157
import { QuickSearchData, QuickSearchGroup } from '@/components/quick-search';
168
import { useCunninghamTheme } from '@/cunningham';
179
import { Doc, Role } from '@/docs/doc-management';
1810
import { User } from '@/features/auth';
1911

20-
import {
21-
useDeleteDocInvitation,
22-
useDocInvitationsInfinite,
23-
useUpdateDocInvitation,
24-
} from '../api';
12+
import { useDocInvitationsInfinite, useUpdateDocInvitation } from '../api';
2513
import { Invitation } from '../types';
2614

2715
import { DocRoleDropdown } from './DocRoleDropdown';
@@ -61,18 +49,6 @@ export const DocShareInvitationItem = ({
6149
},
6250
});
6351

64-
const { mutate: removeDocInvitation } = useDeleteDocInvitation({
65-
onError: (error) => {
66-
toast(
67-
error?.data?.role?.[0] ?? t('Error during delete invitation'),
68-
VariantType.ERROR,
69-
{
70-
duration: 4000,
71-
},
72-
);
73-
},
74-
});
75-
7652
const onUpdate = (newRole: Role) => {
7753
updateDocInvitation({
7854
docId: doc.id,
@@ -81,19 +57,6 @@ export const DocShareInvitationItem = ({
8157
});
8258
};
8359

84-
const onRemove = () => {
85-
removeDocInvitation({ invitationId: invitation.id, docId: doc.id });
86-
};
87-
88-
const moreActions: DropdownMenuOption[] = [
89-
{
90-
label: t('Delete'),
91-
icon: 'delete',
92-
callback: onRemove,
93-
disabled: !canUpdate,
94-
},
95-
];
96-
9760
return (
9861
<Box
9962
$width="100%"
@@ -116,16 +79,6 @@ export const DocShareInvitationItem = ({
11679
email: invitation.email,
11780
})}
11881
/>
119-
120-
{canUpdate && (
121-
<DropdownMenu
122-
data-testid="doc-share-invitation-more-actions"
123-
options={moreActions}
124-
label={t('Open invitation actions menu')}
125-
>
126-
<IconOptions isHorizontal $variation="600" aria-hidden="true" />
127-
</DropdownMenu>
128-
)}
12982
</Box>
13083
}
13184
/>
@@ -149,26 +102,22 @@ export const DocShareModalInviteUserRow = ({
149102
<SearchUserRow
150103
user={user}
151104
right={
152-
<Box
105+
<BoxButton
153106
className="right-hover"
154107
$direction="row"
155108
$align="center"
156109
$css={css`
157110
contain: content;
158111
`}
159-
$color="var(--c--theme--colors--greyscale-400)"
160-
$cursor="pointer"
112+
$theme="brand"
113+
$variation="tertiary"
114+
$gap="var(--c--globals--spacings--xxxs)"
161115
>
162-
<Text $theme="primary" $variation="800" $size="sm">
116+
<Text $withThemeInherited $size="sm">
163117
{t('Add')}
164118
</Text>
165-
<Icon
166-
$theme="primary"
167-
$variation="800"
168-
iconName="add"
169-
aria-hidden="true"
170-
/>
171-
</Box>
119+
<Icon $withThemeInherited iconName="add" />
120+
</BoxButton>
172121
}
173122
/>
174123
</Box>

0 commit comments

Comments
 (0)