diff --git a/CLAUDE.md b/CLAUDE.md index a7e1f60..99ddecb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -336,7 +336,7 @@ Two independent apps that talk over HTTP: library meant restarting; switching confirms first when there are unsaved edits, since the adapter holds them in a native model that opening another library replaces — plus the playlist tree + - create/rename/delete), `SaveBar`, `Toolbar` (search/filters + `ColumnsMenu`), + create/rename/delete), `SaveBar` (+ the settings gear beside it), `Toolbar` (search/filters; columns are chosen by right-clicking the table header), `TrackTable` (**the one track list** — All Tracks, playlists, exports and devices. TanStack Table + **virtualized** grid; per-row play button, configurable columns, header sorting, inline double-click editing, and @@ -359,7 +359,9 @@ Two independent apps that talk over HTTP: slot, a per-slot Replace tick for occupied slots — never remembered, since overwriting is a decision about THIS track — and the template itself persisted as `autoCueTemplate` in userprefs), - `ContextMenu` (supports `▸` submenus and section headings; "Add to" lists + `ContextMenu` (supports `▸` submenus, section headings, separators and + checkbox items that toggle without closing — the header row's right-click + column chooser uses those; "Add to" lists playlists + exports and acts on the whole selection) + `EditTagsDialog` (right-click → multi-field metadata + album-art edit), `StatusBar`, `RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`, diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 6a69a15..b3c2ff8 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,6 +5,7 @@ import { CapabilitiesContext } from './lib/capabilities' import { writeHint } from './lib/platformCopy' import { api, type GridBatchResult, type PlaylistNode, type Track } from './api' import { + COLUMN_MENU, DEFAULT_COLUMN_ORDER, DEFAULT_COLUMN_VISIBILITY, } from './lib/trackColumns' @@ -53,6 +54,8 @@ export default function App() { // `ids` is what the menu acts on: the whole selection when the clicked row is // part of it, otherwise just that row. const [menu, setMenu] = useState<{ track: Track; ids: string[]; x: number; y: number } | null>(null) + // Right-click on the table header: the column chooser. + const [headerMenu, setHeaderMenu] = useState<{ x: number; y: number } | null>(null) const [editing, setEditing] = useState(null) const [showPaths, setShowPaths] = useState(false) const [showHistory, setShowHistory] = useState(false) @@ -624,6 +627,26 @@ export default function App() { onClose={() => setMenu(null)} /> )} + {headerMenu && ( + ({ + label: c.label, + checked: columnVisibility[c.id] !== false, + onToggle: () => + setColumnVisibility((v) => ({ ...v, [c.id]: v[c.id] === false })), + })), + { separator: true as const }, + { label: 'Reset to defaults', onClick: resetColumns }, + ]} + onClose={() => setHeaderMenu(null)} + /> + )} {editing && ( setImporting(true)} onSwitchLibrary={() => setForcePicker(true)} onDone={(msg) => notify('success', msg)} + onOpenPathMapping={() => setShowPaths(true)} />
- {/* Search / filters / column settings — always visible. */} + {/* Search / filters — always visible. Columns are chosen by right-clicking the header. */} setShowPaths(true)} /> {(!isAll || viewingDevice) && (
@@ -791,6 +811,7 @@ export default function App() { onSortingChange={setSorting} selection={{ selected, onChange: setSelected }} onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)} + onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onPlay={playTrack} onEditField={canEdit ? editField : undefined} activeTrackId={prepTrack?.id ?? null} @@ -824,6 +845,7 @@ export default function App() { sorting={sorting} onSortingChange={setSorting} onRowContextMenu={(track, x, y) => openMenu(track, x, y, false)} + onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onPlay={playTrack} activeTrackId={prepTrack?.id ?? null} columnVisibility={columnVisibility} @@ -846,6 +868,7 @@ export default function App() { onSortingChange={setSorting} selection={{ selected, onChange: setSelected }} onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)} + onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onPlay={playTrack} onEditField={canEdit ? editField : undefined} activeTrackId={prepTrack?.id ?? null} @@ -882,6 +905,7 @@ export default function App() { } onRemove={playlistEditable ? removeFromPlaylist : undefined} onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)} + onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onPlay={playTrack} onEditField={canEdit ? editField : undefined} activeTrackId={prepTrack?.id ?? null} diff --git a/frontend/src/components/ColumnsMenu.tsx b/frontend/src/components/ColumnsMenu.tsx deleted file mode 100644 index 18b20fd..0000000 --- a/frontend/src/components/ColumnsMenu.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { useEffect, useRef, useState } from 'react' -import type { VisibilityState } from '@tanstack/react-table' -import { COLUMN_MENU } from '../lib/trackColumns' - -interface Props { - visibility: VisibilityState - onChange: (v: VisibilityState) => void - onReset: () => void -} - -/** Dropdown of checkboxes to show/hide library columns, plus a layout reset. */ -export function ColumnsMenu({ visibility, onChange, onReset }: Props) { - const [open, setOpen] = useState(false) - const ref = useRef(null) - - useEffect(() => { - if (!open) return - const onDoc = (e: MouseEvent) => { - if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false) - } - document.addEventListener('mousedown', onDoc) - return () => document.removeEventListener('mousedown', onDoc) - }, [open]) - - const isVisible = (id: string) => visibility[id] !== false // default-visible unless explicitly false - - return ( -
- - {open && ( -
-
- {COLUMN_MENU.map((c) => ( - - ))} -
- -
- )} -
- ) -} diff --git a/frontend/src/components/ContextMenu.tsx b/frontend/src/components/ContextMenu.tsx index 574e87d..5878331 100644 --- a/frontend/src/components/ContextMenu.tsx +++ b/frontend/src/components/ContextMenu.tsx @@ -4,7 +4,10 @@ import { useEffect, useRef, useState } from 'react' export type MenuItem = | { label: string; onClick: () => void; danger?: boolean; hint?: string; icon?: string; disabled?: boolean } | { label: string; submenu: MenuItem[] } + // Toggles in place and leaves the menu open, so several can be flipped in one go. + | { label: string; checked: boolean; onToggle: () => void } | { heading: string; empty?: string } + | { separator: true } interface Props { x: number @@ -56,7 +59,10 @@ export function ContextMenu({ x, y, items, onClose }: Props) { items={items} onClose={onClose} className="min-w-[160px]" - style={{ top: Math.min(y, window.innerHeight - 100), left: Math.min(x, window.innerWidth - 180) }} + style={(() => { + const top = Math.min(y, window.innerHeight - 100) + return { top, left: Math.min(x, window.innerWidth - 180), maxHeight: window.innerHeight - top - 8 } + })()} />
) @@ -94,6 +100,30 @@ function MenuPanel({ style={style} > {items.map((item, i) => { + if ('separator' in item) { + return
+ } + if ('checked' in item) { + return ( + + ) + } if ('heading' in item) { return (
diff --git a/frontend/src/components/SaveBar.tsx b/frontend/src/components/SaveBar.tsx index 97ce889..8db3ad6 100644 --- a/frontend/src/components/SaveBar.tsx +++ b/frontend/src/components/SaveBar.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, type ReactNode } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { api } from '../api' import { useCaps } from '../lib/capabilities' @@ -6,11 +6,13 @@ import { overwriteWarning, readOnlyNotice, saveLabel } from '../lib/platformCopy interface Props { onError: (msg: string) => void + /** Rendered to the right of the save button (the settings gear). */ + trailing?: ReactNode } // Bottom-of-sidebar save control. Shows unsaved-changes state and writes to the // NML; every save is recorded in the collection's version history. -export function SaveBar({ onError }: Props) { +export function SaveBar({ onError, trailing }: Props) { const qc = useQueryClient() const [justSaved, setJustSaved] = useState(null) const { data: state } = useQuery({ queryKey: ['state'], queryFn: api.state }) @@ -37,11 +39,12 @@ export function SaveBar({ onError }: Props) { // point: a greyed-out button with no explanation reads as a bug. if (readOnly) { return ( -
-
+
+
Read-only
{readOnly}
+ {trailing}
) } @@ -53,10 +56,11 @@ export function SaveBar({ onError }: Props) { ⚠ {warning}
)} +
+ {trailing} +
{justSaved && (
{justSaved}
)} diff --git a/frontend/src/components/SettingsMenu.tsx b/frontend/src/components/SettingsMenu.tsx index 34f44c0..b818d5d 100644 --- a/frontend/src/components/SettingsMenu.tsx +++ b/frontend/src/components/SettingsMenu.tsx @@ -2,11 +2,13 @@ import { useEffect, useRef, useState } from 'react' interface Props { onOpenPathMapping: () => void + /** Open the menu above the button — for a button at the bottom of the window. */ + up?: boolean } /** Overflow menu for low-frequency, collection-level settings. Currently holds * path remapping; the natural home for future advanced settings. */ -export function SettingsMenu({ onOpenPathMapping }: Props) { +export function SettingsMenu({ onOpenPathMapping, up = false }: Props) { const [open, setOpen] = useState(false) const ref = useRef(null) @@ -26,7 +28,7 @@ export function SettingsMenu({ onOpenPathMapping }: Props) {
{open && ( -
+
- + } /> ) } diff --git a/frontend/src/components/Toolbar.tsx b/frontend/src/components/Toolbar.tsx index d8b970a..8ed6c32 100644 --- a/frontend/src/components/Toolbar.tsx +++ b/frontend/src/components/Toolbar.tsx @@ -1,9 +1,6 @@ import { useQuery } from '@tanstack/react-query' -import type { VisibilityState } from '@tanstack/react-table' import { api } from '../api' import { useCaps } from '../lib/capabilities' -import { ColumnsMenu } from './ColumnsMenu' -import { SettingsMenu } from './SettingsMenu' export interface Filters { search: string @@ -28,10 +25,6 @@ export const emptyFilters: Filters = { interface Props { filters: Filters onChange: (f: Filters) => void - columnVisibility: VisibilityState - onColumnVisibilityChange: (v: VisibilityState) => void - onResetColumns: () => void - onOpenPathMapping: () => void } const selectCls = @@ -40,10 +33,6 @@ const selectCls = export function Toolbar({ filters, onChange, - columnVisibility, - onColumnVisibilityChange, - onResetColumns, - onOpenPathMapping, }: Props) { const caps = useCaps() const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets }) @@ -145,12 +134,6 @@ export function Toolbar({ Clear filters )} - -
) diff --git a/frontend/src/components/TrackTable.tsx b/frontend/src/components/TrackTable.tsx index 8657c97..b0b8458 100644 --- a/frontend/src/components/TrackTable.tsx +++ b/frontend/src/components/TrackTable.tsx @@ -70,6 +70,8 @@ interface Props { /** Delete/Backspace removes the selected tracks from this view. */ onRemove?: (ids: string[]) => void onRowContextMenu?: (track: Track, x: number, y: number) => void + /** Right-click on the header row (the column chooser). */ + onHeaderContextMenu?: (x: number, y: number) => void onPlay?: (track: Track) => void onEditField?: (track: Track, field: keyof Track, value: string | number) => void activeTrackId?: string | null @@ -184,11 +186,13 @@ function HeaderRow({ sensors, onColumnDragEnd, hasPlay, + onContextMenu, }: { headers: Header[] sensors: ReturnType onColumnDragEnd: (e: DragEndEvent) => void hasPlay: boolean + onContextMenu?: (x: number, y: number) => void }) { // True while (and just after) a column is being reordered, so the trailing // click a drag emits is swallowed instead of toggling the sort. @@ -209,7 +213,14 @@ function HeaderRow({ }, 0) }} > -
+
{ + if (!onContextMenu) return + e.preventDefault() + onContextMenu(e.clientX, e.clientY) + }} + > {hasPlay && }
{virtualRows.map((vr) => { diff --git a/frontend/src/lib/trackColumns.tsx b/frontend/src/lib/trackColumns.tsx index c093292..0434ee8 100644 --- a/frontend/src/lib/trackColumns.tsx +++ b/frontend/src/lib/trackColumns.tsx @@ -294,6 +294,28 @@ export const TRACK_COLUMNS: ColumnDef[] = [ /> ), }), + col.accessor('filepath', { + id: 'path', + header: 'Path', + size: 320, + // Read-only: the path is the track's identity. Truncated from the LEFT + // (rtl box, ltr text) so the filename — the part you are looking for — + // stays visible; the full path is the tooltip. + cell: (c) => { + const v = c.getValue() + return v ? ( +
+ {v} +
+ ) : ( + — + ) + }, + }), ] // Traktor dates arrive as "YYYY/M/D" strings; show them compactly (or raw). @@ -304,7 +326,7 @@ function formatDate(v: string | null): string { return `${m[1]}-${m[2].padStart(2, '0')}-${m[3].padStart(2, '0')}` } -/** (id, label) pairs for the Columns menu, in the canonical definition order. */ +/** (id, label) pairs for the header's column chooser, in definition order. */ export const COLUMN_MENU: { id: string; label: string }[] = TRACK_COLUMNS.map((c) => ({ id: c.id as string, label: typeof c.header === 'string' ? c.header : (c.id as string),