mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
210c1ab135 | ||
|
|
e211fd180a | ||
|
|
5d059c7604 | ||
|
|
667068c2f1 | ||
|
|
75cb0c8138 | ||
|
|
068e4da08b | ||
|
|
1a28ad6102 |
No files matched your search
@@ -53,6 +53,13 @@ Two independent apps that talk over HTTP:
|
||||
inserts among the CURRENT entries (a drop between a table's rows);
|
||||
folder add (`playlist_index`) and device import (`into_playlist_index`)
|
||||
take the same.
|
||||
`POST /api/playlists/{id}/remove` (`dry_run` counts, changes nothing)
|
||||
drops EVERY occurrence of the given tracks, other entries kept as they
|
||||
are — the track menu's **Remove ▸ From playlist ▸** (decided 2026-10-22,
|
||||
[the discussion](.claude/discussions/discuss-playlist-subtraction-2026-10-22.md)):
|
||||
tracks picked anywhere leave a playlist that is not open, so "A minus B"
|
||||
is open B, select all, remove from A. Lists every `can_reorder`
|
||||
playlist but the open one; the confirm says how many it holds, even 0.
|
||||
- `capabilities.py` — `Capabilities`: what the loaded library can persist, so
|
||||
the UI can gate controls instead of branching on the platform.
|
||||
- `query.py` (`TrackIndex`) — all query/filter/sort/facet/stats logic, over
|
||||
@@ -942,7 +949,10 @@ Two independent apps that talk over HTTP:
|
||||
deleted after the push. Refused while the app runs (`core/apps_running.py`,
|
||||
psutil: `rekordbox` exactly, `traktor*` — macOS `Traktor Pro 4`; re-checked
|
||||
before each save), for the library open in Konduktor, and cloud-synced
|
||||
rekordbox. Backup first: Traktor a version-history baseline + a commit per
|
||||
rekordbox. A target library NOT on this computer (`not_found`) is
|
||||
SKIPPED, not a block (`TargetPlan.skipped`): a remote's sets are shared
|
||||
by every computer opening it, so the set dialog lets it be ticked or
|
||||
unticked anywhere; only none found blocks (`no_library_here`). Backup first: Traktor a version-history baseline + a commit per
|
||||
push, rekordbox `master.db` + XML copied to `app_data/local_push/backups`
|
||||
(10 kept). New copies are placed before the library is written; a copy
|
||||
REPLACING a file a library plays waits as `*.konduktor-partial` until a
|
||||
@@ -1097,8 +1107,9 @@ Two independent apps that talk over HTTP:
|
||||
picker used to be a one-way door with `forcePicker` never set, so changing
|
||||
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. **Creating is right-click
|
||||
only**: a folder's menu offers New Playlist / New Folder inside it, empty
|
||||
library replaces — plus the playlist tree. **Creating is right-click,
|
||||
or the Playlists header's +** (the top-level menu under the button; with
|
||||
no folders, straight to a new playlist): a folder's menu offers New Playlist / New Folder inside it, empty
|
||||
space below the rows creates at the top level, and the new node is named
|
||||
in place (Esc or an empty name creates nothing). Rename/Delete are on the
|
||||
same menu and the row's hover buttons, which share one set of actions.
|
||||
@@ -1322,13 +1333,14 @@ Two independent apps that talk over HTTP:
|
||||
`OverviewWaveform`, which frames the main view's visible range around the
|
||||
playhead (it takes `secPerView` for exactly that). **Controls**: play, CUE, `LoopControls`, then
|
||||
(where `cues.memory_cues`) the **Hot / Mem** switch (`ModeSwitch`, the same component as BEAT / MAN), then
|
||||
`HotcueBar`, `MemoryCueStrip` (Mem) OR — in **Grid mode** — `GridEditStrip`, then `TempoControls`
|
||||
(±0.01 / ±0.25, ÷2 ×2, tap, lock) and the Grid toggle. The row is a
|
||||
`HotcueBar`, `MemoryCueStrip` (Mem) OR — in **Grid mode** — `GridEditStrip`, then the
|
||||
**CUES / GRID** switch (also a `ModeSwitch`) and `TempoControls`
|
||||
(±0.01 / ±0.25, ÷2 ×2, tap, lock). A two-option `ModeSwitch` flips on a
|
||||
click anywhere on it. The row is a
|
||||
**container** and gives way in stages instead of overlapping: each pad
|
||||
queries its own width and drops its name below 4rem (the bank never goes
|
||||
below `PAD_MIN` per pad), then the tempo group folds into `TempoFold`'s
|
||||
portalled popover, then Grid keeps only its icon. The two row breakpoints
|
||||
are measured widths — move them if controls are added to the row. Every grid control acts
|
||||
portalled popover. That breakpoint is a measured width — move them if controls are added to the row. Every grid control acts
|
||||
on the marker **governing the playhead**, since a beatgrid is a marker list
|
||||
and there is no separate marker selection; see "Beatgrid" below.
|
||||
- **One size for loops AND beat jump** (`beatSize`, 1/32–32, persisted as
|
||||
@@ -1514,7 +1526,8 @@ serialization path.** It enforces:
|
||||
- `test_phase3.py` — full create/add/reorder/rename/delete/save cycle stays
|
||||
Traktor-valid, backup-first, COLLECTION byte-identical, original untouched;
|
||||
plus the drag-and-drop routes: `/add`'s three `duplicates` modes (`ask`
|
||||
changes nothing and counts) and `/api/playlists/move` (path id answered,
|
||||
changes nothing and counts), `/remove` (every copy, order kept, `dry_run`
|
||||
counts and changes nothing, 404 unknown) and `/api/playlists/move` (path id answered,
|
||||
400 into itself, 404 unknown).
|
||||
- `test_timebase.py` — Traktor's MP3 time base: `mp3_gapless` on generated
|
||||
MP3s (header found after a 1 MB ID3 tag; header-less has none), the offset
|
||||
|
||||
@@ -106,6 +106,8 @@ CLOUD_SYNCED = "cloud_synced"
|
||||
UNREADABLE = "unreadable"
|
||||
#: Why a push cannot run.
|
||||
BLOCKED_NO_TARGET = "no_target"
|
||||
#: Every library the set names is missing on THIS computer.
|
||||
BLOCKED_NONE_HERE = "no_library_here"
|
||||
BLOCKED_EMPTY = "nothing_to_push"
|
||||
BLOCKED_UNAVAILABLE = "target_unavailable"
|
||||
BLOCKED_RUNNING = "app_running"
|
||||
@@ -337,8 +339,16 @@ class TargetPlan:
|
||||
#: Overwrite: the other sets pushed into this library, which it removes.
|
||||
wipes_sets: list[str] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def skipped(self) -> bool:
|
||||
"""Not on this computer, so passed over rather than blocking: a set's
|
||||
targets are shared by every computer that opens the library (a
|
||||
remote's sets live on its server), and one with only Traktor must
|
||||
still push a Traktor + rekordbox set."""
|
||||
return self.blocked == NOT_FOUND
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
return dict(self.__dict__)
|
||||
return {**self.__dict__, "skipped": self.skipped}
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -358,6 +368,11 @@ class PushPlan:
|
||||
def tracks(self) -> list[PlannedTrack]:
|
||||
return self.audio.tracks
|
||||
|
||||
@property
|
||||
def active(self) -> list[TargetPlan]:
|
||||
"""The targets this push writes: every one found on this computer."""
|
||||
return [t for t in self.targets if not t.skipped]
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
audio = self.audio
|
||||
free = free_bytes(audio.destination) if audio.destination else None
|
||||
@@ -454,11 +469,13 @@ def plan(adapter, export_set, *, store=None, level: Level | None = None,
|
||||
previous=previous)
|
||||
if not targets:
|
||||
out.blocked = BLOCKED_NO_TARGET
|
||||
elif not out.active:
|
||||
out.blocked = BLOCKED_NONE_HERE
|
||||
elif not built.exportable:
|
||||
out.blocked = BLOCKED_EMPTY
|
||||
elif any(t.blocked for t in targets):
|
||||
elif any(t.blocked for t in out.active):
|
||||
out.blocked = BLOCKED_UNAVAILABLE
|
||||
elif any(t.running for t in targets):
|
||||
elif any(t.running for t in out.active):
|
||||
out.blocked = BLOCKED_RUNNING
|
||||
return out
|
||||
|
||||
@@ -521,7 +538,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
See the module docstring for the order and what a cancel leaves."""
|
||||
if built.blocked:
|
||||
raise PushRefused(f"This push cannot run: {built.blocked}")
|
||||
for target in built.targets:
|
||||
for target in built.active:
|
||||
_refuse_if_running(target.platform)
|
||||
|
||||
root = Path(built.audio.destination)
|
||||
@@ -580,7 +597,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
playlists=built.playlists, checkpoint=_checkpoint(handle))
|
||||
|
||||
results = []
|
||||
for target in built.targets:
|
||||
for target in built.active:
|
||||
handle.raise_if_cancelled()
|
||||
handle.progress(done=0, total=0, unit="tracks",
|
||||
message=f"Pushing into {target.name}…")
|
||||
@@ -610,6 +627,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
"deleted_files": removed,
|
||||
"audio_root": str(root),
|
||||
"targets": results,
|
||||
"skipped_targets": [t.name for t in built.targets if t.skipped],
|
||||
}
|
||||
except BaseException:
|
||||
for partial, _final in waiting:
|
||||
|
||||
@@ -104,6 +104,7 @@ from .schemas import (
|
||||
RenamePlaylist,
|
||||
SaveResult,
|
||||
AddEntries,
|
||||
RemoveEntries,
|
||||
MovePlaylist,
|
||||
SetEntries,
|
||||
SourceCandidate,
|
||||
@@ -1473,6 +1474,28 @@ def add_entries(playlist_uuid: str, body: AddEntries) -> dict:
|
||||
"duplicates": len(dupes), "count": n}
|
||||
|
||||
|
||||
@app.post("/api/playlists/{playlist_uuid}/remove")
|
||||
def remove_entries(playlist_uuid: str, body: RemoveEntries) -> dict:
|
||||
"""Remove tracks from a playlist — EVERY occurrence of each — without the
|
||||
caller holding its entry list (the track menu's Remove ▸ From playlist).
|
||||
Other entries keep their order, including ones whose track is missing
|
||||
from the collection. `tracks` = how many of the given tracks it held,
|
||||
`removed` = entries dropped (more, where a track was there twice)."""
|
||||
a = require_adapter()
|
||||
current = a.playlist_entries(playlist_uuid)
|
||||
if current is None:
|
||||
raise HTTPException(404, f"Playlist not found: {playlist_uuid}")
|
||||
gone = set(body.track_ids)
|
||||
kept = [t for t in current if t not in gone]
|
||||
held = len(gone & set(current))
|
||||
removed = len(current) - len(kept)
|
||||
n = len(current)
|
||||
if removed and not body.dry_run:
|
||||
n = a.set_playlist_entries(playlist_uuid, kept)
|
||||
return {"status": "counted" if body.dry_run else "removed", "id": playlist_uuid,
|
||||
"tracks": held, "removed": removed, "count": n}
|
||||
|
||||
|
||||
@app.patch("/api/tracks")
|
||||
def edit_track(body: EditTrack) -> dict:
|
||||
"""Edit a single track's safe metadata fields (in-memory; persisted on save)."""
|
||||
|
||||
@@ -32,6 +32,12 @@ class AddEntries(BaseModel):
|
||||
index: int | None = None
|
||||
|
||||
|
||||
class RemoveEntries(BaseModel):
|
||||
track_ids: list[str]
|
||||
# Count what would go and change nothing — the confirm dialog's numbers.
|
||||
dry_run: bool = False
|
||||
|
||||
|
||||
class MovePlaylist(BaseModel):
|
||||
node_id: str
|
||||
parent_id: str | None = None # None = the top level
|
||||
@@ -539,6 +545,9 @@ class PushTargetOut(BaseModel):
|
||||
name: str
|
||||
path: str | None = None
|
||||
blocked: str | None = None
|
||||
#: Not on this computer (`blocked` = not_found): passed over by the push
|
||||
#: instead of blocking it.
|
||||
skipped: bool = False
|
||||
running: bool = False
|
||||
add: int = 0
|
||||
already: int = 0
|
||||
@@ -565,7 +574,8 @@ class PushPreview(BaseModel):
|
||||
to_measure: int = 0
|
||||
level_counts: dict[str, int] = {}
|
||||
targets: list[PushTargetOut] = []
|
||||
#: A FACT: `no_target`, `nothing_to_push`, `target_unavailable`,
|
||||
#: A FACT: `no_target`, `no_library_here` (none of the set's libraries
|
||||
#: is on this computer), `nothing_to_push`, `target_unavailable`,
|
||||
#: `app_running`, or null when it can run.
|
||||
blocked: str | None = None
|
||||
|
||||
|
||||
@@ -270,6 +270,28 @@ with TestClient(main.app) as c:
|
||||
not copy_of(files[1]).exists() and copy_of(files[2]).exists())
|
||||
check("one removal reported", j["result"]["targets"][0]["removed"] == 1, str(j["result"]))
|
||||
|
||||
print("== a library missing on this computer is skipped, not a block ==")
|
||||
# The set's targets are shared by every computer opening the library;
|
||||
# this one has no rekordbox (its pref points at nothing).
|
||||
c.patch(f"/api/exports/{gig['id']}", json={"targets": ["traktor", "rekordbox"]})
|
||||
pv = c.post(f"/api/exports/{gig['id']}/push/preview", json={}).json()
|
||||
by = {t["platform"]: t for t in pv["targets"]}
|
||||
check("the preview runs, rekordbox skipped", pv["blocked"] is None and by["rekordbox"]["skipped"]
|
||||
and by["rekordbox"]["blocked"] == "not_found" and not by["traktor"]["skipped"], str(pv))
|
||||
RUNNING.add("rekordbox")
|
||||
pv = c.post(f"/api/exports/{gig['id']}/push/preview", json={}).json()
|
||||
check("a skipped library's app running blocks nothing", pv["blocked"] is None, str(pv))
|
||||
RUNNING.clear()
|
||||
j = wait(c, c.post(f"/api/exports/{gig['id']}/push", json={}).json()["id"])
|
||||
check("the push runs into Traktor alone and names the skipped one", j["state"] == "done"
|
||||
and [t["name"] for t in j["result"]["targets"]] == ["Traktor"]
|
||||
and j["result"]["skipped_targets"] == ["Rekordbox"], str(j.get("error") or j["result"]))
|
||||
c.patch(f"/api/exports/{gig['id']}", json={"targets": ["rekordbox"]})
|
||||
pv = c.post(f"/api/exports/{gig['id']}/push/preview", json={}).json()
|
||||
check("none of its libraries here blocks it", pv["blocked"] == "no_library_here", str(pv))
|
||||
check("…and the run is refused", c.post(f"/api/exports/{gig['id']}/push", json={}).status_code == 409)
|
||||
c.patch(f"/api/exports/{gig['id']}", json={"targets": ["traktor"]})
|
||||
|
||||
print("== refusals ==")
|
||||
RUNNING.add("traktor")
|
||||
pv = c.post(f"/api/exports/{gig['id']}/push/preview", json={}).json()
|
||||
|
||||
@@ -204,6 +204,25 @@ check("an index past the end appends", after[-1] == more[1])
|
||||
check("capabilities say Traktor holds duplicates",
|
||||
client.get("/api/capabilities").json()["playlists"]["duplicates"] is True)
|
||||
|
||||
before = [t["id"] for t in client.get(f"/api/playlists/{target}/tracks").json()]
|
||||
outsider = next(t["id"] for t in client.get("/api/tracks", params={"limit": 50}).json()["items"]
|
||||
if t["id"] not in before)
|
||||
picked = [first[0], rest[0], outsider] # first[0] is in there twice
|
||||
r = client.post(f"/api/playlists/{target}/remove",
|
||||
json={"track_ids": picked, "dry_run": True}).json()
|
||||
check("a dry-run remove counts tracks held and entries (both copies) and changes nothing",
|
||||
r["tracks"] == 2 and r["removed"] == 3
|
||||
and [t["id"] for t in client.get(f"/api/playlists/{target}/tracks").json()] == before)
|
||||
r = client.post(f"/api/playlists/{target}/remove", json={"track_ids": picked}).json()
|
||||
after = [t["id"] for t in client.get(f"/api/playlists/{target}/tracks").json()]
|
||||
check("remove drops every copy and keeps the rest in order",
|
||||
r["removed"] == 3 and r["count"] == len(before) - 3
|
||||
and after == [t for t in before if t not in picked])
|
||||
r = client.post(f"/api/playlists/{target}/remove", json={"track_ids": [outsider]}).json()
|
||||
check("removing tracks it does not hold changes nothing", r["removed"] == 0 and r["count"] == len(after))
|
||||
check("remove from an unknown playlist is a 404",
|
||||
client.post("/api/playlists/nope/remove", json={"track_ids": picked}).status_code == 404)
|
||||
|
||||
box = client.post("/api/playlists/folders", json={"name": "Konduktor Drop Box"}).json()["id"]
|
||||
r = client.post("/api/playlists/move", json={"node_id": target, "parent_id": box, "index": 0})
|
||||
check("move answers the playlist's id", r.status_code == 200 and r.json()["id"] == target)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -368,6 +368,13 @@ export default function App() {
|
||||
nodes.flatMap((n) => [...(n.can_add_tracks ? [n] : []), ...walk(n.children)])
|
||||
return walk(playlists.data ?? [])
|
||||
}, [playlists.data])
|
||||
// Every playlist Remove ▸ From playlist can take tracks out of: the same
|
||||
// gate as removing from the open one (its entry list is rewritten).
|
||||
const removablePlaylists = useMemo(() => {
|
||||
const walk = (nodes: PlaylistNode[]): PlaylistNode[] =>
|
||||
nodes.flatMap((n) => [...(n.can_reorder ? [n] : []), ...walk(n.children)])
|
||||
return canEdit ? walk(playlists.data ?? []) : []
|
||||
}, [playlists.data, canEdit])
|
||||
|
||||
// Export membership. Both are no-ops on the library itself, so neither dirties
|
||||
// it nor touches version history — an export set is Konduktor's own data.
|
||||
@@ -1094,6 +1101,50 @@ export default function App() {
|
||||
},
|
||||
})
|
||||
|
||||
// Remove ▸ From playlist ▸ <name>: tracks picked anywhere leave a playlist
|
||||
// that is not open — every copy of each. Counted first, so the dialog says
|
||||
// how many of the selection it actually holds (and still answers at 0).
|
||||
const confirmRemoveFromOther = async (p: PlaylistNode, ids: string[]) => {
|
||||
let r
|
||||
try {
|
||||
r = await api.removeEntries(p.id, ids, true)
|
||||
} catch (e) {
|
||||
onError((e as Error).message)
|
||||
return
|
||||
}
|
||||
const name = <span className="text-text">{p.name}</span>
|
||||
const held = r.tracks
|
||||
setConfirmReq({
|
||||
title: 'Remove from playlist',
|
||||
body: !held ? (
|
||||
<p>
|
||||
{ids.length === 1 ? <>{trackNoun(ids)} is not</> : <>None of these {ids.length} tracks are</>} in {name}.
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Remove {held === ids.length ? trackNoun(ids) : `${held} of the ${ids.length} selected tracks`} from {name}?
|
||||
The {held === 1 ? 'track stays' : 'tracks stay'} in the collection.
|
||||
</p>
|
||||
{held < ids.length && (
|
||||
<p className="text-faint">The other {nTracks(ids.length - held)} {ids.length - held === 1 ? 'is' : 'are'} not in it.</p>
|
||||
)}
|
||||
{r.removed > held && <p className="text-faint">Some are in it more than once; every copy goes.</p>}
|
||||
</>
|
||||
),
|
||||
confirmLabel: held ? `Remove ${nTracks(held)}` : 'Remove',
|
||||
confirmDisabled: !held,
|
||||
onConfirm: () =>
|
||||
guard(async () => {
|
||||
const done = await api.removeEntries(p.id, ids)
|
||||
qc.invalidateQueries({ queryKey: ['playlist', p.id] })
|
||||
qc.invalidateQueries({ queryKey: ['playlists'] })
|
||||
qc.invalidateQueries({ queryKey: ['state'] })
|
||||
notify('success', `Removed ${nTracks(done.tracks)} from ${p.name}`)
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
const confirmRemoveFromExport = (exportId: string, ids: string[]) => {
|
||||
const name = exportSets.data?.find((x) => x.id === exportId)?.name ?? 'this export'
|
||||
setConfirmReq({
|
||||
@@ -1231,6 +1282,22 @@ export default function App() {
|
||||
...(playlistEditable
|
||||
? [{ label: 'From this playlist…', onClick: () => confirmRemoveFromPlaylist(ids) }]
|
||||
: []),
|
||||
// Any other editable playlist — "A minus B" is: open B, select all, here A.
|
||||
...(() => {
|
||||
// A device's ids mean nothing to the collection's playlists.
|
||||
if (viewingDevice) return []
|
||||
const lists = removablePlaylists.filter((p) => !(source.kind === 'playlist' && p.id === source.id))
|
||||
return lists.length
|
||||
? [{
|
||||
label: 'From playlist',
|
||||
submenu: lists.map((p) => ({
|
||||
label: p.name,
|
||||
hint: String(p.count),
|
||||
onClick: () => void confirmRemoveFromOther(p, ids),
|
||||
})),
|
||||
}]
|
||||
: []
|
||||
})(),
|
||||
// Only on the export's ROOT view. Inside a referenced playlist there is
|
||||
// nothing to remove: the reference is live, and per-track removal would
|
||||
// need an exclusion list — hidden state deciding what a future export
|
||||
|
||||
+11
-1
@@ -929,6 +929,8 @@ export interface PushTarget {
|
||||
name: string
|
||||
path: string | null
|
||||
blocked: LocalLibrary['blocked']
|
||||
/** Not on this computer: the push passes it over instead of blocking. */
|
||||
skipped: boolean
|
||||
running: boolean
|
||||
/** Tracks this set has not pushed here before. */
|
||||
add: number
|
||||
@@ -958,7 +960,7 @@ export interface PushPreview {
|
||||
to_measure: number
|
||||
targets: PushTarget[]
|
||||
/** A FACT, not a sentence. Null when the push can run. */
|
||||
blocked: 'no_target' | 'nothing_to_push' | 'target_unavailable' | 'app_running' | null
|
||||
blocked: 'no_target' | 'no_library_here' | 'nothing_to_push' | 'target_unavailable' | 'app_running' | null
|
||||
}
|
||||
|
||||
/** The run dialog's options; each is remembered on the set. Omitted = the
|
||||
@@ -1270,6 +1272,14 @@ export const api = {
|
||||
`/api/playlists/${encodeURIComponent(nodeId)}/add`,
|
||||
{ track_ids: trackIds, duplicates, index },
|
||||
),
|
||||
/** Remove every occurrence of these tracks. `dryRun` changes nothing and
|
||||
* counts: `tracks` = how many of them it holds, `removed` = entries. */
|
||||
removeEntries: (nodeId: string, trackIds: string[], dryRun = false) =>
|
||||
send<{ status: 'removed' | 'counted'; tracks: number; removed: number; count: number }>(
|
||||
'POST',
|
||||
`/api/playlists/${encodeURIComponent(nodeId)}/remove`,
|
||||
{ track_ids: trackIds, dry_run: dryRun },
|
||||
),
|
||||
/** Move a tree node to `index` among `parentId`'s children (null = top
|
||||
* level), counted without it. Answers its id AFTER the move. */
|
||||
movePlaylist: (nodeId: string, parentId: string | null, index: number) =>
|
||||
|
||||
@@ -14,6 +14,9 @@ export interface ConfirmRequest {
|
||||
* (e.g. "Add them again" next to "Add 6 new"). Enter still means confirm. */
|
||||
altLabel?: string
|
||||
onAlt?: () => void
|
||||
/** Nothing to confirm (e.g. none of the tracks are there): the dialog
|
||||
* still answers, with the confirm button — and Enter — off. */
|
||||
confirmDisabled?: boolean
|
||||
onConfirm: () => Promise<void> | void
|
||||
}
|
||||
|
||||
@@ -23,11 +26,11 @@ interface Props extends ConfirmRequest {
|
||||
|
||||
/** A yes/no confirmation for destructive actions. Enter confirms and Esc
|
||||
* cancels, so a confirmed Delete key stays a two-keystroke action. */
|
||||
export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altLabel, onAlt, onConfirm, onClose }: Props) {
|
||||
export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altLabel, onAlt, confirmDisabled, onConfirm, onClose }: Props) {
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
const confirm = async () => {
|
||||
if (busy) return
|
||||
if (busy || confirmDisabled) return
|
||||
setBusy(true)
|
||||
try {
|
||||
await onConfirm()
|
||||
@@ -87,7 +90,7 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
)}
|
||||
<button
|
||||
onClick={() => void confirm()}
|
||||
disabled={busy}
|
||||
disabled={busy || confirmDisabled}
|
||||
className={`rounded-full px-4 py-1.5 text-sm font-semibold disabled:opacity-50 ${
|
||||
tone === 'primary'
|
||||
? 'btn-primary'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api, type ExportSet } from '../api'
|
||||
import { api, type ExportSet, type LocalLibrary } from '../api'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
|
||||
@@ -85,11 +85,14 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
on ? [...prev.filter((t) => t !== platform), platform] : prev.filter((t) => t !== platform),
|
||||
)
|
||||
|
||||
const pushable = new Set(
|
||||
(locals.data?.libraries ?? []).filter((l) => !l.blocked).map((l) => l.platform),
|
||||
)
|
||||
// A set's targets are shared by every computer that opens this library (a
|
||||
// remote's sets live on its server), so a library missing HERE can still be
|
||||
// ticked or unticked — the push skips it on this computer. Anything else
|
||||
// wrong with a library here can always be unticked, never newly ticked.
|
||||
const lockedOut = (lib: LocalLibrary) =>
|
||||
!!lib.blocked && lib.blocked !== 'not_found' && !chosen.includes(lib.platform)
|
||||
const valid = computer
|
||||
? name.trim() !== '' && chosen.length > 0 && chosen.every((t) => pushable.has(t))
|
||||
? name.trim() !== '' && chosen.length > 0
|
||||
: name.trim() !== '' && destination.trim() !== '' && chosen.length > 0
|
||||
|
||||
const chooseKind = (next: ExportSet['kind']) => {
|
||||
@@ -178,17 +181,21 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
<span className="mb-1 block text-xs text-muted">Into</span>
|
||||
<div className="space-y-1">
|
||||
{(locals.data?.libraries ?? []).map((lib) => {
|
||||
const problem = localLibraryProblem(lib)
|
||||
const missing = lib.blocked === 'not_found'
|
||||
const problem = missing
|
||||
? `${localLibraryProblem(lib)} — skipped when pushing from this computer`
|
||||
: localLibraryProblem(lib)
|
||||
const disabled = lockedOut(lib)
|
||||
return (
|
||||
<label
|
||||
key={lib.platform}
|
||||
className={`flex items-start gap-2 rounded-md px-2 py-1.5 ${
|
||||
problem ? 'cursor-not-allowed' : 'cursor-pointer hover:bg-ink-850'
|
||||
disabled ? 'cursor-not-allowed' : 'cursor-pointer hover:bg-ink-850'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={!!problem}
|
||||
disabled={disabled}
|
||||
checked={chosen.includes(lib.platform)}
|
||||
onChange={(e) => toggle(lib.platform, e.target.checked)}
|
||||
className="mt-0.5 accent-accent"
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
/**
|
||||
* The deck's two-way mode switch: two small stacked tabs in a well, the chosen
|
||||
* one lit. BEAT / MAN (loops) and HOT / MEM (the cue bank) are both this.
|
||||
* With exactly two options a click anywhere on it flips to the other one;
|
||||
* with more, each tab selects itself.
|
||||
*/
|
||||
export function ModeSwitch<T extends string>({
|
||||
label,
|
||||
value,
|
||||
options,
|
||||
disabled = false,
|
||||
onChange,
|
||||
}: {
|
||||
/** Names the group for assistive tech ("Loop mode", "Cue bank"). */
|
||||
label: string
|
||||
value: T
|
||||
options: { value: T; text: string; title: string }[]
|
||||
disabled?: boolean
|
||||
onChange: (value: T) => void
|
||||
}) {
|
||||
const other =
|
||||
options.length === 2 && !disabled ? options.find((o) => o.value !== value) : undefined
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-label={label}
|
||||
className="well flex h-10 shrink-0 flex-col justify-center gap-0.5 rounded-[10px] p-0.5"
|
||||
onClick={other ? () => onChange(other.value) : undefined}
|
||||
className={`well ${other ? 'cursor-pointer ' : ''}${disabled ? 'opacity-40 ' : ''}flex h-10 shrink-0 flex-col justify-center gap-0.5 rounded-[10px] p-0.5`}
|
||||
>
|
||||
{options.map((o) => (
|
||||
<button
|
||||
key={o.value}
|
||||
onClick={() => onChange(o.value)}
|
||||
onClick={other ? undefined : () => onChange(o.value)}
|
||||
title={o.title}
|
||||
disabled={disabled}
|
||||
aria-pressed={value === o.value}
|
||||
className={`h-[17px] rounded-[7px] px-[7px] text-[9px] font-bold tracking-[0.08em] transition-colors ${
|
||||
value === o.value ? 'btn-primary' : 'text-faint hover:text-text'
|
||||
|
||||
@@ -1625,11 +1625,10 @@ export function PrepStrip({
|
||||
A container, so the row gives way in stages as the window narrows
|
||||
instead of the pads sliding under the tempo group: the pads drop
|
||||
their names first (each pad queries its own width, see HotcueBar),
|
||||
then below 77rem the tempo group folds into one BPM button, and below
|
||||
63rem the Grid toggle keeps only its icon. Those are the row's
|
||||
measured widths just before the pad bank would hit its minimum (with
|
||||
a lockable grid's extra Lock button, and the Hot / Mem toggle's
|
||||
~3rem with its gap), so move them with the controls. */}
|
||||
then below 77rem the tempo group folds into one BPM button. That is
|
||||
the row's measured width just before the pad bank would hit its
|
||||
minimum (with a lockable grid's extra Lock button, and the Hot / Mem
|
||||
toggle's ~3rem with its gap), so move it with the controls. */}
|
||||
<div className="@container flex h-11 shrink-0 items-center gap-3">
|
||||
<button
|
||||
onClick={toggle}
|
||||
@@ -1752,31 +1751,26 @@ export function PrepStrip({
|
||||
/>
|
||||
)}
|
||||
{DIVIDER}
|
||||
<TempoControls {...tempoProps} className="@max-[77rem]:hidden" />
|
||||
<TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex">
|
||||
<TempoControls {...tempoProps} />
|
||||
</TempoFold>
|
||||
<button
|
||||
onClick={() => {
|
||||
setGridMode((g) => !g)
|
||||
<ModeSwitch
|
||||
label="Deck mode"
|
||||
value={gridMode ? 'grid' : 'cues'}
|
||||
options={[
|
||||
{ value: 'cues', text: 'CUES', title: 'Cues: the hotcue pads or memory cues' },
|
||||
{ value: 'grid', text: 'GRID', title: 'Edit the beatgrid: markers, phase, reset' },
|
||||
]}
|
||||
disabled={!track}
|
||||
onChange={(m) => {
|
||||
setGridMode(m === 'grid')
|
||||
setPadMenu(null)
|
||||
setRenamingSlot(null)
|
||||
setMemoryMenu(null)
|
||||
setRenamingMemory(null)
|
||||
}}
|
||||
aria-pressed={gridMode}
|
||||
disabled={!track}
|
||||
title={gridMode ? 'Back to the hotcue pads' : 'Edit the beatgrid: markers, phase, reset'}
|
||||
aria-label="Grid"
|
||||
className={`flex h-10 shrink-0 items-center gap-1.5 rounded-xl px-3 text-xs font-semibold transition-colors disabled:opacity-40 @max-[63rem]:w-10 @max-[63rem]:justify-center @max-[63rem]:px-0 ${
|
||||
gridMode
|
||||
? 'bg-gold/15 text-gold shadow-[inset_0_0_0_1px_rgb(255_200_97/0.5),0_0_16px_-4px_rgb(255_200_97/0.6)]'
|
||||
: 'btn-glass text-text'
|
||||
}`}
|
||||
>
|
||||
<Icon name="grid" size={14} />
|
||||
<span className="@max-[63rem]:hidden">Grid</span>
|
||||
</button>
|
||||
/>
|
||||
<TempoControls {...tempoProps} className="@max-[77rem]:hidden" />
|
||||
<TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex">
|
||||
<TempoControls {...tempoProps} />
|
||||
</TempoFold>
|
||||
</div>
|
||||
|
||||
{memoryMenu && (
|
||||
|
||||
@@ -16,6 +16,9 @@ import { localLibraryProblem } from '../lib/platformCopy'
|
||||
* so quitting the app is all it takes. Overwrite is confirmed once more, naming
|
||||
* the other pushes it removes. Normalise is not here: the pushed files are
|
||||
* shared by every set, so their level is a setting (Settings → Local libraries).
|
||||
*
|
||||
* A library the set names that is not on THIS computer is skipped, not a block:
|
||||
* a set's targets are shared by every computer that opens the library.
|
||||
*/
|
||||
|
||||
const POLL_MS = 300
|
||||
@@ -92,12 +95,13 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
|
||||
const p = preview.data
|
||||
const blocked = p?.blocked ?? null
|
||||
const active = p?.targets.filter((t) => !t.skipped) ?? []
|
||||
|
||||
const start = async () => {
|
||||
if (overwrite && p) {
|
||||
const wiped = p.targets.flatMap((t) => t.wipes_sets)
|
||||
const wiped = active.flatMap((t) => t.wipes_sets)
|
||||
const ok = await askConfirm({
|
||||
title: `Replace ${p.targets.map((t) => t.name).join(' and ')}’s library?`,
|
||||
title: `Replace ${active.map((t) => t.name).join(' and ')}’s library?`,
|
||||
body:
|
||||
`Everything in it is replaced by “${set.name}” — your own tracks and playlists too` +
|
||||
(wiped.length ? `, and the pushes of ${wiped.map((n) => `“${n}”`).join(', ')}` : '') +
|
||||
@@ -178,14 +182,14 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
<div className="mt-1 text-faint">{p.missing.slice(0, 4).join(', ')}</div>
|
||||
</div>
|
||||
)}
|
||||
{overwrite && p.targets.some((t) => t.wipes_sets.length) && (
|
||||
{overwrite && active.some((t) => t.wipes_sets.length) && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-gold">
|
||||
Also removes what{' '}
|
||||
{[...new Set(p.targets.flatMap((t) => t.wipes_sets))].map((n) => `“${n}”`).join(', ')}{' '}
|
||||
{[...new Set(active.flatMap((t) => t.wipes_sets))].map((n) => `“${n}”`).join(', ')}{' '}
|
||||
pushed there, and deletes its files.
|
||||
</div>
|
||||
)}
|
||||
{p.targets.some((t) => t.platform === 'traktor') && (
|
||||
{active.some((t) => t.platform === 'traktor') && (
|
||||
<label className="flex cursor-pointer items-start gap-2.5">
|
||||
<input type="checkbox" className="mt-0.5" checked={lockGrids}
|
||||
onChange={(e) => setLockGrids(e.target.checked)} />
|
||||
@@ -224,7 +228,7 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
|
||||
{blocked === 'app_running' && (
|
||||
<div className="rounded border border-pink/40 bg-well px-3 py-2 text-xs text-pink">
|
||||
Quit {p!.targets.filter((t) => t.running).map((t) => t.name).join(' and ')} to push —
|
||||
Quit {active.filter((t) => t.running).map((t) => t.name).join(' and ')} to push —
|
||||
it would overwrite the push when it next saves its library.
|
||||
</div>
|
||||
)}
|
||||
@@ -234,6 +238,14 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
libraries, or edit the set.
|
||||
</div>
|
||||
)}
|
||||
{blocked === 'no_library_here' && p && (
|
||||
<div className="rounded border border-pink/40 bg-well px-3 py-2 text-xs text-pink">
|
||||
{p.targets.map((t) => t.name).join(' and ')}{' '}
|
||||
{p.targets.length === 1 ? 'isn’t' : 'aren’t'} on this computer, so there’s nothing to
|
||||
push into. Set {p.targets.length === 1 ? 'its' : 'their'} location in Settings → Local
|
||||
libraries, or edit the set.
|
||||
</div>
|
||||
)}
|
||||
{blocked === 'nothing_to_push' && p && (
|
||||
<div className={`rounded well px-3 py-2 text-xs ${p.tracks ? 'text-pink' : 'text-muted'}`}>
|
||||
{p.tracks === 0
|
||||
@@ -317,6 +329,16 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
}
|
||||
|
||||
function TargetLine({ target, overwrite }: { target: PushTarget; overwrite: boolean }) {
|
||||
if (target.skipped) {
|
||||
return (
|
||||
<div className="rounded-md well px-3 py-2">
|
||||
<div className="flex items-baseline gap-2">
|
||||
<span className="text-faint">{target.name}</span>
|
||||
<span className="ml-auto text-xs text-faint">not on this computer — skipped</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const problem = localLibraryProblem({ ...target, detected: true })
|
||||
const counts = overwrite
|
||||
? 'replaced by this set'
|
||||
@@ -353,6 +375,9 @@ function resultLine(r: TargetResult): string {
|
||||
}
|
||||
|
||||
function doneMessage(name: string, result: Record<string, unknown> | null): string {
|
||||
const targets = ((result as { targets?: TargetResult[] } | null)?.targets ?? []).map((t) => t.name)
|
||||
return `Pushed “${name}” into ${targets.join(' and ') || 'this computer'}`
|
||||
const r = result as { targets?: TargetResult[]; skipped_targets?: string[] } | null
|
||||
const targets = (r?.targets ?? []).map((t) => t.name)
|
||||
const skipped = r?.skipped_targets ?? []
|
||||
return `Pushed “${name}” into ${targets.join(' and ') || 'this computer'}` +
|
||||
(skipped.length ? ` (${skipped.join(' and ')} skipped — not on this computer)` : '')
|
||||
}
|
||||
@@ -774,10 +774,26 @@ export function Sidebar({
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mt-3 shrink-0 px-4">
|
||||
<div className="mt-3 flex shrink-0 items-center justify-between px-4">
|
||||
<span className="text-[11px] font-semibold uppercase tracking-wider text-faint">
|
||||
Playlists
|
||||
</span>
|
||||
{/* The same choices as right-clicking below the rows: straight to a
|
||||
new playlist where there is nothing else to create, else the
|
||||
menu, opened under the button. */}
|
||||
{canCreate && (
|
||||
<button
|
||||
title={foldersSupported ? 'New playlist or folder' : 'New playlist'}
|
||||
onClick={(e) => {
|
||||
if (!foldersSupported) return startDraft('playlist', null)
|
||||
const r = e.currentTarget.getBoundingClientRect()
|
||||
setMenu({ x: r.left, y: r.bottom + 4, items: createItems(null) })
|
||||
}}
|
||||
className="rounded px-1 text-sm text-faint hover:text-text"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right-click here (below the rows) creates at the top level; rows
|
||||
|
||||
Reference in new issue
Block a user