fix: admin/plugins: crash in case of config with type=username and multiple=true
Massimo Melina committed
Apr 4, 2026 at 19:23 UTC
923fa04db26e685ed835d14a1bcfa67cd57a261e
1 file changed
+4
-4
admin/src/pluginOptions.ts
+4
-4
@@ -154,14 +154,14 @@ const type2comp = {
154
function UsernameField({ value, onChange, multiple, groups, ...rest }: FieldProps<string>) {
155
const { data, element, loading } = useApiEx<typeof adminApis.get_accounts>('get_accounts')
156
const list = useMemo(() => data && _.sortBy(data.list, [x => !x.isGroup, x => !x.adminActualAccess, 'username']), [data])
157
- type UsernameOption = { value: string, label: string, a: Account }
158
- return !loading && element || h((multiple ? MultiSelectField : SelectField) as Field<string>, {
157
+ type UsernameOption = { value: string, label: string, a?: Account } // an account may be passed as value but not exist (anymore)
158
+ return (!loading || !data) && element || h((multiple ? MultiSelectField : SelectField) as Field<string>, {
159
value, onChange,
160
options: list?.filter(x => groups === undefined || groups === x.isGroup).map(a => ({ value: a.username, label: a.username, a })),
161
renderOption: (x: UsernameOption) => {
162
+ if (!x.a)
163
+ return h('span', { style: { textDecoration: 'line-through' } }, x.label)
164
const icon = x.a.isGroup && account2icon(x.a) || x.a.adminActualAccess && iconTooltip(MilitaryTech, "Can login into Admin")
163
- if (!icon)
164
- return x.label
165
return !icon ? x.label
166
: h('span', {},
167
h('span', { style: { marginLeft: -8, marginRight: 8 } }, icon),