plugins: config.type 'vfs_path'
Massimo Melina committed
Sep 7, 2024 at 11:40 UTC
eb4dfbfba29f8ba246e8d00d80088f582fa29b11
3 files changed
+8
-3
admin/src/ArrayField.ts
+3
-1
@@ -13,7 +13,9 @@ import { Center, IconBtn } from './mui'
13
14
type ArrayFieldProps<T> = FieldProps<T[]> & { fields: FieldDescriptor[], height?: number, reorder?: boolean, prepend?: boolean, autoRowHeight?: boolean }
15
export function ArrayField<T extends object>({ label, helperText, fields, value, onChange, onError, setApi, reorder, prepend, noRows, valuesForAdd, autoRowHeight, ...rest }: ArrayFieldProps<T>) {
16
- const rows = useMemo(() => (value||[]).map((x,$idx) =>
16
+ if (!Array.isArray(value)) // avoid crash if non-array values are passed, especially developing plugins
17
+ value = []
18
+ const rows = useMemo(() => value!.map((x,$idx) =>
19
setHidden({ ...x } as any, x.hasOwnProperty('id') ? { $idx } : { id: $idx })),
20
[JSON.stringify(value)]) //eslint-disable-line
21
const form = {
admin/src/InstalledPlugins.ts
+2
@@ -15,6 +15,7 @@ import { ArrayField } from './ArrayField'
15
import FileField from './FileField'
16
import { PLUGIN_ERRORS } from './PluginsPage'
17
import { Btn, hTooltip, IconBtn, iconTooltip } from './mui'
18
+import VfsPathField from './VfsPathField'
19
20
export default function InstalledPlugins({ updates }: { updates?: true }) {
21
const { list, updateEntry, error, updateList, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins')
@@ -177,6 +178,7 @@ const type2comp = {
178
multiselect: MultiSelectField,
179
array: ArrayField,
180
real_path: FileField,
181
+ vfs_path: VfsPathField,
182
username: UsernameField,
183
}
184
dev-plugins.md
+3
-2
@@ -125,7 +125,7 @@ used must be strictly JSON (thus, no single quotes, only double quotes for strin
125
### FieldDescriptor
126
127
Currently, these properties are supported:
128
-- `type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'real_path' | 'array' | 'username'ì` . Default is `string`.
128
+- `type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'real_path' | 'vfs_path' | 'array' | 'username'` . Default is `string`.
129
- `label: string` what name to display next to the field. Default is based on `key`.
130
- `defaultValue: any` value to be used when nothing is set.
131
- `helperText: string` extra text printed next to the field.
@@ -628,12 +628,13 @@ If you want to override a text regardless of the language, use the special langu
628
629
## API version history
630
631
-- 9 (v0.54.0)
631
+- 9.1 (v0.54.0)
632
- frontend event: showPlay
633
- api.addBlock
634
- api.misc
635
- frontend event: paste
636
- exports.customRest + HFS.customRestCall
637
+ - config.type: vfs_path
638
- 8.891 (v0.53.0)
639
- api.openDb
640
- frontend event: menuZip