feat(FileManager): improve entry action handling for files and folders
This commit is contained in:
parent
435a1b38c0
commit
30e9c0949a
|
|
@ -760,7 +760,11 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
className="w-4 h-4 flex-shrink-0"
|
||||
/>
|
||||
<button
|
||||
onClick={() => void openEntry(entry)}
|
||||
onClick={() => {
|
||||
if (renameEntry !== null) return;
|
||||
if (entry.type === 'folder') navigateTo(joinPath(path, entry.name));
|
||||
else setMountEntry(entry);
|
||||
}}
|
||||
className="flex-1 flex items-center gap-3 text-left min-w-0"
|
||||
>
|
||||
<EntryIcon entry={entry} />
|
||||
|
|
@ -835,19 +839,39 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-2">
|
||||
{/* Default open */}
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) void openEntry(e); }}
|
||||
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"
|
||||
>
|
||||
{actionEntry?.type === 'folder'
|
||||
? <Folder className="w-4 h-4 text-blue-600" />
|
||||
: <Eye className="w-4 h-4 text-blue-600" />}
|
||||
<span className="flex-1">{actionEntry?.type === 'folder' ? 'Open folder' : 'Open / View'}</span>
|
||||
{actionEntry?.type === 'file' && (
|
||||
{/* Folder: open */}
|
||||
{actionEntry?.type === 'folder' && (
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) void openEntry(e); }}
|
||||
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"
|
||||
>
|
||||
<Folder className="w-4 h-4 text-blue-600" />
|
||||
<span>Open folder</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* File: mount (primary default) */}
|
||||
{actionEntry?.type === 'file' && (
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) setMountEntry(e); }}
|
||||
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 on virtual drive</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* File: open/view */}
|
||||
{actionEntry?.type === 'file' && (
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) void openEntry(e); }}
|
||||
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-neutral-50 inline-flex items-center gap-3"
|
||||
>
|
||||
<Eye className="w-4 h-4 text-blue-600" />
|
||||
<span className="flex-1">Open / View</span>
|
||||
<span className="text-xs text-neutral-400">{VIEWER_LABEL[defaultViewMode(actionEntry)]}</span>
|
||||
)}
|
||||
</button>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Alternate viewers */}
|
||||
{actionEntry?.type === 'file' && availableViewers(actionEntry)
|
||||
|
|
@ -875,15 +899,6 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
</button>
|
||||
)}
|
||||
|
||||
{actionEntry?.type === 'file' && (
|
||||
<button
|
||||
onClick={() => { const e = actionEntry; setActionEntry(null); if (e) setMountEntry(e); }}
|
||||
className="w-full text-left px-4 py-3 rounded border border-neutral-200 hover:bg-neutral-50 inline-flex items-center gap-3"
|
||||
>
|
||||
<HardDrive className="w-4 h-4 text-amber-600" /> <span>Mount on virtual drive</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<div className="border-t border-neutral-100" />
|
||||
|
||||
<button
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user