fix: account deletion times out #291

This commit is contained in:
rustmailer
2026-06-07 15:34:38 +08:00
parent 62cb5264fd
commit c736afffb0
29 changed files with 106 additions and 14 deletions
+1
View File
@@ -144,6 +144,7 @@ export interface AccountModel {
imap_quota_bytes?: number;
auto_download_new_mailboxes?: boolean;
download_schedule?: string;
deleting?: boolean;
}
export const download_state = async (account_id: number) => {
@@ -50,13 +50,16 @@ export function DataTableRowActions({ row }: DataTableRowActionsProps) {
const hasPermission = require_any_permission(['system:root', 'account:manage'], row.original.id);
const hasReadPermission = require_any_permission(['system:root', 'account:read_details'], row.original.id);
const isDeleting = row.original.deleting === true;
const canShowAnyAction =
!isDeleting && (
(hasPermission) ||
(account_type === 'IMAP' && hasPermission) ||
(account_type === 'IMAP' && hasReadPermission);
(account_type === 'IMAP' && hasReadPermission)
);
const showDownload = account_type === 'IMAP' && hasPermission;
const showDownload = !isDeleting && account_type === 'IMAP' && hasPermission;
const handleStartDownload = async () => {
try {
@@ -43,8 +43,8 @@ export function AccountDeleteDialog({ open, onOpenChange, currentRow }: Props) {
const queryClient = useQueryClient();
function handleSuccess() {
toast({
title: t('dialogs.accountDeleted'),
description: t('dialogs.accountDeletedDesc'),
title: t('dialogs.accountDeletionStarted'),
description: t('dialogs.accountDeletionStartedDesc'),
action: <ToastAction altText={t('common.close')}>{t('common.close')}</ToastAction>,
});
@@ -77,7 +77,7 @@ export function EnableAction({ row }: DataTableRowActionsProps) {
<Switch
checked={row.original.enabled}
onCheckedChange={() => setOpen(true)}
disabled={!hasPermission || updateMutation.isPending}
disabled={!hasPermission || updateMutation.isPending || row.original.deleting}
/>
<ConfirmDialog
open={open}
@@ -35,6 +35,9 @@ export function RunningStateCellAction({ row }: Props) {
const { setOpen, setCurrentRow } = useAccountContext()
const { require_any_permission } = useCurrentUser()
if (row.original.deleting) {
return <span className="text-xs text-muted-foreground italic">Deleting...</span>
}
let account_type = row.original.account_type;
if (account_type === "NoSync") {
return <span className="text-xs text-muted-foreground">n/a</span>
@@ -127,7 +127,7 @@ export function AccountTable({ columns, data }: DataTableProps) {
<TableRow
key={row.id}
data-state={row.getIsSelected() && 'selected'}
className='group/row'
className={row.original.deleting ? 'opacity-50' : 'group/row'}
>
{row.getVisibleCells().map((cell) => (
<TableCell
+4
View File
@@ -55,6 +55,10 @@ export default function Accounts() {
const { data: accountList, isLoading } = useQuery({
queryKey: ['account-list'],
queryFn: list_accounts,
refetchInterval: (query) => {
const items = (query.state.data as { items?: { deleting?: boolean }[] })?.items;
return items?.some((item) => item.deleting) ? 5000 : false;
},
})
const hasAccounts = accountList != null && accountList.items.length > 0;
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "فشل حذف الحساب",
"accountDeleted": "تم حذف الحساب",
"accountDeletedDesc": "تم حذف حسابك بنجاح.",
"accountDeletionStarted": "بدء حذف الحساب",
"accountDeletionStartedDesc": "جاري حذف الحساب في الخلفية، وسيختفي بعد اكتمال التنظيف.",
"allResourcesErased": "سيتم مسح جميع الموارد ذات الصلة نهائيًا.",
"cannotBeUndone": "لا يمكن التراجع عن هذا الإجراء!",
"confirmDelete": "تأكيد الحذف",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Sletning af konto mislykkedes",
"accountDeleted": "Konto slettet",
"accountDeletedDesc": "Din konto er blevet slettet.",
"accountDeletionStarted": "Kontoen slettes nu",
"accountDeletionStartedDesc": "Kontoen slettes i baggrunden og forsvinder, når oprydningen er færdig.",
"allResourcesErased": "Alle relaterede ressourcer vil blive slettet permanent.",
"cannotBeUndone": "Denne handling kan ikke fortrydes!",
"confirmDelete": "Bekræft Sletning",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Löschen des Kontos fehlgeschlagen",
"accountDeleted": "Konto gelöscht",
"accountDeletedDesc": "Ihr Konto wurde erfolgreich gelöscht.",
"accountDeletionStarted": "Kontolöschung gestartet",
"accountDeletionStartedDesc": "Konto wird im Hintergrund gelöscht und verschwindet nach der Bereinigung.",
"allResourcesErased": "Alle zugehörigen Ressourcen werden dauerhaft gelöscht.",
"cannotBeUndone": "Diese Aktion kann nicht rückgängig gemacht werden!",
"confirmDelete": "Löschung bestätigen",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Account delete Failed",
"accountDeleted": "Account Deleted",
"accountDeletedDesc": "Your account has been successfully deleted.",
"accountDeletionStarted": "Account deletion started",
"accountDeletionStartedDesc": "Account is being deleted in the background and will disappear after cleanup.",
"allResourcesErased": "All related resources will be permanently erased.",
"cannotBeUndone": "This action cannot be undone!",
"confirmDelete": "Confirm Delete",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Error al eliminar la cuenta",
"accountDeleted": "Cuenta eliminada",
"accountDeletedDesc": "Tu cuenta ha sido eliminada con éxito.",
"accountDeletionStarted": "Eliminación de cuenta iniciada",
"accountDeletionStartedDesc": "La cuenta se está eliminando en segundo plano y desaparecerá tras la limpieza.",
"allResourcesErased": "Todos los recursos asociados se borrarán permanentemente.",
"cannotBeUndone": "¡Esta acción no se puede deshacer!",
"confirmDelete": "Confirmar eliminación",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Tilin poistaminen epäonnistui",
"accountDeleted": "Tili poistettu",
"accountDeletedDesc": "Tilisi on poistettu onnistuneesti.",
"accountDeletionStarted": "Tilin poistaminen aloitettu",
"accountDeletionStartedDesc": "Tiliä poistetaan taustalla. Se katoaa, kun puhdistus on valmis.",
"allResourcesErased": "Kaikki liittyvät resurssit poistetaan pysyvästi.",
"cannotBeUndone": "Tätä toimenpidettä ei voi kumota!",
"confirmDelete": "Vahvista poisto",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Échec de la suppression du compte",
"accountDeleted": "Compte Supprimé",
"accountDeletedDesc": "Votre compte a été supprimé avec succès.",
"accountDeletionStarted": "Suppression du compte lancée",
"accountDeletionStartedDesc": "Compte en cours de suppression en arrière-plan, disparaîtra après nettoyage.",
"allResourcesErased": "Toutes les ressources associées seront effacées définitivement.",
"cannotBeUndone": "Cette action ne peut pas être annulée !",
"confirmDelete": "Confirmer la Suppression",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Eliminazione account fallita",
"accountDeleted": "Account Eliminato",
"accountDeletedDesc": "Il tuo account è stato eliminato con successo.",
"accountDeletionStarted": "Eliminazione account avviata",
"accountDeletionStartedDesc": "L'account è in fase di eliminazione in background e scomparirà dopo la pulizia.",
"allResourcesErased": "Tutte le risorse correlate verranno cancellate permanentemente.",
"cannotBeUndone": "Questa azione non può essere annullata!",
"confirmDelete": "Conferma Eliminazione",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "アカウントの削除に失敗しました",
"accountDeleted": "アカウントが削除されました",
"accountDeletedDesc": "アカウントが正常に削除されました。",
"accountDeletionStarted": "アカウントの削除を開始しました",
"accountDeletionStartedDesc": "バックグラウンドで削除中です。完了するとリストから消えます。",
"allResourcesErased": "関連するすべてのリソースは完全に消去されます。",
"cannotBeUndone": "この操作は元に戻せません!",
"confirmDelete": "削除の確認",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "계정 삭제 실패",
"accountDeleted": "계정 삭제됨",
"accountDeletedDesc": "계정이 성공적으로 삭제되었습니다.",
"accountDeletionStarted": "계정 삭제 시작됨",
"accountDeletionStartedDesc": "백그라운드에서 삭제 중이며, 정리가 끝나면 목록에서 사라집니다.",
"allResourcesErased": "모든 관련 리소스가 영구적으로 지워집니다.",
"cannotBeUndone": "이 작업은 되돌릴 수 없습니다!",
"confirmDelete": "삭제 확인",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Account verwijderen Mislukt",
"accountDeleted": "Account Verwijderd",
"accountDeletedDesc": "Uw account is succesvol verwijderd.",
"accountDeletionStarted": "Verwijdering account gestart",
"accountDeletionStartedDesc": "Account wordt op de achtergrond verwijderd en verdwijnt na opschonen.",
"allResourcesErased": "Alle gerelateerde bronnen worden permanent gewist.",
"cannotBeUndone": "Deze actie kan niet ongedaan worden gemaakt!",
"confirmDelete": "Verwijdering Bevestigen",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Sletting av konto mislyktes",
"accountDeleted": "Konto slettet",
"accountDeletedDesc": "Kontoen din har blitt slettet.",
"accountDeletionStarted": "Kontosletting startet",
"accountDeletionStartedDesc": "Kontoen slettes i bakgrunnen og forsvinner når opprydningen er ferdig.",
"allResourcesErased": "Alle relaterte ressurser vil bli permanent slettet.",
"cannotBeUndone": "Denne handlingen kan ikke angres!",
"confirmDelete": "Bekreft sletting",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Bład podczas usuwania konta",
"accountDeleted": "Konto usunięte",
"accountDeletedDesc": "Konto zostało usunięte.",
"accountDeletionStarted": "Rozpoczęto usuwanie konta",
"accountDeletionStartedDesc": "Konto jest usuwane w tle i zniknie po zakończeniu czyszczenia.",
"allResourcesErased": "Wszystkie powiązane zasoby zostaną trwale usunięte.",
"cannotBeUndone": "Tej czynności nie można cofnąć!",
"confirmDelete": "Potwierdź usunięcie",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Falha ao Excluir Conta",
"accountDeleted": "Conta Excluída",
"accountDeletedDesc": "A conta foi excluída com sucesso.",
"accountDeletionStarted": "Exclusão da conta iniciada",
"accountDeletionStartedDesc": "A conta está sendo excluída em segundo plano e desaparecerá após a limpeza.",
"allResourcesErased": "Todos os recursos relacionados serão permanentemente apagados.",
"cannotBeUndone": "Esta ação não pode ser desfeita!",
"confirmDelete": "Confirmar Exclusão",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Ошибка удаления аккаунта",
"accountDeleted": "Аккаунт удален",
"accountDeletedDesc": "Ваш аккаунт был успешно удален.",
"accountDeletionStarted": "Удаление аккаунта запущено",
"accountDeletionStartedDesc": "Аккаунт удаляется в фоновом режиме и исчезнет после очистки.",
"allResourcesErased": "Все связанные ресурсы будут безвозвратно стерты.",
"cannotBeUndone": "Это действие нельзя отменить!",
"confirmDelete": "Подтвердить удаление",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "Borttagning av konto misslyckades",
"accountDeleted": "Konto raderat",
"accountDeletedDesc": "Ditt konto har tagits bort.",
"accountDeletionStarted": "Kontoradering har startat",
"accountDeletionStartedDesc": "Kontot raderas i bakgrunden och försvinner när rensningen är klar.",
"allResourcesErased": "Alla relaterade resurser kommer att raderas permanent.",
"cannotBeUndone": "Denna åtgärd kan inte ångras!",
"confirmDelete": "Bekräfta borttagning",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "帳號刪除失敗",
"accountDeleted": "帳號已刪除",
"accountDeletedDesc": "帳號已成功刪除。",
"accountDeletionStarted": "帳戶刪除已開始",
"accountDeletionStartedDesc": "帳戶正在背景刪除,清理完成後將從列表中消失。",
"allResourcesErased": "所有相關資源將被永久清除。",
"cannotBeUndone": "此操作無法復原!",
"confirmDelete": "確認刪除",
+2
View File
@@ -536,6 +536,8 @@
"accountDeleteFailed": "账户删除失败",
"accountDeleted": "账户已删除",
"accountDeletedDesc": "您的账户已成功删除。",
"accountDeletionStarted": "账户删除已开始",
"accountDeletionStartedDesc": "账户正在后台删除,清理完成后将从列表中消失。",
"allResourcesErased": "所有相关资源将被永久删除。",
"cannotBeUndone": "此操作无法撤销!",
"confirmDelete": "确认删除",