diff --git a/components/mail-transfer/__tests__/transfer-progress.test.ts b/components/mail-transfer/__tests__/transfer-progress.test.ts new file mode 100644 index 000000000..0701429fc --- /dev/null +++ b/components/mail-transfer/__tests__/transfer-progress.test.ts @@ -0,0 +1,8 @@ +import { describe, it, expect } from 'vitest'; +import { serverMegabytes } from '@/components/mail-transfer/transfer-progress'; + +describe('serverMegabytes', () => { + it('names Stalwart\'s upload quota as the server does', () => { + expect(serverMegabytes(50_000_000)).toBe('50 MB'); + }); +}); diff --git a/components/mail-transfer/mail-backup-settings.tsx b/components/mail-transfer/mail-backup-settings.tsx index d1ba7eeaf..facc6e6e9 100644 --- a/components/mail-transfer/mail-backup-settings.tsx +++ b/components/mail-transfer/mail-backup-settings.tsx @@ -1,16 +1,16 @@ "use client"; import { useTranslations } from "next-intl"; -import { SettingItem } from "@/components/settings/settings-section"; +import { SettingItem, SettingsSection } from "@/components/settings/settings-section"; import { Button } from "@/components/ui/button"; import { openMailExport, openMailImport } from "@/stores/mail-transfer-store"; -/** Settings > Backup: bring mail in from files, and save all of it as one file. */ +/** Settings > Backup & reset > Mail files: bring mail in from files, and save all of it as one file. */ export function MailBackupSettings() { const tImport = useTranslations("mail_import"); const tExport = useTranslations("mail_export"); return ( - <> + - + ); } diff --git a/components/mail-transfer/mail-import-dialog.tsx b/components/mail-transfer/mail-import-dialog.tsx index aba661d07..f196ca97c 100644 --- a/components/mail-transfer/mail-import-dialog.tsx +++ b/components/mail-transfer/mail-import-dialog.tsx @@ -14,7 +14,7 @@ import { hasFolders, sniffFormat, type ImportFormat, type SkipReason } from "@/l import type { ImportProgress } from "@/lib/mail-import/engine"; import type { Mailbox } from "@/lib/jmap/types"; import { formatFileSize, getMailboxPath } from "@/lib/utils"; -import { formatClock, TransferBar, useFocusOnStage } from "./transfer-progress"; +import { formatClock, serverMegabytes, TransferBar, useFocusOnStage } from "./transfer-progress"; import { startImport } from "./start-import"; const ACCEPT = ".eml,.zip,.mbox,.mbx,.pst,.ost,message/rfc822,application/zip,application/mbox"; @@ -288,7 +288,7 @@ function ProgressBody({ progress: p, t, locale, statusId }: { progress: ImportPr if (p.phase === "paused" && p.pausedUntil) { const time = formatClock(p.pausedUntil, locale); status = p.quota?.files && p.quota.bytes - ? t("paused", { time, files: p.quota.files, size: formatFileSize(p.quota.bytes) }) + ? t("paused", { time, files: p.quota.files, size: serverMegabytes(p.quota.bytes) }) : t("paused_generic", { time }); } else if (running) { status = p.fileName ? t("reading_file", { name: p.fileName }) : t("running_title"); diff --git a/components/mail-transfer/transfer-progress.tsx b/components/mail-transfer/transfer-progress.tsx index 208810343..1363b9d9e 100644 --- a/components/mail-transfer/transfer-progress.tsx +++ b/components/mail-transfer/transfer-progress.tsx @@ -42,6 +42,11 @@ export function TransferBar({ fraction, label, paused }: { fraction: number | nu ); } +/** A server limit in the server's own unit: Stalwart's 50000000 bytes are "50 MB" (not the 48 MB of a 1024-based size). */ +export function serverMegabytes(bytes: number): string { + return `${Math.round(bytes / 1_000_000)} MB`; +} + /** "14:00", or a date and time when the moment isn't today. */ export function formatClock(ms: number, locale: string, now = Date.now()): string { const date = new Date(ms); diff --git a/components/settings/about-data-settings.tsx b/components/settings/about-data-settings.tsx index 692d0acad..17db44064 100644 --- a/components/settings/about-data-settings.tsx +++ b/components/settings/about-data-settings.tsx @@ -213,10 +213,10 @@ export function AboutDataSettings() { )} - - + +