Added support for remote file exploring

This commit is contained in:
patben8 committed 2026-10-12 09:23:34 +02:00
1 parent 966f3fe8c5
commit 40630ff78e
18 files changed
+717 -70

No files matched your search

+20 -6
View File
@@ -1,7 +1,7 @@
import { createPortal } from 'react-dom'
import { useEffect, useRef, useState, type ReactNode } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type FolderAddPreview, type FolderAddRequest, type JobStatus } from '../api'
import { api, isServerPath, type FolderAddPreview, type FolderAddRequest, type JobStatus } from '../api'
import { useCaps } from '../lib/capabilities'
import { placedAudioSummary } from '../lib/platformCopy'
import { FolderPicker } from './FolderPicker'
@@ -20,7 +20,10 @@ import { FolderPicker } from './FolderPicker'
*
* A library held by a server (`tracks.audio_destination === 'library'`) is the
* other exception: it cannot see this computer's files, so the only choice is
* which folder ON THE SERVER they are uploaded into.
* which folder ON THE SERVER they are uploaded into — unless the files were
* browsed in that server's own content folder: they are already where the
* library can reach them, so they are added in place, uploaded nowhere and
* nothing asked (decided 2026-10-10).
*
* A playlist or export target still needs the files in the collection first —
* both hold collection track ids — so the dialog says so rather than doing it
@@ -57,11 +60,15 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
// decides copy vs in place itself, so there is nothing to ask.
const caps = useCaps()
const places = caps.tracks.places_audio
// Already in the server's content folder: added where they are.
const onServer = trackIds.length > 0 && trackIds.every(isServerPath)
// Uploaded into a folder on the server: nothing to ask but where.
const uploads = !places && caps.tracks.audio_destination === 'library'
const [mode, setMode] = useState<'copy' | 'reference' | null>(uploads ? 'copy' : null)
const uploads = !places && !onServer && caps.tracks.audio_destination === 'library'
const [mode, setMode] = useState<'copy' | 'reference' | null>(
onServer ? 'reference' : uploads ? 'copy' : null,
)
const [folder, setFolder] = useState('')
const remote = useServerImportFolder(uploads)
const remote = useServerImportFolder(uploads || onServer)
const [browsing, setBrowsing] = useState(false)
const [job, setJob] = useState<JobStatus | null>(null)
const [starting, setStarting] = useState(false)
@@ -251,7 +258,14 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
</div>
)}
{!places && !uploads && (
{onServer && (
<div className="rounded well px-3 py-2 text-xs text-muted">
Already on {remote.serverName}, so your collection points at them where they
are. Nothing is uploaded or copied.
</div>
)}
{!places && !uploads && !onServer && (
<div className="space-y-1">
{option(
'copy',
+13 -5
View File
@@ -1,13 +1,14 @@
import { useEffect, useState, type ReactNode } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type Drive, type PlaylistNode } from '../api'
import { api, isServerPath, type Drive, type PlaylistNode } from '../api'
import type { Source } from './Sidebar'
import { Icon } from '../lib/icons'
import { ContextMenu, type MenuItem } from './ContextMenu'
/**
* Every drive, in the sidebar: plugged-in ones under Devices, and the computer's
* own under an expandable Local Storage.
* own under an expandable Local Storage. While a remote library is open, the
* server holding it comes first: its content folder, browsed like any drive.
*
* A drive carrying a OneLibrary library opens as a device, the way rekordbox and
* Traktor show a stick: its playlists appear under it and the ordinary track
@@ -86,13 +87,15 @@ export function DevicesSection({ source, onSelect, onError, onImport, onOpenLibr
})
const list = drives.data ?? []
const server = list.filter((d) => d.kind === 'server')
const external = list.filter((d) => d.kind === 'external')
const local = list.filter((d) => d.kind === 'local')
// A drive can be physically unplugged while it is open. Nothing crashes — the
// routes just start failing — but leaving it selected would show a library
// that is not there, so fall back to the collection. The same goes for a
// folder on it being browsed.
// folder on it being browsed — and for a folder on the server, the remote
// library being closed.
const stillPresent = !openPath || list.some((d) => d.library?.path === openPath)
useEffect(() => {
if (!drives.isSuccess || !openPath || stillPresent || eject.isPending) return
@@ -102,7 +105,11 @@ export function DevicesSection({ source, onSelect, onError, onImport, onOpenLibr
const folderGone =
source.kind === 'folder' &&
drives.isSuccess &&
!list.some((d) => d.path === '/' || isInside(source.path, d.path))
!list.some((d) =>
isServerPath(source.path)
? d.kind === 'server'
: d.path === '/' || isInside(source.path, d.path),
)
useEffect(() => {
if (folderGone) onSelect({ kind: 'all' })
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -137,7 +144,7 @@ export function DevicesSection({ source, onSelect, onError, onImport, onOpenLibr
<div key={d.path}>
<TreeRow
depth={depth}
icon={<span className="text-gold"><Icon name="drive" size={15} /></span>}
icon={<span className="text-gold"><Icon name={d.kind === 'server' ? 'server' : 'drive'} size={15} /></span>}
label={d.name}
title={d.path}
expanded={expandedHere}
@@ -212,6 +219,7 @@ export function DevicesSection({ source, onSelect, onError, onImport, onOpenLibr
</div>
<div className="mt-1 min-h-0 overflow-y-auto px-2 pb-1">
{server.map((d) => driveRow(d, 0))}
{external.map((d) => driveRow(d, 0))}
{local.length > 0 && (
+4 -1
View File
@@ -82,6 +82,8 @@ interface Props {
onHeaderContextMenu?: (x: number, y: number) => void
onPlay?: (track: Track) => void
onEditField?: (track: Track, field: keyof Track, value: string | number) => void
/** Per-row gate on opening an inline editor (`TableMeta.mayEdit`). */
mayEdit?: (track: Track) => boolean
activeTrackId?: string | null
/** Whether the deck is playing `activeTrackId` (vs. loaded but paused). */
activePlaying?: boolean
@@ -287,6 +289,7 @@ export function TrackTable({
onHeaderContextMenu,
onPlay,
onEditField,
mayEdit,
activeTrackId,
activePlaying = false,
}: Props) {
@@ -299,7 +302,7 @@ export function TrackTable({
data,
columns: TRACK_COLUMNS,
state: { sorting, columnVisibility, columnOrder, columnSizing },
meta: { onEditField, editableFields },
meta: { onEditField, editableFields, mayEdit },
onSortingChange: (updater) =>
onSortingChange(typeof updater === 'function' ? updater(sorting) : updater),
onColumnSizingChange: (updater) =>