Switched to more generic wording

This commit is contained in:
patben8 committed 2026-09-17 22:24:56 +02:00
1 parent c9e85bbdb5
commit 6e24f5ef1d
29 files changed
+796 -319

No files matched your search

+13 -6
View File
@@ -52,6 +52,13 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
const [manual, setManual] = useState('')
const options = useQuery({ queryKey: ['collectionOptions'], queryFn: api.collectionOptions })
// The picker runs BEFORE a library is open, so capabilities do not exist yet —
// /api/platforms is the pre-load equivalent.
const { data: platforms } = useQuery({ queryKey: ['platforms'], queryFn: api.platforms })
// One platform today, so name it; with more, stay general rather than listing.
const only = platforms?.length === 1 ? platforms[0] : null
const appName = only?.name ?? 'DJ'
const fileLabel = only?.library_label ?? 'library file'
const listing = useQuery({
queryKey: ['fs', dir ?? '~'],
queryFn: () => api.listDir(dir),
@@ -76,12 +83,12 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
<div className="flex items-center gap-3 border-b border-line px-5 py-4">
<div className="flex-1">
<div className="text-[15px] font-semibold tracking-tight">
Select your Traktor collection
Select your {appName} library
</div>
<div className="text-xs text-muted">
{mode === 'choose'
? 'Open automatically, resume your last one, or browse.'
: 'Choose a collection.nml file to open.'}
: `Choose a ${fileLabel} to open.`}
</div>
</div>
{mode === 'browse' && (
@@ -112,8 +119,8 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
auto
? `${auto.label} · modified ${formatWhen(auto.modified)}`
: options.isLoading
? 'Searching for a Traktor collection…'
: 'No Traktor collection found in the default location'
? `Searching for a ${appName} library…`
: `No ${appName} library found in the default location`
}
disabled={!auto}
busy={open.isPending}
@@ -136,7 +143,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
<OptionCard
icon="📂"
title="Find collection manually"
subtitle="Browse for a collection.nml file"
subtitle={`Browse for a ${fileLabel}`}
busy={open.isPending}
onClick={() => setMode('browse')}
/>
@@ -218,7 +225,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
onKeyDown={(e) => {
if (e.key === 'Enter' && manual.trim()) open.mutate(manual.trim())
}}
placeholder="…or paste a full path to collection.nml"
placeholder={`…or paste a full path to ${fileLabel}`}
className="min-w-0 flex-1 rounded-md border border-line bg-ink-850 px-3 py-2 font-mono text-xs text-text outline-none placeholder:text-faint focus:border-accent"
/>
<button
+12 -12
View File
@@ -2,6 +2,9 @@ import { useRef, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type Track } from '../api'
import { formatBpm, formatDuration } from '../lib/format'
import { useCaps } from '../lib/capabilities'
import { RatingStars } from './RatingStars'
import { saveLabel, writeHint } from '../lib/platformCopy'
interface Props {
track: Track
@@ -25,6 +28,7 @@ const TEXT_FIELDS: { key: keyof Track; label: string; textarea?: boolean }[] = [
]
export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
const caps = useCaps()
const qc = useQueryClient()
const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets })
@@ -61,7 +65,9 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
qc.invalidateQueries({ queryKey: ['state'] })
qc.invalidateQueries({ queryKey: ['facets'] })
qc.invalidateQueries({ queryKey: ['stats'] })
onApplied(`Updated “${form.title || track.title || 'track'}” — Save to write to Traktor`)
onApplied(
`Updated “${form.title || track.title || 'track'}” — ${writeHint(caps.save)}`,
)
onClose()
},
onError: (e: Error) => onError(e.message),
@@ -170,15 +176,7 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
Rating
</span>
<div className="flex items-center gap-1 text-xl">
{[1, 2, 3, 4, 5].map((i) => (
<button
key={i}
onClick={() => setRating(i === rating ? 0 : i)}
className={i <= rating ? 'text-gold' : 'text-ink-600 hover:text-faint'}
>
★
</button>
))}
<RatingStars value={rating} max={caps.tracks.rating_max} onChange={setRating} />
{rating > 0 && (
<button
onClick={() => setRating(0)}
@@ -204,8 +202,10 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
</div>
<p className="text-[11px] leading-snug text-faint">
BPM, key and path aren’t editable here. Changes apply in-app; click
<span className="text-muted"> Save to Traktor</span> to write them to disk.
New album art is written into the file; Traktor may need a manual
<span className="text-muted"> {saveLabel(caps.save)}</span> to write them to disk.
New album art is written into the file.{' '}
{caps.tracks.artwork_note}
{'' /* platform-specific footnote, supplied by the adapter */}
“Import Cover Art” to refresh its own cached thumbnail.
</p>
</div>
+5 -3
View File
@@ -1,6 +1,8 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type HistoryEntry } from '../api'
import { useCaps } from '../lib/capabilities'
import { restoreWarning } from '../lib/platformCopy'
import type { ToastMsg } from './Toast'
interface Props {
@@ -37,9 +39,10 @@ function summaryChips(summary: string): string[] {
* a purely-local git repo (see backend history.py); this lists them newest-first
* and lets the user restore any past version (written back as a new forward save)
* or wipe the entire history. Restore overwrites the collection on disk, so the
* user must close Traktor first (it rewrites the .nml on exit).
* user is warned first, in the loaded platform's own terms.
*/
export function HistoryPanel({ onClose, onNotify, onError }: Props) {
const caps = useCaps()
const qc = useQueryClient()
const history = useQuery({ queryKey: ['history'], queryFn: api.history })
const [confirmingId, setConfirmingId] = useState<string | null>(null)
@@ -87,8 +90,7 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
<div className="border-b border-line px-5 py-4">
<div className="text-[15px] font-semibold tracking-tight">Version History</div>
<div className="text-xs text-muted">
Every save is a restorable version of this collection. Close Traktor before
restoring — it overwrites the collection on exit.
Every save is a restorable version of this library. {restoreWarning(caps.save)}
</div>
</div>
+37 -14
View File
@@ -1,14 +1,21 @@
import type { CuePoint } from '../api'
import { contrastText, cueColor, GRID_MARKER_COLOR } from '../lib/cues'
import { contrastText, cueColor, cueGlyph } from '../lib/cues'
interface Props {
cues: CuePoint[]
/** Bank size, from capabilities — not every platform has eight. */
slotCount: number
/** How a slot is labelled ("1".."8" or "A".."H"). */
slotLabel: (slot: number) => string
selectedSlot: number | null
onSlotPress: (slot: number) => void
onSlotRelease: (slot: number) => void
}
const SLOTS = [0, 1, 2, 3, 4, 5, 6, 7] // Traktor hotcue slots → labelled 1–8
const READONLY_LABELS: Record<string, string> = {
beatgrid_companion: 'Beatgrid marker — managed by the grid controls',
platform_managed: 'Managed by the DJ app — not editable here',
}
/**
* The 8 hotcue slots, colour-coded by cue type when assigned (gray when empty).
@@ -24,14 +31,24 @@ const SLOTS = [0, 1, 2, 3, 4, 5, 6, 7] // Traktor hotcue slots → labelled 1–
* the backend refuses hotcue edits on them, and showing that up front is better
* than surfacing the refusal as an error.
*/
export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Props) {
export function HotcueBar({
cues,
slotCount,
slotLabel,
selectedSlot,
onSlotPress,
onSlotRelease,
}: Props) {
return (
<div className="flex flex-1 items-stretch gap-px">
{SLOTS.map((slot) => {
const cue = cues.find((c) => c.hotcue === slot) ?? null
const isMarker = cue?.grid_marker != null
const selected = selectedSlot === slot && !isMarker
const color = cue ? (isMarker ? GRID_MARKER_COLOR : cueColor(cue)) : null
{Array.from({ length: slotCount }, (_, i) => i).map((slot) => {
const cue = cues.find((c) => c.role === 'hotcue' && c.slot === slot) ?? null
// Gate on `editable`, never on why: a platform-owned cue is a read-only
// case, not a Traktor-companion case.
const locked = cue != null && !cue.editable
const selected = selectedSlot === slot && !locked
const color = cue ? cueColor(cue) : null
const glyph = cue ? cueGlyph(cue) : ''
return (
<button
key={slot}
@@ -45,13 +62,14 @@ export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Pr
onPointerUp={() => onSlotRelease(slot)}
onPointerCancel={() => onSlotRelease(slot)}
title={
isMarker
? `Beatgrid marker ${(cue!.grid_marker ?? 0) + 1} — managed by the grid controls`
locked
? (cue!.readonly_reason && READONLY_LABELS[cue!.readonly_reason]) ??
'Not editable here'
: cue
? cue.name && cue.name !== 'n.n.'
? `${slot + 1}: ${cue.name}`
: `Hotcue ${slot + 1}`
: `Hotcue ${slot + 1} — click to set at playhead`
? `${slotLabel(slot)}: ${cue.name}`
: `Hotcue ${slotLabel(slot)}`
: `Hotcue ${slotLabel(slot)} — click to set at playhead`
}
style={color ? { backgroundColor: color, color: contrastText(color) } : undefined}
className={
@@ -60,7 +78,12 @@ export function HotcueBar({ cues, selectedSlot, onSlotPress, onSlotRelease }: Pr
(selected ? ' ring-2 ring-inset ring-white/80' : '')
}
>
{isMarker ? '⊞' : slot + 1}
{locked ? '🔒' : slotLabel(slot)}
{glyph && (
<span className="absolute right-0.5 top-0 text-[9px] leading-none opacity-80">
{glyph}
</span>
)}
</button>
)
})}
+61 -32
View File
@@ -1,7 +1,9 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type GridMarker, type Track, type TrackCues } from '../api'
import { api, type CueType, type GridMarker, type Track, type TrackCues } from '../api'
import { buildBeatGrid, GRID_EPS } from '../lib/beatgrid'
import { slotLabeller, useCaps } from '../lib/capabilities'
import { CUE_TYPE_LABELS } from '../lib/cues'
import { analyzeWaveform, type WaveColumn } from '../lib/waveform'
import { ScratchEngine } from '../lib/scratchEngine'
import { PlaybackEngine } from '../lib/playbackEngine'
@@ -29,13 +31,22 @@ function fmt(secs: number): string {
return `${m}:${s.toString().padStart(2, '0')}`
}
const CUE_TYPES: { value: number; label: string }[] = [
{ value: 0, label: 'Cue' },
{ value: 1, label: 'Fade-In' },
{ value: 2, label: 'Fade-Out' },
{ value: 3, label: 'Load' },
]
const LOOP_TYPE = 5
/**
* Digit key -> bank slot: 1..9 map to slots 0..8 and 0 maps to slot 10.
*
* Ten digits is the physical ceiling, so a bank larger than that simply has no
* shortcut for its tail. Returns null when the key is not a digit or the slot is
* beyond this platform's bank — an 8-slot bank behaves exactly as before.
*/
const DIGIT_RE = /^(?:Digit|Numpad)([0-9])$/
function slotForDigit(code: string, slotCount: number): number | null {
const m = code.match(DIGIT_RE)
if (!m) return null
const slot = m[1] === '0' ? 9 : Number(m[1]) - 1
return slot < slotCount ? slot : null
}
const LOOP_SIZES = [1 / 32, 1 / 16, 1 / 8, 1 / 4, 1 / 2, 1, 2, 4, 8, 16, 32]
/**
@@ -549,8 +560,17 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [grid])
// ---- capability-derived -----------------------------------------------
const caps = useCaps()
const slotCount = caps.cues.hotcue_slots
const slotLabel = slotLabeller(caps)
// Loops are a cue TYPE on some platforms and a separate bank on others; the
// dropdown only ever offers the point types.
const pointCueTypes = caps.cues.types.filter((t) => t !== 'loop')
// ---- hotcues ----------------------------------------------------------
const hotcueAt = (slot: number) => cueData?.cues.find((c) => c.hotcue === slot) ?? null
const hotcueAt = (slot: number) =>
cueData?.cues.find((c) => c.role === 'hotcue' && c.slot === slot) ?? null
const applyCueEdit = (fresh: TrackCues) => {
setCueData(fresh)
@@ -597,10 +617,10 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
// Setting a hotcue while a loop is active stores it as a loop hotcue.
if (loopActive && loopRegion) {
const len = loopRegion.end - loopRegion.start
applyCueEdit(await api.createHotcue(track.id, slot, loopRegion.start, LOOP_TYPE, len))
applyCueEdit(await api.createCue(track.id, slot, loopRegion.start, 'loop', len))
} else {
const t = snapTime(playbackRef.current?.getPosition() ?? current)
applyCueEdit(await api.createHotcue(track.id, slot, t, 0))
applyCueEdit(await api.createCue(track.id, slot, t, 'cue'))
}
setSelectedSlot(slot)
} catch (e) {
@@ -613,7 +633,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
if (!eng || !eng.ready) return
getCtx()
// A loop hotcue jumps to its start AND re-engages a loop of its length.
if (cue.type === LOOP_TYPE && cue.length > 0) {
if (cue.type === 'loop' && cue.length > 0) {
seek(cue.start)
engagLoop(cue.start, cue.start + cue.length, beatsForLoop(cue.start, cue.length))
} else {
@@ -633,15 +653,15 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
const runAutoHotcues = async () => {
if (!track || !canAutoCue || autoBusy) return
const hotcueCount = (c: TrackCues | null) =>
c?.cues.filter((x) => x.hotcue >= 0).length ?? 0
if (hotcueCount(cueData) >= 8) {
onError?.('No free hotcue slots — delete some first')
c?.cues.filter((x) => x.role === 'hotcue' && x.slot != null).length ?? 0
if (hotcueCount(cueData) >= slotCount) {
onError?.(`No free hotcue slots (${slotCount} of ${slotCount} used) — delete some first`)
return
}
setAutoBusy(true)
try {
const before = hotcueCount(cueData)
const fresh = await api.autoHotcues(track.id)
const fresh = await api.autoCues(track.id)
applyCueEdit(fresh)
const placed = Math.max(0, hotcueCount(fresh) - before)
if (placed === 0) {
@@ -656,10 +676,10 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
}
}
const changeSelectedType = async (type: number) => {
const changeSelectedType = async (type: CueType) => {
if (!track || selectedSlot == null) return
try {
applyCueEdit(await api.setHotcueType(track.id, selectedSlot, type))
applyCueEdit(await api.setCueType(track.id, selectedSlot, type))
} catch (e) {
onError?.((e as Error).message)
}
@@ -668,7 +688,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
const deleteSelected = async () => {
if (!track || selectedSlot == null) return
try {
applyCueEdit(await api.deleteHotcue(track.id, selectedSlot))
applyCueEdit(await api.deleteCue(track.id, selectedSlot))
setSelectedSlot(null)
} catch (e) {
onError?.((e as Error).message)
@@ -680,7 +700,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
if (!track || !existing) return // nothing to remove in an empty slot
if (existing.grid_marker != null) return // beatgrid-owned: delete the marker instead
try {
applyCueEdit(await api.deleteHotcue(track.id, slot))
applyCueEdit(await api.deleteCue(track.id, slot))
if (selectedSlot === slot) setSelectedSlot(null)
} catch (e) {
onError?.((e as Error).message)
@@ -757,7 +777,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
const toggleLock = async () => {
if (!track) return
try {
applyCueEdit(await api.setLock(track.id, !cueData?.locked))
applyCueEdit(await api.setGridLock(track.id, !cueData?.grid_locked))
} catch (e) {
onError?.((e as Error).message)
}
@@ -799,6 +819,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
beatJump,
prevMarker,
nextMarker,
slotCount,
})
shortcutsRef.current = {
toggle,
@@ -810,6 +831,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
beatJump,
prevMarker,
nextMarker,
slotCount,
}
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
@@ -840,10 +862,9 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
else shortcutsRef.current.beatJump(1)
return
}
const digit = e.code.match(/^(?:Digit|Numpad)([1-8])$/)
if (digit) {
const slot = slotForDigit(e.code, shortcutsRef.current.slotCount)
if (slot != null) {
e.preventDefault()
const slot = Number(digit[1]) - 1
if (e.shiftKey) void shortcutsRef.current.deleteHotcueSlot(slot)
else void shortcutsRef.current.onSlotPress(slot)
}
@@ -851,8 +872,8 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
// keyup ends a held hotcue's momentary preview (release).
const onKeyRelease = (e: KeyboardEvent) => {
if (e.code === 'KeyC') shortcutsRef.current.onCueRelease()
const digit = e.code.match(/^(?:Digit|Numpad)([1-8])$/)
if (digit) shortcutsRef.current.onSlotRelease(Number(digit[1]) - 1)
const slot = slotForDigit(e.code, shortcutsRef.current.slotCount)
if (slot != null) shortcutsRef.current.onSlotRelease(slot)
}
window.addEventListener('keydown', onKey)
window.addEventListener('keyup', onKeyRelease)
@@ -893,7 +914,7 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
markerStart={activeMarker?.start ?? null}
atMarker={atMarker}
beforeFirst={beforeFirstMarker}
locked={cueData?.locked ?? false}
locked={cueData?.grid_locked ?? false}
canReset={originalGridRef.current != null}
onSetBpm={setBpm}
onNudgeBpm={nudgeBpm}
@@ -1034,24 +1055,32 @@ export function PrepStrip({ track, playRequest = 0, onError, onNotify }: Props)
</span>
<HotcueBar
cues={cueData?.cues ?? []}
slotCount={slotCount}
slotLabel={slotLabel}
selectedSlot={selectedSlot}
onSlotPress={onSlotPress}
onSlotRelease={onSlotRelease}
/>
<div className="flex w-28 items-center justify-center bg-ink-900 px-1">
{selectedCue && selectedCue.type === LOOP_TYPE ? (
{selectedCue && selectedCue.type === 'loop' ? (
<span className="text-sm font-semibold text-mint">Loop</span>
) : pointCueTypes.length < 2 ? (
// One point type means there is nothing to choose between —
// show it rather than a dropdown that cannot change anything.
<span className="text-sm font-semibold text-text">
{selectedCue ? CUE_TYPE_LABELS[selectedCue.type] : '—'}
</span>
) : (
<select
value={selectedCue ? selectedCue.type : ''}
disabled={!selectedCue}
onChange={(e) => changeSelectedType(Number(e.target.value))}
onChange={(e) => changeSelectedType(e.target.value as CueType)}
className="w-full bg-transparent text-center text-sm font-semibold text-text outline-none disabled:opacity-40"
>
{!selectedCue && <option value="">—</option>}
{CUE_TYPES.map((t) => (
<option key={t.value} value={t.value}>
{t.label}
{pointCueTypes.map((t) => (
<option key={t} value={t}>
{CUE_TYPE_LABELS[t]}
</option>
))}
</select>
+13 -10
View File
@@ -2,22 +2,25 @@ import { useState } from 'react'
interface Props {
value: number
/** When provided, the stars become clickable to set the rating (0–5). */
/** Scale length, from capabilities.tracks.rating_max. */
max?: number
/** When provided, the stars become clickable to set the rating. */
onChange?: (value: number) => void
}
// Compact 5-star rating. Read-only by default (shows a dash when unrated). When
// `onChange` is given it's interactive: always shows five stars — hollow (☆) up
// to the rating, solid gold (★) below it — with hover preview. Clicking a star
// sets that rating; clicking the current top star again clears it to 0.
export function RatingStars({ value, onChange }: Props) {
// Compact star rating. Read-only by default (shows a dash when unrated). When
// `onChange` is given it's interactive: hollow (☆) above the rating, solid gold
// (★) up to it, with hover preview. Clicking a star sets that rating; clicking
// the current top star again clears it to 0.
export function RatingStars({ value, max = 5, onChange }: Props) {
const [hover, setHover] = useState(0)
const stars = Array.from({ length: max }, (_, i) => i + 1)
if (!onChange) {
if (!value) return <span className="text-faint">—</span>
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span className="whitespace-nowrap tracking-tight" title={`${value} / ${max}`}>
{stars.map((i) => (
<span key={i} className={i <= value ? 'text-gold' : 'text-ink-600'}>
{i <= value ? '★' : '☆'}
</span>
@@ -28,8 +31,8 @@ export function RatingStars({ value, onChange }: Props) {
const shown = hover || value
return (
<span className="whitespace-nowrap tracking-tight" title={`${value} / 5`}>
{[1, 2, 3, 4, 5].map((i) => (
<span className="whitespace-nowrap tracking-tight" title={`${value} / ${max}`}>
{stars.map((i) => (
<button
key={i}
onClick={(e) => {
+7 -3
View File
@@ -1,6 +1,8 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api } from '../api'
import { useCaps } from '../lib/capabilities'
import { overwriteWarning, saveLabel } from '../lib/platformCopy'
interface Props {
onError: (msg: string) => void
@@ -26,13 +28,15 @@ export function SaveBar({ onError }: Props) {
onError: (e: Error) => onError(e.message),
})
const caps = useCaps()
const warning = overwriteWarning(caps.save)
const dirty = state?.dirty ?? false
return (
<div className="border-t border-line bg-ink-900 px-3 py-3">
{dirty && (
{dirty && warning && (
<div className="mb-2 rounded-md bg-gold/10 px-2 py-1.5 text-[11px] leading-snug text-gold">
⚠ Close Traktor before saving — it overwrites the collection on exit.
⚠ {warning}
</div>
)}
<button
@@ -49,7 +53,7 @@ export function SaveBar({ onError }: Props) {
) : dirty ? (
<>
<span className="h-1.5 w-1.5 rounded-full bg-ink-950/60" />
Save to Traktor
{saveLabel(caps.save)}
</>
) : (
'No unsaved changes'
+1 -1
View File
@@ -12,7 +12,7 @@ interface Props {
function flattenPlaylists(nodes: PlaylistNode[]): PlaylistNode[] {
return nodes.flatMap((n) => [
...(n.type === 'PLAYLIST' ? [n] : []),
...(n.can_add_tracks ? [n] : []),
...flattenPlaylists(n.children),
])
}
+12 -10
View File
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type PlaylistNode } from '../api'
import { api, type PlaylistKind, type PlaylistNode } from '../api'
import { SaveBar } from './SaveBar'
export type Source = { kind: 'all' } | { kind: 'playlist'; id: string; name: string }
@@ -12,10 +12,12 @@ interface Props {
onOpenHistory: () => void
}
const icons: Record<string, string> = {
FOLDER: '▸',
PLAYLIST: '♫',
SMARTLIST: '✦',
// Kind picks the icon; every behavioural question is answered by the node's own
// flags, so nothing here infers what a node can do from what it is called.
const icons: Record<PlaylistKind, string> = {
folder: '▸',
playlist: '♫',
smart: '✦',
}
function NodeRow({
@@ -35,9 +37,9 @@ function NodeRow({
const [open, setOpen] = useState(true)
const [renaming, setRenaming] = useState(false)
const [draft, setDraft] = useState(node.name)
const isFolder = node.type === 'FOLDER'
const isFolder = node.kind === 'folder'
const selected = source.kind === 'playlist' && source.id === node.id
const selectable = node.type === 'PLAYLIST'
const selectable = node.selectable
const invalidate = () => {
qc.invalidateQueries({ queryKey: ['playlists'] })
@@ -82,10 +84,10 @@ function NodeRow({
>
<span
className={`w-3 shrink-0 text-center text-[11px] ${
isFolder ? 'text-faint' : node.type === 'SMARTLIST' ? 'text-pink' : 'text-accent'
isFolder ? 'text-faint' : node.kind === 'smart' ? 'text-pink' : 'text-accent'
} ${isFolder && open ? 'rotate-90' : ''} transition-transform`}
>
{icons[node.type]}
{icons[node.kind]}
</span>
{renaming ? (
<input
@@ -113,7 +115,7 @@ function NodeRow({
)}
</button>
{node.type === 'PLAYLIST' && !renaming && (
{node.can_rename && !renaming && (
<>
<button
title="Rename"
+3 -1
View File
@@ -1,6 +1,7 @@
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'
@@ -44,6 +45,7 @@ export function Toolbar({
onResetColumns,
onOpenPathMapping,
}: Props) {
const caps = useCaps()
const { data: facets } = useQuery({ queryKey: ['facets'], queryFn: api.facets })
const set = (patch: Partial<Filters>) => onChange({ ...filters, ...patch })
const active =
@@ -117,7 +119,7 @@ export function Toolbar({
className={selectCls}
>
<option value={0}>Any rating</option>
{[1, 2, 3, 4, 5].map((r) => (
{Array.from({ length: caps.tracks.rating_max }, (_, i) => i + 1).map((r) => (
<option key={r} value={r}>
{'★'.repeat(r)}+
</option>