feat: add file browsing functionality to IECPage for boot disk selection

This commit is contained in:
Jaime Idolpx 2026-06-07 20:43:29 -04:00
parent 3f7cc16ce1
commit aadd29e554

View File

@ -1,9 +1,14 @@
import { useState } from 'react';
import { FolderOpen } from 'lucide-react';
import FileBrowser from './FileBrowser';
interface IECPageProps { interface IECPageProps {
config: any; config: any;
setConfig: (config: any) => void; setConfig: (config: any) => void;
} }
export default function IECPage({ config, setConfig }: IECPageProps) { export default function IECPage({ config, setConfig }: IECPageProps) {
const [showFileBrowser, setShowFileBrowser] = useState(false);
const updateSetting = (path: string[], value: any) => { const updateSetting = (path: string[], value: any) => {
const newConfig = JSON.parse(JSON.stringify(config)); const newConfig = JSON.parse(JSON.stringify(config));
let current = newConfig; let current = newConfig;
@ -57,13 +62,33 @@ export default function IECPage({ config, setConfig }: IECPageProps) {
<div className="p-4"> <div className="p-4">
<label className="text-sm text-neutral-500 block mb-2">Boot Disk</label> <label className="text-sm text-neutral-500 block mb-2">Boot Disk</label>
<input <div className="flex gap-2">
type="text" <input
value={iec.boot_disk || ''} type="text"
onChange={(e) => updateSetting(['iec', 'boot_disk'], e.target.value)} value={iec.boot_disk || ''}
className="w-full px-3 py-2 border border-neutral-300 rounded-lg" onChange={(e) => updateSetting(['iec', 'boot_disk'], e.target.value)}
/> className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg"
/>
<button
onClick={() => setShowFileBrowser(true)}
className="px-3 py-2 border border-neutral-300 rounded-lg bg-neutral-50 hover:bg-neutral-100"
title="Browse files"
>
<FolderOpen className="w-5 h-5" />
</button>
</div>
</div> </div>
{showFileBrowser && (
<FileBrowser
currentPath={iec.boot_disk || '/'}
onSelect={(path) => {
updateSetting(['iec', 'boot_disk'], path);
setShowFileBrowser(false);
}}
onClose={() => setShowFileBrowser(false)}
/>
)}
</div> </div>
<h2 className="text-sm text-neutral-500 pt-4">Directory Settings</h2> <h2 className="text-sm text-neutral-500 pt-4">Directory Settings</h2>