plugins: config.type.username.groups
Massimo Melina committed
Sep 24, 2024 at 14:45 UTC
39722d7c8993d638c8ef58178a30a722a5008342
2 files changed
+5
-3
admin/src/InstalledPlugins.ts
+2
-3
@@ -194,12 +194,11 @@ export async function startPlugin(id: string) {
194
}
195
}
196
197
-function UsernameField({ value, onChange, multiple, ...rest }: FieldProps<string>) {
197
+function UsernameField({ value, onChange, multiple, groups, ...rest }: FieldProps<string>) {
198
const { data, element, loading } = useApiEx<{ list: Account[] }>('get_accounts')
199
return !loading && element || h((multiple ? MultiSelectField : SelectField) as Field<string>, {
200
value, onChange,
201
- options: data?.list.map(x => x.username),
202
- helperText: "Only users, no groups here",
201
+ options: data?.list.filter(x => groups === undefined || groups === !x.hasPassword).map(x => x.username),
202
...rest,
203
})
204
}
dev-plugins.md
+3
@@ -158,6 +158,9 @@ Based on `type`, other properties are supported:
158
- `defaultPath: string` what path to start from if no value is set. E.g. __dirname if you want to start with your plugin's folder.
159
- `fileMask: string` restrict files that are displayed. E.g. `*.jpg|*.png`
160
- `username`
161
+ - `groups: undefined | boolean` true if you want only groups, false if you want only users. Default is undefined.
162
+ - `multiple: boolean` if you set this to true, the field will allow the selection of multiple accounts,
163
+ and the resulting value will be array of strings, instead of a string. Default is false.
164
165
## api object
166