feat(IECPage): add compatibility mode toggle for directory enhancements

This commit is contained in:
Jaime Idolpx 2026-06-10 16:52:09 -04:00
parent 54ed2e08e7
commit 07bbf00aa9
2 changed files with 34 additions and 13 deletions

View File

@ -24,6 +24,18 @@ export default function IECPage({ config, setConfig }: IECPageProps) {
const iec = config.iec || {}; const iec = config.iec || {};
const boolDirEntries = Object.entries(iec.directory || {}).filter(([, v]) => v === 0 || v === 1);
const isCompatMode = boolDirEntries.length > 0 && boolDirEntries.every(([, v]) => v === 0);
const setAllDirBools = (val: 0 | 1) => {
const newConfig = JSON.parse(JSON.stringify(config));
const dir = newConfig.iec?.directory ?? {};
for (const k of Object.keys(dir)) {
if (dir[k] === 0 || dir[k] === 1) dir[k] = val;
}
setConfig(newConfig);
};
return ( return (
<div className="p-4 space-y-4"> <div className="p-4 space-y-4">
<h2 className="text-sm text-neutral-500 flex items-center gap-2"><Cable className="w-4 h-4" /> IEC Settings</h2> <h2 className="text-sm text-neutral-500 flex items-center gap-2"><Cable className="w-4 h-4" /> IEC Settings</h2>
@ -172,30 +184,39 @@ export default function IECPage({ config, setConfig }: IECPageProps) {
<h2 className="text-sm text-neutral-500 pt-4 flex items-center gap-2"><List className="w-4 h-4" /> Directory Enhancements</h2> <h2 className="text-sm text-neutral-500 pt-4 flex items-center gap-2"><List className="w-4 h-4" /> Directory Enhancements</h2>
<div className="bg-white border border-neutral-200 rounded-lg divide-y divide-neutral-200"> <div className="bg-white border border-neutral-200 rounded-lg divide-y divide-neutral-200">
{/* CBM Directory Compatibility Mode */}
<div className="p-4 flex items-center justify-between bg-neutral-50">
<div>
<div className="text-sm font-medium text-neutral-700">CBM Directory Compatibility</div>
<div className="text-xs text-neutral-400 mt-0.5">Disables all directory enhancements</div>
</div>
<button
onClick={() => setAllDirBools(isCompatMode ? 1 : 0)}
className={`relative w-12 h-6 rounded-full transition-colors ${isCompatMode ? 'bg-blue-600' : 'bg-neutral-300'}`}
>
<div className={`absolute top-0.5 w-5 h-5 bg-white rounded-full transition-transform ${isCompatMode ? 'translate-x-6' : 'translate-x-0.5'}`} />
</button>
</div>
{Object.entries(iec.directory || {}).map(([key, value]) => ( {Object.entries(iec.directory || {}).map(([key, value]) => (
<div key={key} className="p-4 flex items-center justify-between"> <div key={key} className={`p-4 flex items-center justify-between transition-opacity ${isCompatMode ? 'opacity-40' : ''}`}>
<label className="text-sm text-neutral-500"> <label className="text-sm text-neutral-500">
{key.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase())} {key.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase())}
</label> </label>
{typeof value === 'number' ? ( {value === 0 || value === 1 ? (
<button <button
onClick={() => updateSetting(['iec', 'directory', key], value ? 0 : 1)} onClick={() => { if (!isCompatMode) updateSetting(['iec', 'directory', key], value ? 0 : 1); }}
className={`relative w-12 h-6 rounded-full transition-colors ${ className={`relative w-12 h-6 rounded-full transition-colors ${value ? 'bg-blue-600' : 'bg-neutral-300'} ${isCompatMode ? 'cursor-not-allowed' : ''}`}
value ? 'bg-blue-600' : 'bg-neutral-300'
}`}
> >
<div <div className={`absolute top-0.5 w-5 h-5 bg-white rounded-full transition-transform ${value ? 'translate-x-6' : 'translate-x-0.5'}`} />
className={`absolute top-0.5 w-5 h-5 bg-white rounded-full transition-transform ${
value ? 'translate-x-6' : 'translate-x-0.5'
}`}
/>
</button> </button>
) : ( ) : (
<input <input
type="number" type="number"
value={value} value={value}
disabled={isCompatMode}
onChange={(e) => updateSetting(['iec', 'directory', key], parseInt(e.target.value))} onChange={(e) => updateSetting(['iec', 'directory', key], parseInt(e.target.value))}
className="w-24 px-3 py-1 border border-neutral-300 rounded-lg text-right" className="w-24 px-3 py-1 border border-neutral-300 rounded-lg text-right disabled:cursor-not-allowed"
/> />
)} )}
</div> </div>

View File

@ -95,11 +95,11 @@
"nfo_header": 1, "nfo_header": 1,
"hidden_dirs": 1, "hidden_dirs": 1,
"hidden_files": 1, "hidden_files": 1,
"long_filenames": 1,
"extension_colon": 1, "extension_colon": 1,
"date_time": 1, "date_time": 1,
"load_address": 1, "load_address": 1,
"sys_address": 1, "sys_address": 1,
"entry_length": 16,
"footer_bytes": 1 "footer_bytes": 1
}, },
"fastloaders": { "fastloaders": {