feat(MediaManager): add folder mounting functionality and improve base URL handling
This commit is contained in:
parent
1f15e1fe20
commit
0b7dc77e78
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
|
|
@ -23,7 +23,6 @@ import {
|
||||||
Home,
|
Home,
|
||||||
Image as ImageIcon,
|
Image as ImageIcon,
|
||||||
Loader2,
|
Loader2,
|
||||||
Menu,
|
|
||||||
MoreVertical,
|
MoreVertical,
|
||||||
Move,
|
Move,
|
||||||
Pencil,
|
Pencil,
|
||||||
|
|
@ -251,6 +250,7 @@ function EntryIcon({ entry }: { entry: EntryInfo }) {
|
||||||
// ─── ActionsModal ─────────────────────────────────────────────────────────────
|
// ─── ActionsModal ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
interface FolderManagementActions {
|
interface FolderManagementActions {
|
||||||
|
onMountFolder: () => void;
|
||||||
onNewFolder: () => void;
|
onNewFolder: () => void;
|
||||||
onNewFile: () => void;
|
onNewFile: () => void;
|
||||||
onUpload: () => void;
|
onUpload: () => void;
|
||||||
|
|
@ -294,6 +294,11 @@ function ActionsModal({ entry, onClose, onOpen, onMount, onDownload, onRename, o
|
||||||
{/* Folder management items — current-folder context (header Actions) */}
|
{/* Folder management items — current-folder context (header Actions) */}
|
||||||
{fm && (
|
{fm && (
|
||||||
<>
|
<>
|
||||||
|
<button onClick={() => { onClose(); fm.onMountFolder(); }}
|
||||||
|
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-blue-50 hover:border-blue-300 inline-flex items-center gap-3">
|
||||||
|
<HardDrive className="w-4 h-4 text-amber-600" /> <span>Mount Folder</span>
|
||||||
|
</button>
|
||||||
|
<div className="border-t border-neutral-100" />
|
||||||
<button onClick={() => { onClose(); fm.onNewFolder(); }}
|
<button onClick={() => { onClose(); fm.onNewFolder(); }}
|
||||||
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-neutral-50 inline-flex items-center gap-3">
|
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-neutral-50 inline-flex items-center gap-3">
|
||||||
<FolderPlus className="w-4 h-4 text-neutral-500" /> <span>New Folder</span>
|
<FolderPlus className="w-4 h-4 text-neutral-500" /> <span>New Folder</span>
|
||||||
|
|
@ -740,8 +745,11 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev.enabled) dev.enabled = 1;
|
if (!dev.enabled) dev.enabled = 1;
|
||||||
if (folderConfig?.['cache'] === '.') dev.cache = splitPath(mountEntry.path).parent;
|
if (folderConfig?.['base_url']) {
|
||||||
if (folderConfig?.['base_url']) dev.base_url = folderConfig['base_url'];
|
dev.base_url = folderConfig['base_url'];
|
||||||
|
delete dev.url;
|
||||||
|
}
|
||||||
|
if (folderConfig?.['cache'] === '.') dev.cache = path;
|
||||||
setConfig(newConfig);
|
setConfig(newConfig);
|
||||||
setMountEntry(null);
|
setMountEntry(null);
|
||||||
const deviceId = `${deviceType}-${key}`;
|
const deviceId = `${deviceType}-${key}`;
|
||||||
|
|
@ -1175,6 +1183,7 @@ export default function MediaManager({ initialPath = '/', rootPath, title, confi
|
||||||
onCut={e => cutOrCopyEntry(e, 'move')}
|
onCut={e => cutOrCopyEntry(e, 'move')}
|
||||||
onDelete={e => void deleteEntry(e)}
|
onDelete={e => void deleteEntry(e)}
|
||||||
folderManagement={folderActionOpen ? {
|
folderManagement={folderActionOpen ? {
|
||||||
|
onMountFolder: () => setMountEntry({ name: splitPath(path).name || '/', path, type: 'folder', size: 0, lastModified: null, contentType: null }),
|
||||||
onNewFolder: () => { setShowNewFolder(true); setShowNewFile(false); },
|
onNewFolder: () => { setShowNewFolder(true); setShowNewFile(false); },
|
||||||
onNewFile: () => { setShowNewFile(true); setShowNewFolder(false); },
|
onNewFile: () => { setShowNewFile(true); setShowNewFolder(false); },
|
||||||
onUpload: () => fileInputRef.current?.click(),
|
onUpload: () => fileInputRef.current?.click(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user