mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Cleaned up column settings
This commit is contained in:
1 parent
73694fe532
commit
76bf142fb4
10 files changed
+125
-103
No files matched your search
@@ -336,7 +336,7 @@ Two independent apps that talk over HTTP:
|
|||||||
library meant restarting; switching confirms first when there are unsaved
|
library meant restarting; switching confirms first when there are unsaved
|
||||||
edits, since the adapter holds them in a native model that opening another
|
edits, since the adapter holds them in a native model that opening another
|
||||||
library replaces — plus the playlist tree +
|
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
|
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
|
||||||
devices. TanStack Table + **virtualized** grid; per-row play button,
|
devices. TanStack Table + **virtualized** grid; per-row play button,
|
||||||
configurable columns, header sorting, inline double-click editing, and
|
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
|
slot, a per-slot Replace tick for occupied slots — never remembered, since
|
||||||
overwriting is a decision about THIS track — and the template itself
|
overwriting is a decision about THIS track — and the template itself
|
||||||
persisted as `autoCueTemplate` in userprefs),
|
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`
|
playlists + exports and acts on the whole selection) + `EditTagsDialog`
|
||||||
(right-click → multi-field metadata + album-art edit), `StatusBar`,
|
(right-click → multi-field metadata + album-art edit), `StatusBar`,
|
||||||
`RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`,
|
`RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`,
|
||||||
|
|||||||
+29
-5
@@ -5,6 +5,7 @@ import { CapabilitiesContext } from './lib/capabilities'
|
|||||||
import { writeHint } from './lib/platformCopy'
|
import { writeHint } from './lib/platformCopy'
|
||||||
import { api, type GridBatchResult, type PlaylistNode, type Track } from './api'
|
import { api, type GridBatchResult, type PlaylistNode, type Track } from './api'
|
||||||
import {
|
import {
|
||||||
|
COLUMN_MENU,
|
||||||
DEFAULT_COLUMN_ORDER,
|
DEFAULT_COLUMN_ORDER,
|
||||||
DEFAULT_COLUMN_VISIBILITY,
|
DEFAULT_COLUMN_VISIBILITY,
|
||||||
} from './lib/trackColumns'
|
} 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
|
// `ids` is what the menu acts on: the whole selection when the clicked row is
|
||||||
// part of it, otherwise just that row.
|
// part of it, otherwise just that row.
|
||||||
const [menu, setMenu] = useState<{ track: Track; ids: string[]; x: number; y: number } | null>(null)
|
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<Track | null>(null)
|
const [editing, setEditing] = useState<Track | null>(null)
|
||||||
const [showPaths, setShowPaths] = useState(false)
|
const [showPaths, setShowPaths] = useState(false)
|
||||||
const [showHistory, setShowHistory] = useState(false)
|
const [showHistory, setShowHistory] = useState(false)
|
||||||
@@ -624,6 +627,26 @@ export default function App() {
|
|||||||
onClose={() => setMenu(null)}
|
onClose={() => setMenu(null)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{headerMenu && (
|
||||||
|
<ContextMenu
|
||||||
|
key={`${headerMenu.x}:${headerMenu.y}`}
|
||||||
|
x={headerMenu.x}
|
||||||
|
y={headerMenu.y}
|
||||||
|
items={[
|
||||||
|
{ heading: 'Columns' },
|
||||||
|
// Default-visible unless explicitly hidden, as in the Columns menu.
|
||||||
|
...COLUMN_MENU.map((c) => ({
|
||||||
|
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 && (
|
{editing && (
|
||||||
<EditTagsDialog
|
<EditTagsDialog
|
||||||
track={editing}
|
track={editing}
|
||||||
@@ -690,18 +713,15 @@ export default function App() {
|
|||||||
onImport={() => setImporting(true)}
|
onImport={() => setImporting(true)}
|
||||||
onSwitchLibrary={() => setForcePicker(true)}
|
onSwitchLibrary={() => setForcePicker(true)}
|
||||||
onDone={(msg) => notify('success', msg)}
|
onDone={(msg) => notify('success', msg)}
|
||||||
|
onOpenPathMapping={() => setShowPaths(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CapabilitiesContext.Provider value={viewCaps}>
|
<CapabilitiesContext.Provider value={viewCaps}>
|
||||||
<main className="relative flex min-w-0 flex-1 flex-col">
|
<main className="relative flex min-w-0 flex-1 flex-col">
|
||||||
{/* Search / filters / column settings — always visible. */}
|
{/* Search / filters — always visible. Columns are chosen by right-clicking the header. */}
|
||||||
<Toolbar
|
<Toolbar
|
||||||
filters={filters}
|
filters={filters}
|
||||||
onChange={setFilters}
|
onChange={setFilters}
|
||||||
columnVisibility={columnVisibility}
|
|
||||||
onColumnVisibilityChange={setColumnVisibility}
|
|
||||||
onResetColumns={resetColumns}
|
|
||||||
onOpenPathMapping={() => setShowPaths(true)}
|
|
||||||
/>
|
/>
|
||||||
{(!isAll || viewingDevice) && (
|
{(!isAll || viewingDevice) && (
|
||||||
<div className="flex items-center gap-3 border-b border-line bg-ink-900 px-4 py-2">
|
<div className="flex items-center gap-3 border-b border-line bg-ink-900 px-4 py-2">
|
||||||
@@ -791,6 +811,7 @@ export default function App() {
|
|||||||
onSortingChange={setSorting}
|
onSortingChange={setSorting}
|
||||||
selection={{ selected, onChange: setSelected }}
|
selection={{ selected, onChange: setSelected }}
|
||||||
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
||||||
|
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||||
onPlay={playTrack}
|
onPlay={playTrack}
|
||||||
onEditField={canEdit ? editField : undefined}
|
onEditField={canEdit ? editField : undefined}
|
||||||
activeTrackId={prepTrack?.id ?? null}
|
activeTrackId={prepTrack?.id ?? null}
|
||||||
@@ -824,6 +845,7 @@ export default function App() {
|
|||||||
sorting={sorting}
|
sorting={sorting}
|
||||||
onSortingChange={setSorting}
|
onSortingChange={setSorting}
|
||||||
onRowContextMenu={(track, x, y) => openMenu(track, x, y, false)}
|
onRowContextMenu={(track, x, y) => openMenu(track, x, y, false)}
|
||||||
|
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||||
onPlay={playTrack}
|
onPlay={playTrack}
|
||||||
activeTrackId={prepTrack?.id ?? null}
|
activeTrackId={prepTrack?.id ?? null}
|
||||||
columnVisibility={columnVisibility}
|
columnVisibility={columnVisibility}
|
||||||
@@ -846,6 +868,7 @@ export default function App() {
|
|||||||
onSortingChange={setSorting}
|
onSortingChange={setSorting}
|
||||||
selection={{ selected, onChange: setSelected }}
|
selection={{ selected, onChange: setSelected }}
|
||||||
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
||||||
|
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||||
onPlay={playTrack}
|
onPlay={playTrack}
|
||||||
onEditField={canEdit ? editField : undefined}
|
onEditField={canEdit ? editField : undefined}
|
||||||
activeTrackId={prepTrack?.id ?? null}
|
activeTrackId={prepTrack?.id ?? null}
|
||||||
@@ -882,6 +905,7 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
onRemove={playlistEditable ? removeFromPlaylist : undefined}
|
onRemove={playlistEditable ? removeFromPlaylist : undefined}
|
||||||
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
onRowContextMenu={(track, x, y) => openMenu(track, x, y, true)}
|
||||||
|
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
|
||||||
onPlay={playTrack}
|
onPlay={playTrack}
|
||||||
onEditField={canEdit ? editField : undefined}
|
onEditField={canEdit ? editField : undefined}
|
||||||
activeTrackId={prepTrack?.id ?? null}
|
activeTrackId={prepTrack?.id ?? 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<HTMLDivElement>(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 (
|
|
||||||
<div ref={ref} className="relative">
|
|
||||||
<button
|
|
||||||
onClick={() => setOpen((o) => !o)}
|
|
||||||
className="flex items-center gap-1.5 rounded-md border border-line bg-ink-850 px-2.5 py-1.5 text-sm text-text transition-colors hover:border-ink-600"
|
|
||||||
title="Choose columns"
|
|
||||||
>
|
|
||||||
<span className="text-faint">▦</span> Columns
|
|
||||||
</button>
|
|
||||||
{open && (
|
|
||||||
<div className="absolute right-0 z-30 mt-1 w-52 rounded-md border border-line bg-ink-850 p-1 shadow-2xl">
|
|
||||||
<div className="max-h-80 overflow-y-auto p-1">
|
|
||||||
{COLUMN_MENU.map((c) => (
|
|
||||||
<label
|
|
||||||
key={c.id}
|
|
||||||
className="flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-text hover:bg-ink-800"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={isVisible(c.id)}
|
|
||||||
onChange={(e) => onChange({ ...visibility, [c.id]: e.target.checked })}
|
|
||||||
className="accent-accent"
|
|
||||||
/>
|
|
||||||
{c.label}
|
|
||||||
</label>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
onReset()
|
|
||||||
setOpen(false)
|
|
||||||
}}
|
|
||||||
className="mt-1 w-full rounded px-2 py-1.5 text-left text-xs text-muted hover:bg-ink-800 hover:text-text"
|
|
||||||
>
|
|
||||||
Reset to defaults
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,10 @@ import { useEffect, useRef, useState } from 'react'
|
|||||||
export type MenuItem =
|
export type MenuItem =
|
||||||
| { label: string; onClick: () => void; danger?: boolean; hint?: string; icon?: string; disabled?: boolean }
|
| { label: string; onClick: () => void; danger?: boolean; hint?: string; icon?: string; disabled?: boolean }
|
||||||
| { label: string; submenu: MenuItem[] }
|
| { 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 }
|
| { heading: string; empty?: string }
|
||||||
|
| { separator: true }
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
x: number
|
x: number
|
||||||
@@ -56,7 +59,10 @@ export function ContextMenu({ x, y, items, onClose }: Props) {
|
|||||||
items={items}
|
items={items}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
className="min-w-[160px]"
|
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 }
|
||||||
|
})()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -94,6 +100,30 @@ function MenuPanel({
|
|||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
{items.map((item, i) => {
|
{items.map((item, i) => {
|
||||||
|
if ('separator' in item) {
|
||||||
|
return <div key={i} className="my-1 border-t border-line" />
|
||||||
|
}
|
||||||
|
if ('checked' in item) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={i}
|
||||||
|
role="menuitemcheckbox"
|
||||||
|
aria-checked={item.checked}
|
||||||
|
onMouseEnter={() => setOpen(null)}
|
||||||
|
onClick={item.onToggle}
|
||||||
|
className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-muted hover:bg-ink-800 hover:text-text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border text-[10px] leading-none ${
|
||||||
|
item.checked ? 'border-accent bg-accent text-ink-950' : 'border-ink-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{item.checked ? '✓' : ''}
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0 flex-1 truncate">{item.label}</span>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
if ('heading' in item) {
|
if ('heading' in item) {
|
||||||
return (
|
return (
|
||||||
<div key={i}>
|
<div key={i}>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react'
|
import { useState, type ReactNode } from 'react'
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { api } from '../api'
|
import { api } from '../api'
|
||||||
import { useCaps } from '../lib/capabilities'
|
import { useCaps } from '../lib/capabilities'
|
||||||
@@ -6,11 +6,13 @@ import { overwriteWarning, readOnlyNotice, saveLabel } from '../lib/platformCopy
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onError: (msg: string) => void
|
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
|
// Bottom-of-sidebar save control. Shows unsaved-changes state and writes to the
|
||||||
// NML; every save is recorded in the collection's version history.
|
// 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 qc = useQueryClient()
|
||||||
const [justSaved, setJustSaved] = useState<string | null>(null)
|
const [justSaved, setJustSaved] = useState<string | null>(null)
|
||||||
const { data: state } = useQuery({ queryKey: ['state'], queryFn: api.state })
|
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.
|
// point: a greyed-out button with no explanation reads as a bug.
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
return (
|
return (
|
||||||
<div className="border-t border-line bg-ink-900 px-3 py-3">
|
<div className="flex items-stretch gap-2 border-t border-line bg-ink-900 px-3 py-3">
|
||||||
<div className="rounded-md bg-ink-800 px-2 py-2 text-[11px] leading-snug text-faint">
|
<div className="min-w-0 flex-1 rounded-md bg-ink-800 px-2 py-2 text-[11px] leading-snug text-faint">
|
||||||
<span className="font-medium text-ink-200">Read-only</span>
|
<span className="font-medium text-ink-200">Read-only</span>
|
||||||
<div className="mt-1">{readOnly}</div>
|
<div className="mt-1">{readOnly}</div>
|
||||||
</div>
|
</div>
|
||||||
|
{trailing}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -53,10 +56,11 @@ export function SaveBar({ onError }: Props) {
|
|||||||
⚠ {warning}
|
⚠ {warning}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div className="flex items-stretch gap-2">
|
||||||
<button
|
<button
|
||||||
disabled={!dirty || save.isPending}
|
disabled={!dirty || save.isPending}
|
||||||
onClick={() => save.mutate()}
|
onClick={() => save.mutate()}
|
||||||
className={`flex w-full items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
|
className={`flex min-w-0 flex-1 items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
|
||||||
dirty
|
dirty
|
||||||
? 'bg-accent text-ink-950 hover:brightness-110'
|
? 'bg-accent text-ink-950 hover:brightness-110'
|
||||||
: 'cursor-not-allowed bg-ink-800 text-faint'
|
: 'cursor-not-allowed bg-ink-800 text-faint'
|
||||||
@@ -73,6 +77,8 @@ export function SaveBar({ onError }: Props) {
|
|||||||
'No unsaved changes'
|
'No unsaved changes'
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
{trailing}
|
||||||
|
</div>
|
||||||
{justSaved && (
|
{justSaved && (
|
||||||
<div className="mt-2 text-center text-[11px] text-mint">{justSaved}</div>
|
<div className="mt-2 text-center text-[11px] text-mint">{justSaved}</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import { useEffect, useRef, useState } from 'react'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onOpenPathMapping: () => void
|
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
|
/** Overflow menu for low-frequency, collection-level settings. Currently holds
|
||||||
* path remapping; the natural home for future advanced settings. */
|
* 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 [open, setOpen] = useState(false)
|
||||||
const ref = useRef<HTMLDivElement>(null)
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ export function SettingsMenu({ onOpenPathMapping }: Props) {
|
|||||||
<div ref={ref} className="relative">
|
<div ref={ref} className="relative">
|
||||||
<button
|
<button
|
||||||
onClick={() => setOpen((o) => !o)}
|
onClick={() => setOpen((o) => !o)}
|
||||||
className="flex items-center justify-center rounded-md border border-line bg-ink-850 px-2 py-1.5 text-muted transition-colors hover:border-ink-600 hover:text-text"
|
className="flex h-full items-center justify-center rounded-md border border-line bg-ink-850 px-2 py-1.5 text-muted transition-colors hover:border-ink-600 hover:text-text"
|
||||||
title="Settings"
|
title="Settings"
|
||||||
aria-label="Settings"
|
aria-label="Settings"
|
||||||
>
|
>
|
||||||
@@ -44,7 +46,11 @@ export function SettingsMenu({ onOpenPathMapping }: Props) {
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
{open && (
|
{open && (
|
||||||
<div className="absolute right-0 z-30 mt-1 w-56 rounded-md border border-line bg-ink-850 p-1 shadow-2xl">
|
<div
|
||||||
|
className={`absolute right-0 z-30 w-56 rounded-md border border-line bg-ink-850 p-1 shadow-2xl ${
|
||||||
|
up ? 'bottom-full mb-1' : 'mt-1'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onOpenPathMapping()
|
onOpenPathMapping()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|||||||
import { api, type PlaylistKind, type PlaylistNode } from '../api'
|
import { api, type PlaylistKind, type PlaylistNode } from '../api'
|
||||||
import { useCaps } from '../lib/capabilities'
|
import { useCaps } from '../lib/capabilities'
|
||||||
import { SaveBar } from './SaveBar'
|
import { SaveBar } from './SaveBar'
|
||||||
|
import { SettingsMenu } from './SettingsMenu'
|
||||||
import { DevicesSection } from './DevicesSection'
|
import { DevicesSection } from './DevicesSection'
|
||||||
import { ExportsSection } from './ExportsSection'
|
import { ExportsSection } from './ExportsSection'
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ interface Props {
|
|||||||
onImport: () => void
|
onImport: () => void
|
||||||
onSwitchLibrary: () => void
|
onSwitchLibrary: () => void
|
||||||
onDone: (msg: string) => void
|
onDone: (msg: string) => void
|
||||||
|
onOpenPathMapping: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind picks the icon; every behavioural question is answered by the node's own
|
// Kind picks the icon; every behavioural question is answered by the node's own
|
||||||
@@ -259,6 +261,7 @@ export function Sidebar({
|
|||||||
onImport,
|
onImport,
|
||||||
onSwitchLibrary,
|
onSwitchLibrary,
|
||||||
onDone,
|
onDone,
|
||||||
|
onOpenPathMapping,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
// Both share a cache entry with App and SaveBar, so the header never
|
// Both share a cache entry with App and SaveBar, so the header never
|
||||||
@@ -408,7 +411,7 @@ export function Sidebar({
|
|||||||
Collection Version History
|
Collection Version History
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<SaveBar onError={onError} />
|
<SaveBar onError={onError} trailing={<SettingsMenu up onOpenPathMapping={onOpenPathMapping} />} />
|
||||||
</aside>
|
</aside>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import type { VisibilityState } from '@tanstack/react-table'
|
|
||||||
import { api } from '../api'
|
import { api } from '../api'
|
||||||
import { useCaps } from '../lib/capabilities'
|
import { useCaps } from '../lib/capabilities'
|
||||||
import { ColumnsMenu } from './ColumnsMenu'
|
|
||||||
import { SettingsMenu } from './SettingsMenu'
|
|
||||||
|
|
||||||
export interface Filters {
|
export interface Filters {
|
||||||
search: string
|
search: string
|
||||||
@@ -28,10 +25,6 @@ export const emptyFilters: Filters = {
|
|||||||
interface Props {
|
interface Props {
|
||||||
filters: Filters
|
filters: Filters
|
||||||
onChange: (f: Filters) => void
|
onChange: (f: Filters) => void
|
||||||
columnVisibility: VisibilityState
|
|
||||||
onColumnVisibilityChange: (v: VisibilityState) => void
|
|
||||||
onResetColumns: () => void
|
|
||||||
onOpenPathMapping: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectCls =
|
const selectCls =
|
||||||
@@ -40,10 +33,6 @@ const selectCls =
|
|||||||
export function Toolbar({
|
export function Toolbar({
|
||||||
filters,
|
filters,
|
||||||
onChange,
|
onChange,
|
||||||
columnVisibility,
|
|
||||||
onColumnVisibilityChange,
|
|
||||||
onResetColumns,
|
|
||||||
onOpenPathMapping,
|
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const caps = useCaps()
|
const caps = useCaps()
|
||||||
const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets })
|
const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets })
|
||||||
@@ -145,12 +134,6 @@ export function Toolbar({
|
|||||||
Clear filters
|
Clear filters
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<ColumnsMenu
|
|
||||||
visibility={columnVisibility}
|
|
||||||
onChange={onColumnVisibilityChange}
|
|
||||||
onReset={onResetColumns}
|
|
||||||
/>
|
|
||||||
<SettingsMenu onOpenPathMapping={onOpenPathMapping} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ interface Props {
|
|||||||
/** Delete/Backspace removes the selected tracks from this view. */
|
/** Delete/Backspace removes the selected tracks from this view. */
|
||||||
onRemove?: (ids: string[]) => void
|
onRemove?: (ids: string[]) => void
|
||||||
onRowContextMenu?: (track: Track, x: number, y: number) => 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
|
onPlay?: (track: Track) => void
|
||||||
onEditField?: (track: Track, field: keyof Track, value: string | number) => void
|
onEditField?: (track: Track, field: keyof Track, value: string | number) => void
|
||||||
activeTrackId?: string | null
|
activeTrackId?: string | null
|
||||||
@@ -184,11 +186,13 @@ function HeaderRow({
|
|||||||
sensors,
|
sensors,
|
||||||
onColumnDragEnd,
|
onColumnDragEnd,
|
||||||
hasPlay,
|
hasPlay,
|
||||||
|
onContextMenu,
|
||||||
}: {
|
}: {
|
||||||
headers: Header<Track, unknown>[]
|
headers: Header<Track, unknown>[]
|
||||||
sensors: ReturnType<typeof useSensors>
|
sensors: ReturnType<typeof useSensors>
|
||||||
onColumnDragEnd: (e: DragEndEvent) => void
|
onColumnDragEnd: (e: DragEndEvent) => void
|
||||||
hasPlay: boolean
|
hasPlay: boolean
|
||||||
|
onContextMenu?: (x: number, y: number) => void
|
||||||
}) {
|
}) {
|
||||||
// True while (and just after) a column is being reordered, so the trailing
|
// True while (and just after) a column is being reordered, so the trailing
|
||||||
// click a drag emits is swallowed instead of toggling the sort.
|
// click a drag emits is swallowed instead of toggling the sort.
|
||||||
@@ -209,7 +213,14 @@ function HeaderRow({
|
|||||||
}, 0)
|
}, 0)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="sticky top-0 z-10 flex border-b border-line bg-ink-850">
|
<div
|
||||||
|
className="sticky top-0 z-10 flex border-b border-line bg-ink-850"
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
if (!onContextMenu) return
|
||||||
|
e.preventDefault()
|
||||||
|
onContextMenu(e.clientX, e.clientY)
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span className="w-10 shrink-0" />
|
<span className="w-10 shrink-0" />
|
||||||
{hasPlay && <span className="w-9 shrink-0" />}
|
{hasPlay && <span className="w-9 shrink-0" />}
|
||||||
<SortableContext
|
<SortableContext
|
||||||
@@ -247,6 +258,7 @@ export function TrackTable({
|
|||||||
reorder,
|
reorder,
|
||||||
onRemove,
|
onRemove,
|
||||||
onRowContextMenu,
|
onRowContextMenu,
|
||||||
|
onHeaderContextMenu,
|
||||||
onPlay,
|
onPlay,
|
||||||
onEditField,
|
onEditField,
|
||||||
activeTrackId,
|
activeTrackId,
|
||||||
@@ -500,6 +512,7 @@ export function TrackTable({
|
|||||||
sensors={sensors}
|
sensors={sensors}
|
||||||
onColumnDragEnd={onColumnDragEnd}
|
onColumnDragEnd={onColumnDragEnd}
|
||||||
hasPlay={hasPlay}
|
hasPlay={hasPlay}
|
||||||
|
onContextMenu={onHeaderContextMenu}
|
||||||
/>
|
/>
|
||||||
<div ref={bodyRef} style={{ height: virtualizer.getTotalSize(), position: 'relative' }}>
|
<div ref={bodyRef} style={{ height: virtualizer.getTotalSize(), position: 'relative' }}>
|
||||||
{virtualRows.map((vr) => {
|
{virtualRows.map((vr) => {
|
||||||
|
|||||||
@@ -294,6 +294,28 @@ export const TRACK_COLUMNS: ColumnDef<Track, any>[] = [
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
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 ? (
|
||||||
|
<div
|
||||||
|
className="w-full truncate text-xs text-muted"
|
||||||
|
style={{ direction: 'rtl', textAlign: 'left' }}
|
||||||
|
title={v}
|
||||||
|
>
|
||||||
|
<bdi>{v}</bdi>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<span className="text-faint">—</span>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
// Traktor dates arrive as "YYYY/M/D" strings; show them compactly (or raw).
|
// 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')}`
|
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) => ({
|
export const COLUMN_MENU: { id: string; label: string }[] = TRACK_COLUMNS.map((c) => ({
|
||||||
id: c.id as string,
|
id: c.id as string,
|
||||||
label: typeof c.header === 'string' ? c.header : (c.id as string),
|
label: typeof c.header === 'string' ? c.header : (c.id as string),
|
||||||
|
|||||||
Reference in new issue
Block a user