Add unlimited option to backup retention setting

- Add "unlimited" (value 0) to the keeping-last dropdown
- Skip pruning when retention is set to unlimited
- Show toast confirmation when changing retention
- Update description to read "Keeping unlimited backups" or "Keeping last N backups"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 16:31:51 -05:00
co-authored by Claude Opus 4.6
parent 0794bca301
commit 0a0e7dfc47
3 changed files with 14 additions and 7 deletions
+2 -2
View File
@@ -188,8 +188,8 @@ export async function getScheduledBackupSettings(): Promise<{
export async function setMaxBackupsAction(max: number): Promise<void> {
await getAdminSession();
if (max < 1 || max > 30)
throw new Error("Max backups must be between 1 and 30");
if (max < 0 || (max > 30 && max !== 0))
throw new Error("Max backups must be between 1 and 30, or 0 for unlimited");
setSetting("maxBackupRetention", String(max));
}
@@ -259,6 +259,11 @@ export function BackupSection({
setMaxRetention(value);
try {
await setMaxBackupsAction(value);
toast.success(
value === 0
? "Keeping unlimited backups"
: `Keeping last ${value} backups`,
);
} catch {
setMaxRetention(previous);
toast.error("Failed to update retention setting");
@@ -463,10 +468,12 @@ export function BackupSection({
<span suppressHydrationWarning>
{formatNextBackup(frequency, time, dow)}.
</span>{" "}
Keeping last{" "}
Keeping{" "}
<DropdownMenu>
<DropdownMenuTrigger className="inline-flex cursor-pointer items-center gap-0.5 border-b border-dotted border-muted-foreground/50 transition-colors hover:text-foreground">
{maxRetention}
{maxRetention === 0
? "unlimited"
: `last ${maxRetention}`}
<IconChevronDown className="size-2.5" />
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
@@ -476,9 +483,9 @@ export function BackupSection({
handleMaxRetentionChange(Number(v))
}
>
{[3, 5, 7, 14, 30].map((n) => (
{[3, 5, 7, 14, 30, 0].map((n) => (
<DropdownMenuRadioItem key={n} value={String(n)}>
{n}
{n === 0 ? "unlimited" : n}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>