fix: admin/accounts: it was not possible to clear the "redirect" field
Massimo Melina committed
Feb 17, 2024 at 13:02 UTC
dec72954c4e880d05d76d47b4a16f30f066040ac
3 files changed
+7
-5
admin/src/AccountForm.ts
+1
-1
@@ -84,7 +84,7 @@ export default function AccountForm({ account, done, groups, addToBar, reload }:
84
helperText: "When expired, login won't be allowed" },
85
{ k: 'days_to_live', xs: 12, sm: 6, comp: NumberField, disabled: expired, step: 'any', min: 1/1000, // 10 minutes
86
helperText: "Used to set expiration on first login" + (expired ? " (already expired)" : '') },
87
- { k: 'redirect', comp: VfsPathField, onlyFolders: false,
87
+ { k: 'redirect', comp: VfsPathField, onlyFolders: false, placeholder: "no",
88
helperText: "If you want this account to be redirected to a specific folder/address (or even file) at login time" },
89
],
90
onError: alertDialog,
admin/src/VfsMenuBar.ts
+4
-1
@@ -41,7 +41,10 @@ export default function VfsMenuBar({ statusApi }: { statusApi: ApiObject }) {
41
} }),
42
h(Alert, { severity: 'info' }, "It will also automatically copy the URL, ready to paste!"),
43
)
44
- const parent = await promptDialog(msg, { field: { comp: VfsPathField, label: "Add to this folder" }, form: { saveOnEnter: false } })
44
+ const parent = await promptDialog(msg, {
45
+ field: { comp: VfsPathField, label: "Add to this folder", placeholder: "home" },
46
+ form: { saveOnEnter: false }
47
+ })
48
return !parent ? false : apiCall('windows_integration', { parent }).then(reload)
49
}
50
} : {
admin/src/VfsPathField.ts
+2
-3
@@ -1,4 +1,4 @@
1
-import { dirname } from './misc'
1
+import { dirname, enforceFinal } from './misc'
2
import { useApiList } from './api'
3
import { createElement as h, useMemo } from 'react'
4
import { Autocomplete, AutocompleteProps, TextField } from '@mui/material'
@@ -20,14 +20,13 @@ export default function VfsPathField({ value='', onChange, helperText, setApi, a
20
disableClearable: true,
21
renderInput: params => h(TextField, {
22
helperText,
23
- placeholder: "home",
23
onChange(event) {
24
const v = event.target.value
25
if (v.endsWith('/') || !v)
26
onChange(v, { was: value, event })
27
},
28
onBlur(event) {
30
- const v = event.target.value + '/'
29
+ const v = enforceFinal('/', event.target.value)
30
if (options.includes(v))
31
onChange(v, { was: value, event })
32
},