Display confirmation dialog on connected account deletion (#10323)
 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:
3
.github/workflows/i18n-pull.yaml
vendored
3
.github/workflows/i18n-pull.yaml
vendored
@ -104,6 +104,9 @@ jobs:
|
|||||||
npx nx run twenty-emails:lingui:compile
|
npx nx run twenty-emails:lingui:compile
|
||||||
npx nx run twenty-front:lingui:compile
|
npx nx run twenty-front:lingui:compile
|
||||||
|
|
||||||
|
- name: Debug git status
|
||||||
|
run: git status
|
||||||
|
|
||||||
- name: Check and commit compiled files
|
- name: Check and commit compiled files
|
||||||
id: check_changes
|
id: check_changes
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
IconCalendarEvent,
|
IconCalendarEvent,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
@ -16,6 +17,7 @@ import { SettingsPath } from '@/types/SettingsPath';
|
|||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
|
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||||
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||||
|
|
||||||
type SettingsAccountsRowDropdownMenuProps = {
|
type SettingsAccountsRowDropdownMenuProps = {
|
||||||
@ -27,6 +29,9 @@ export const SettingsAccountsRowDropdownMenu = ({
|
|||||||
}: SettingsAccountsRowDropdownMenuProps) => {
|
}: SettingsAccountsRowDropdownMenuProps) => {
|
||||||
const dropdownId = `settings-account-row-${account.id}`;
|
const dropdownId = `settings-account-row-${account.id}`;
|
||||||
|
|
||||||
|
const [isDeleteAccountModalOpen, setIsDeleteAccountModalOpen] =
|
||||||
|
useState(false);
|
||||||
|
|
||||||
const navigate = useNavigateSettings();
|
const navigate = useNavigateSettings();
|
||||||
const { closeDropdown } = useDropdown(dropdownId);
|
const { closeDropdown } = useDropdown(dropdownId);
|
||||||
|
|
||||||
@ -35,54 +40,72 @@ export const SettingsAccountsRowDropdownMenu = ({
|
|||||||
});
|
});
|
||||||
const { triggerApisOAuth } = useTriggerApisOAuth();
|
const { triggerApisOAuth } = useTriggerApisOAuth();
|
||||||
|
|
||||||
|
const deleteAccount = async () => {
|
||||||
|
await destroyOneRecord(account.id);
|
||||||
|
setIsDeleteAccountModalOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<>
|
||||||
dropdownId={dropdownId}
|
<Dropdown
|
||||||
dropdownPlacement="right-start"
|
dropdownId={dropdownId}
|
||||||
dropdownHotkeyScope={{ scope: dropdownId }}
|
className={className}
|
||||||
clickableComponent={
|
dropdownPlacement="right-start"
|
||||||
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
dropdownHotkeyScope={{ scope: dropdownId }}
|
||||||
}
|
clickableComponent={
|
||||||
dropdownMenuWidth={160}
|
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
||||||
dropdownComponents={
|
}
|
||||||
<DropdownMenuItemsContainer>
|
dropdownMenuWidth={160}
|
||||||
<MenuItem
|
dropdownComponents={
|
||||||
LeftIcon={IconMail}
|
<DropdownMenuItemsContainer>
|
||||||
text="Emails settings"
|
|
||||||
onClick={() => {
|
|
||||||
navigate(SettingsPath.AccountsEmails);
|
|
||||||
closeDropdown();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<MenuItem
|
|
||||||
LeftIcon={IconCalendarEvent}
|
|
||||||
text="Calendar settings"
|
|
||||||
onClick={() => {
|
|
||||||
navigate(SettingsPath.AccountsCalendars);
|
|
||||||
closeDropdown();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{account.authFailedAt && (
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
LeftIcon={IconRefresh}
|
LeftIcon={IconMail}
|
||||||
text="Reconnect"
|
text="Emails settings"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
triggerApisOAuth(account.provider);
|
navigate(SettingsPath.AccountsEmails);
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
<MenuItem
|
||||||
<MenuItem
|
LeftIcon={IconCalendarEvent}
|
||||||
accent="danger"
|
text="Calendar settings"
|
||||||
LeftIcon={IconTrash}
|
onClick={() => {
|
||||||
text="Remove account"
|
navigate(SettingsPath.AccountsCalendars);
|
||||||
onClick={() => {
|
closeDropdown();
|
||||||
destroyOneRecord(account.id);
|
}}
|
||||||
closeDropdown();
|
/>
|
||||||
}}
|
{account.authFailedAt && (
|
||||||
/>
|
<MenuItem
|
||||||
</DropdownMenuItemsContainer>
|
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"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user