"use client"; import { useState, useTransition } from "react"; import { ChevronDown } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "yt-dlp-transcript-common/components/ui/dropdown-menu"; import { clearFinishedLogsAction, type ClearLogsScope } from "../actions"; const OPTIONS: { scope: ClearLogsScope; label: string }[] = [ { scope: "7d", label: "Older than 7 days" }, { scope: "30d", label: "Older than 30 days" }, { scope: "90d", label: "Older than 90 days" }, ]; // Replaces the old (now no-op) "Clear archived logs" button. Prunes finished // job logs by age or all at once; running/queued jobs are never touched (see // pruneJobLogs). The directory also self-trims on job finish, so this is the // manual escape hatch. export function ClearLogsMenu() { const [pending, startTransition] = useTransition(); const [open, setOpen] = useState(false); function clear(scope: ClearLogsScope): void { startTransition(async () => { await clearFinishedLogsAction(scope); }); } return ( {pending ? "Clearing…" : "Clear logs"} {OPTIONS.map((o) => ( clear(o.scope)}> {o.label} ))} clear("all")} > All finished logs ); }