Add album view and bulk actions to Review
The Review list can now be grouped by album (disc folders folded in), showing per-album counts of upgrades, identical files, downgrades and approximate matches. Whole albums or individual songs can be selected and linked, promoted, ignored or un-ignored in one action. Every bulk action is previewed server-side first: how many songs will be processed, which are skipped and why, and warnings with examples for downgrades, approximate matches, duration mismatches, folder moves and renames. Downgrades are excluded unless explicitly included, and replacing master files requires an acknowledgement. Link and promote run as a background job that re-plans each song and uses the normal single-item operation, so all preflight checks still apply. IDs from another pair are refused and duplicates are ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ae4e85bd2
commit
1d31999793
9 files changed
+1209
-7
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { AlertTriangle, ArrowRight, ArrowUpCircle, Download, ChevronDown, ChevronRight, CopyCheck, EyeOff, Eye, Link2, Search, Crown } from "lucide-react";
|
||||
import { AlertTriangle, ArrowRight, ArrowUpCircle, Disc3, Download, ListMusic, ChevronDown, ChevronRight, CopyCheck, EyeOff, Eye, Link2, Search, Crown } from "lucide-react";
|
||||
import { ApiError, api, type Match, type Page, type Pair, type ProbeInfo } from "../api";
|
||||
import { Alert, Badge, Button, Card, Empty, Modal, Spinner, cx, formatBytes, formatDuration, inputCls, statusTone } from "../ui";
|
||||
import { useToast } from "../toast";
|
||||
import { AlbumView, BulkBar, TriCheckbox, toggleIDs, type Selection } from "./Bulk";
|
||||
|
||||
const filters = [
|
||||
{ id: "review", label: "Needs review" },
|
||||
@@ -41,12 +42,30 @@ export function Review({ pair }: { pair: Pair }) {
|
||||
const [debounced, setDebounced] = useState("");
|
||||
const [page, setPage] = useState(0);
|
||||
const [confirmBulk, setConfirmBulk] = useState(false);
|
||||
const [view, setView] = useState<"songs" | "albums">(() => {
|
||||
try {
|
||||
return localStorage.getItem("playlink.reviewView") === "albums" ? "albums" : "songs";
|
||||
} catch {
|
||||
return "songs";
|
||||
}
|
||||
});
|
||||
const [sel, setSel] = useState<Selection>(new Set());
|
||||
const chooseView = (v: "songs" | "albums") => {
|
||||
setView(v);
|
||||
try {
|
||||
localStorage.setItem("playlink.reviewView", v);
|
||||
} catch {
|
||||
/* private mode: the choice just isn't remembered */
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setDebounced(q), 250);
|
||||
return () => clearTimeout(t);
|
||||
}, [q]);
|
||||
useEffect(() => setPage(0), [status, debounced]);
|
||||
// A selection only makes sense for the list it was made in.
|
||||
useEffect(() => setSel(new Set()), [status, debounced, pair.id]);
|
||||
|
||||
const list = useQuery({
|
||||
queryKey: ["matches", pair.id, status, debounced, page],
|
||||
@@ -91,6 +110,20 @@ export function Review({ pair }: { pair: Pair }) {
|
||||
<Search className="absolute left-2.5 top-2.5 size-4 text-muted" />
|
||||
<input className={inputCls + " pl-8"} placeholder="Filter by path…" value={q} onChange={(e) => setQ(e.target.value)} />
|
||||
</div>
|
||||
<div className="flex rounded-lg border border-line p-0.5" role="tablist" aria-label="Group by">
|
||||
{(["songs", "albums"] as const).map((v) => (
|
||||
<button
|
||||
key={v}
|
||||
role="tab"
|
||||
aria-selected={view === v}
|
||||
onClick={() => chooseView(v)}
|
||||
className={cx("flex items-center gap-1 rounded-md px-2.5 py-1 text-xs capitalize cursor-pointer", view === v ? "bg-panel-2 text-white" : "text-muted hover:text-white")}
|
||||
>
|
||||
{v === "songs" ? <ListMusic className="size-3.5" /> : <Disc3 className="size-3.5" />}
|
||||
{v}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<ExportMenu pairId={pair.id} status={status} query={debounced} viewCount={list.data?.total} filterLabel={filters.find((f) => f.id === status)?.label ?? "All"} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -107,7 +140,23 @@ export function Review({ pair }: { pair: Pair }) {
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{view === "albums" ? (
|
||||
<AlbumView pair={pair} status={status} query={debounced} sel={sel} setSel={setSel} />
|
||||
) : (
|
||||
<>
|
||||
<Card className="overflow-hidden">
|
||||
{list.data && list.data.items.length > 0 && (
|
||||
<label className="flex items-center gap-3 border-b border-line bg-panel-2 px-4 py-2 text-xs text-muted">
|
||||
<TriCheckbox
|
||||
label="Select all songs on this page"
|
||||
checked={list.data.items.every((m) => sel.has(m.id))}
|
||||
partial={list.data.items.some((m) => sel.has(m.id))}
|
||||
onChange={(v) => setSel(toggleIDs(sel, list.data!.items.map((m) => m.id), v))}
|
||||
/>
|
||||
Select all {list.data.items.length} songs on this page
|
||||
<span className="text-gray-600">· switch to Albums to select whole albums</span>
|
||||
</label>
|
||||
)}
|
||||
{list.isLoading && (
|
||||
<div className="p-8">
|
||||
<Spinner />
|
||||
@@ -118,7 +167,9 @@ export function Review({ pair }: { pair: Pair }) {
|
||||
{pair.last_scan_at ? "No files match this filter." : "Run a scan to compare the two libraries."}
|
||||
</Empty>
|
||||
)}
|
||||
{list.data?.items.map((m) => <MatchRow key={m.id} m={m} />)}
|
||||
{list.data?.items.map((m) => (
|
||||
<MatchRow key={m.id} m={m} selected={sel.has(m.id)} onToggle={(v) => setSel(toggleIDs(sel, [m.id], v))} />
|
||||
))}
|
||||
</Card>
|
||||
|
||||
{list.data && list.data.total > PAGE && (
|
||||
@@ -136,6 +187,10 @@ export function Review({ pair }: { pair: Pair }) {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<BulkBar pair={pair} status={status} sel={sel} clear={() => setSel(new Set())} />
|
||||
|
||||
<Modal open={confirmBulk} onClose={() => setConfirmBulk(false)} title="Link all identical files?">
|
||||
<p className="text-sm text-gray-300">
|
||||
@@ -212,7 +267,7 @@ function qualityLabel(p?: ProbeInfo) {
|
||||
return `${p.codec.toUpperCase()} ${Math.round(p.bitrate / 1000)}k`;
|
||||
}
|
||||
|
||||
function MatchRow({ m }: { m: Match }) {
|
||||
export function MatchRow({ m, selected, onToggle }: { m: Match; selected?: boolean; onToggle?: (v: boolean) => void }) {
|
||||
const reviewable = m.status === "different" || m.status === "similar";
|
||||
const [open, setOpen] = useState(false);
|
||||
const qc = useQueryClient();
|
||||
@@ -237,7 +292,16 @@ function MatchRow({ m }: { m: Match }) {
|
||||
|
||||
return (
|
||||
<div className="border-b border-line last:border-0">
|
||||
<div className="flex items-center gap-3 px-4 py-2.5">
|
||||
<div className={cx("flex items-center gap-3 px-4 py-2.5", selected && "bg-accent/5")}>
|
||||
{onToggle && (
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={`Select ${m.rel_slave}`}
|
||||
className="size-4 shrink-0 accent-violet-500 cursor-pointer"
|
||||
checked={!!selected}
|
||||
onChange={(e) => onToggle(e.target.checked)}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
className={cx("text-muted", reviewable ? "cursor-pointer hover:text-white" : "invisible")}
|
||||
onClick={() => setOpen(!open)}
|
||||
|
||||
Reference in new issue
Block a user