new type for plugin config: real_path
Massimo Melina committed
Jun 5, 2022 at 11:15 UTC
22dd09bb70c490d26e524846debe28a96b6e9e30
4 files changed
+8
-4
admin/src/FileField.ts
+2
-2
@@ -7,7 +7,7 @@ import { newDialog } from '@hfs/shared'
7
import FilePicker from './FilePicker'
8
import { apiCall } from './api'
9
10
-export default function FileField({ value, onChange, files=true, title, ...props }: FieldProps<string>) {
10
+export default function FileField({ value, onChange, files=true, folders=false, title, ...props }: FieldProps<string>) {
11
return h(StringField, {
12
...props,
13
value,
@@ -28,7 +28,7 @@ export default function FileField({ value, onChange, files=true, title, ...props
28
function Content() {
29
return h(FilePicker, {
30
multiple: false,
31
- folders: false,
31
+ folders,
32
files,
33
from: value,
34
async onSelect(sel) {
admin/src/InstalledPlugins.ts
+2
@@ -8,6 +8,7 @@ import { formDialog, toast } from './dialog'
8
import _ from 'lodash'
9
import { BoolField, Field, MultiSelectField, NumberField, SelectField, StringField } from '@hfs/mui-grid-form'
10
import { ArrayField } from './ArrayField'
11
+import FileField from './FileField'
12
13
export default function InstalledPlugins({ updates }: { updates?: true }) {
14
const { list, setList, error, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins')
@@ -131,6 +132,7 @@ const type2comp = {
132
select: SelectField,
133
multiselect: MultiSelectField,
134
array: ArrayField,
135
+ real_path: FileField,
136
}
137
138
export function repoLink(repo?: string) {
dev-plugins.md
+4
-1
@@ -72,7 +72,7 @@ All the following properties are essentially optional.
72
### FieldDescriptor
73
74
Currently, these properties are supported:
75
-- `type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect'` . Default is `string`.
75
+- `type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'real_path'` . Default is `string`.
76
- `label: string` what name to display next to the field. Default is based on `key`.
77
- `defaultValue: any` value to be used when nothing is set.
78
- `helperText: string` extra text printed next to the field.
@@ -86,6 +86,9 @@ Based on `type`, other properties are supported:
86
- `select`
87
- `options: { [label]: AnyJsonValue }`
88
- `multiselect` it's like `select` but its result is an array of values.
89
+- `real_path` path to server disk
90
+ - `files` allow to select a file. Default is `true`.
91
+ - `folders` allow to select a folder. Default is `false`.
92
93
## api object
94
todo.md
-1
@@ -1,6 +1,5 @@
1
# To do
2
- plugin api to read hfs config
3
-- plugin: config to be able to declare a file field (real-path) https://github.com/rejetto/hfs/issues/46
3
- fix: root without can_download breaks
4
- use dialogs instead of side-forms on mobile (admin/fs+accounts)
5
- easier deploy on cloud server