fix: admin/fs: if node has a source that was folder but doesn't exist anymore, the picker was allowing you to only select files

Massimo Melina committed Dec 12, 2023 at 00:34 UTC b3b5133a254d85f71b6da7a7491de2b515358a77
1 file changed +2 -1
admin/src/FileForm.ts
+2 -1
@@ -74,6 +74,7 @@ export default function FileForm({ file, anyMask, addToBar, statusApi }: FileFor
74 }, [file])
75 const { source } = file
76 const isDir = file.type === 'folder'
77 + const isUnknown = !file.type && source && file.size! < 0 // the type is lost
78 const isLink = values.url !== undefined
79 const hasSource = source !== undefined // we need a boolean
80 const realFolder = hasSource && isDir
@@ -156,7 +157,7 @@ export default function FileForm({ file, anyMask, addToBar, statusApi }: FileFor
157 isRoot ? h(Alert, { severity: 'info' }, "This is Home, the root of your shared files. Options set here will be applied to all files.")
158 : { k: 'name', required: true, xl: true, helperText: hasSource && "You can decide a name that's different from the one on your disk" },
159 isLink ? { k: 'url', label: "URL", lg: 12, required: true }
159 - : { k: 'source', label: "Load content from disk", xl: true, comp: FileField, files: !isDir, folders: isDir,
160 + : { k: 'source', label: "Load content from disk", xl: true, comp: FileField, files: isUnknown || !isDir, folders: isUnknown || isDir,
161 placeholder: "no",
162 helperText: values.source ? "Content from this path will be listed, but you can also add more"
163 : "This field is empty, and thus this element is a virtual-folder. You can set this field, pointing at any folder/file on disk.",