Display confirmation dialog on connected account deletion (#10323)

![deleteConfirmation](https://github.com/user-attachments/assets/1f0fea78-d02c-4351-b79f-733c08e0e0ec)

Fairly straightforward change, it's my first contribution in this
project so tried to follow the existing patterns.
I couldn't find any component tests or e2e Playwright tests touching
this area to update - happy to write some from scratch if necessary!

Closes #10285

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
Alex Motoc
2025-02-19 15:29:10 +00:00
committed by GitHub
parent 7bf851b29b
commit ad47ab5bcd
2 changed files with 69 additions and 43 deletions

View File

@ -104,6 +104,9 @@ jobs:
npx nx run twenty-emails:lingui:compile
npx nx run twenty-front:lingui:compile
- name: Debug git status
run: git status
- name: Check and commit compiled files
id: check_changes
run: |

View File

@ -1,3 +1,4 @@
import { useState } from 'react';
import {
IconCalendarEvent,
IconDotsVertical,
@ -16,6 +17,7 @@ import { SettingsPath } from '@/types/SettingsPath';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
type SettingsAccountsRowDropdownMenuProps = {
@ -27,6 +29,9 @@ export const SettingsAccountsRowDropdownMenu = ({
}: SettingsAccountsRowDropdownMenuProps) => {
const dropdownId = `settings-account-row-${account.id}`;
const [isDeleteAccountModalOpen, setIsDeleteAccountModalOpen] =
useState(false);
const navigate = useNavigateSettings();
const { closeDropdown } = useDropdown(dropdownId);
@ -35,54 +40,72 @@ export const SettingsAccountsRowDropdownMenu = ({
});
const { triggerApisOAuth } = useTriggerApisOAuth();
const deleteAccount = async () => {
await destroyOneRecord(account.id);
setIsDeleteAccountModalOpen(false);
};
return (
<Dropdown
dropdownId={dropdownId}
dropdownPlacement="right-start"
dropdownHotkeyScope={{ scope: dropdownId }}
clickableComponent={
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
}
dropdownMenuWidth={160}
dropdownComponents={
<DropdownMenuItemsContainer>
<MenuItem
LeftIcon={IconMail}
text="Emails settings"
onClick={() => {
navigate(SettingsPath.AccountsEmails);
closeDropdown();
}}
/>
<MenuItem
LeftIcon={IconCalendarEvent}
text="Calendar settings"
onClick={() => {
navigate(SettingsPath.AccountsCalendars);
closeDropdown();
}}
/>
{account.authFailedAt && (
<>
<Dropdown
dropdownId={dropdownId}
className={className}
dropdownPlacement="right-start"
dropdownHotkeyScope={{ scope: dropdownId }}
clickableComponent={
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
}
dropdownMenuWidth={160}
dropdownComponents={
<DropdownMenuItemsContainer>
<MenuItem
LeftIcon={IconRefresh}
text="Reconnect"
LeftIcon={IconMail}
text="Emails settings"
onClick={() => {
triggerApisOAuth(account.provider);
navigate(SettingsPath.AccountsEmails);
closeDropdown();
}}
/>
)}
<MenuItem
accent="danger"
LeftIcon={IconTrash}
text="Remove account"
onClick={() => {
destroyOneRecord(account.id);
closeDropdown();
}}
/>
</DropdownMenuItemsContainer>
}
/>
<MenuItem
LeftIcon={IconCalendarEvent}
text="Calendar settings"
onClick={() => {
navigate(SettingsPath.AccountsCalendars);
closeDropdown();
}}
/>
{account.authFailedAt && (
<MenuItem
LeftIcon={IconRefresh}
text="Reconnect"
onClick={() => {
triggerApisOAuth(account.provider);
closeDropdown();
}}
/>
)}
<MenuItem
accent="danger"
LeftIcon={IconTrash}
text="Remove account"
onClick={() => {
setIsDeleteAccountModalOpen(true);
closeDropdown();
}}
/>
</DropdownMenuItemsContainer>
}
/>
<ConfirmationModal
isOpen={isDeleteAccountModalOpen}
setIsOpen={setIsDeleteAccountModalOpen}
title="Data deletion"
subtitle={
<>All emails and events linked to this account will be deleted</>
}
onConfirmClick={deleteAccount}
deleteButtonText="Delete account"
/>
</>
);
};