fix: admin/config: error not displayed in case of too-high https port number

Massimo Melina committed Jun 3, 2022 at 15:43 UTC 22411fe3704d6b1236a513a06e292d1b19f56e14
1 file changed +15 -3
admin/src/ConfigPage.ts
+15 -3
@@ -141,7 +141,7 @@ export default function ConfigPage() {
141 await alertDialog("You are being redirected but in some cases this may fail. Hold on tight!", 'warning')
142 return window.location.href = loc.protocol + '//' + loc.hostname + ':' + newPort + loc.pathname
143 }
144 - setTimeout(reloadStatus, 2000) // in case of busy port, finding the name of the process can be a lengthy task. Worst case we'll get the generic error message
144 + setTimeout(reloadStatus, 2000) // in case of busy port, finding the name of the process can be a lengthy task. 2s is hopefully enough. Worst case we'll kee the generic error message
145 Object.assign(loaded, values) // since changes are recalculated subscribing state.config, but it depends on 'loaded' to (which cannot be subscribed), be sure to update loaded first
146 recalculateChanges()
147 toast("Changes applied", 'success')
@@ -165,7 +165,7 @@ export function isKeyError(error: any) {
165 return /private key/.test(error)
166 }
167
168 -function ServerPort({ label, value, onChange, getApi, status, suggestedPort=1, error }: FieldProps<number | null>) {
168 +function ServerPort({ label, value, onChange, getApi, status, suggestedPort=1, error, helperText }: FieldProps<number | null>) {
169 const lastCustom = useRef(suggestedPort)
170 if (value! > 0)
171 lastCustom.current = value!
@@ -181,6 +181,7 @@ function ServerPort({ label, value, onChange, getApi, status, suggestedPort=1, e
181 h(SelectField as Field<number>, {
182 sx: { flexGrow: 1 },
183 label,
184 + error,
185 value: selectValue,
186 options: [
187 { label: "off", value: -1 },
@@ -189,7 +190,18 @@ function ServerPort({ label, value, onChange, getApi, status, suggestedPort=1, e
190 ],
191 onChange,
192 }),
192 - value! > 0 && h(NumberField, { label: 'Number', fullWidth: false, value, onChange, getApi, error, min: 1, max: 65535, sx: { minWidth:'5.5em' } }),
193 + value! > 0 && h(NumberField, {
194 + label: "Number",
195 + fullWidth: false,
196 + value,
197 + onChange,
198 + getApi,
199 + error,
200 + min: 1,
201 + max: 65535,
202 + helperText,
203 + sx: { minWidth: '5.5em' }
204 + }),
205 ),
206 status && h(FormHelperText, { error },
207 status === true ? '...'