feature: the package installs the Router Manager, which is no longer a package of its own.
Release / release (push) Failing after 4s
Release / release (push) Failing after 4s
This commit is contained in:
1 parent
6d90441bee
commit
8efe21bfa6
129 files changed
+17381
-104
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Stack, Switch, Typography } from '@mui/material'
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import type { HttpsSettings } from './api.ts'
|
||||
|
||||
/**
|
||||
* A dialog that switches the CA of the certificates Caddy obtains on the router: Let's Encrypt's staging environment,
|
||||
* https.acme_staging, or Caddy's default CAs. onSave sends acme_staging; the dialog closes when it succeeds and shows
|
||||
* the router's message when it fails.
|
||||
*/
|
||||
export default function HttpsSettingsDialog(props: {
|
||||
current: HttpsSettings
|
||||
onSave: (settings: { acme_staging: boolean }) => Promise<void>
|
||||
onCancel: () => void
|
||||
}) {
|
||||
const [staging, setStaging] = useState(props.current.acme_staging)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
async function submit(event: FormEvent) {
|
||||
event.preventDefault()
|
||||
setSaving(true)
|
||||
setError(null)
|
||||
try {
|
||||
await props.onSave({ acme_staging: staging })
|
||||
} catch (caught) {
|
||||
setError((caught as Error).message)
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open onClose={(_event, reason) => reason !== 'backdropClick' && props.onCancel()} maxWidth="sm" fullWidth slotProps={{ paper: { component: 'form', onSubmit: submit } }}>
|
||||
<DialogTitle>HTTPS settings</DialogTitle>
|
||||
<DialogContent>
|
||||
<Stack sx={{ gap: 2, pt: 1 }}>
|
||||
{error && <Alert severity="error" sx={{ whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
<FormControlLabel control={<Switch checked={staging} onChange={(event) => setStaging(event.target.checked)} />} label="Let's Encrypt staging CA" />
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{staging
|
||||
? 'Caddy takes every certificate from Let\'s Encrypt\'s staging environment, the web sites\' included. Its rate limits are far higher, but no browser trusts its certificates: for routers rebuilt often, for tests only.'
|
||||
: 'Caddy takes its certificates from Let\'s Encrypt, and from ZeroSSL when Let\'s Encrypt refuses, such as for its limit of 5 certificates a week for the same name.'}
|
||||
</Typography>
|
||||
{staging !== props.current.acme_staging && (
|
||||
<Alert severity="info">The router runs its setup again, which applies the change.</Alert>
|
||||
)}
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={props.onCancel} disabled={saving}>Cancel</Button>
|
||||
<Button type="submit" variant="contained" disabled={saving || staging === props.current.acme_staging}>Save</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user