From 243a134a9cc0d2f02064217d3ad654403146b60e Mon Sep 17 00:00:00 2001 From: Jaime Idolpx Date: Thu, 11 Jun 2026 23:54:12 -0400 Subject: [PATCH] feat(MediaManager): add VMS creation functionality and UI enhancements --- src/app/components/MediaManager.tsx | 62 ++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/app/components/MediaManager.tsx b/src/app/components/MediaManager.tsx index 51f1328..4ce601b 100644 --- a/src/app/components/MediaManager.tsx +++ b/src/app/components/MediaManager.tsx @@ -21,6 +21,7 @@ import { Hash, Home, Image as ImageIcon, + Layers, Loader2, MoreVertical, Move, @@ -370,9 +371,11 @@ export default function MediaManager({ initialPath, rootPath, title, config, set const [viewHexData, setViewHexData] = useState(null); const [viewLoading, setViewLoading] = useState(false); - // Rename / folder + // Rename / folder / VMS const [showNewFolder, setShowNewFolder] = useState(false); const [newFolderName, setNewFolderName] = useState(''); + const [showCreateVms, setShowCreateVms] = useState(false); + const [vmsName, setVmsName] = useState(''); const [renameEntry, setRenameEntry] = useState(null); const [renameName, setRenameName] = useState(''); const [mountEntry, setMountEntry] = useState(null); @@ -781,6 +784,36 @@ export default function MediaManager({ initialPath, rootPath, title, config, set void openEntry(entry, 'config'); }; + // ── Create VMS ─────────────────────────────────────────────────────────── + + const openCreateVms = () => { + const folderName = path.split('/').filter(Boolean).pop() ?? 'playlist'; + setVmsName(folderName + '.vms'); + setShowNewFolder(false); + setShowCreateVms(true); + }; + + const handleCreateVms = async () => { + const name = vmsName.trim(); + if (!name) return; + const filename = name.endsWith('.vms') ? name : name + '.vms'; + const selectedFiles = entries.filter(e => selected.has(e.path) && e.type === 'file'); + const content = selectedFiles + .map(e => { + const stem = e.name.includes('.') ? e.name.slice(0, e.name.lastIndexOf('.')) : e.name; + return `${e.name},${stem}`; + }) + .join('\n') + '\n'; + try { + await putFileContents(joinPath(path, filename), content); + toast.success(`Created "${filename}"`); + setShowCreateVms(false); + setVmsName(''); + setSelected(new Set()); + void load(path); + } catch (e: any) { toast.error(`Failed to create VMS: ${e?.message ?? e}`); } + }; + // ── New folder ─────────────────────────────────────────────────────────── const handleCreateFolder = async () => { @@ -972,6 +1005,28 @@ export default function MediaManager({ initialPath, rootPath, title, config, set )} + {showCreateVms && ( +
+ + setVmsName(e.target.value)} + onKeyDown={e => { + if (e.key === 'Enter') void handleCreateVms(); + if (e.key === 'Escape') { setShowCreateVms(false); setVmsName(''); } + }} + placeholder="playlist.vms" + className="flex-1 px-2 py-1 text-sm border border-neutral-300 rounded" + autoFocus + /> + + +
+ )} {/* ── Filter + sort bar ── */} @@ -1017,6 +1072,11 @@ export default function MediaManager({ initialPath, rootPath, title, config, set + {selCount > 1 && ( + + )}