mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-20 00:05:26 +02:00
feat: Add reset functionality
This commit is contained in:
parent
a29fe864d3
commit
6dd49d659e
@ -390,7 +390,8 @@
|
|||||||
"title": "Random aliases will look like this",
|
"title": "Random aliases will look like this",
|
||||||
"helperText": "This is just a preview. Those are not real aliases."
|
"helperText": "This is just a preview. Those are not real aliases."
|
||||||
},
|
},
|
||||||
"randomAliasesIncreaseExplanation": "Random aliases' length will be increased from {{originalLength}} to {{increasedLength}} characters after {{amount}} aliases have been created."
|
"randomAliasesIncreaseExplanation": "Random aliases' length will be increased from {{originalLength}} to {{increasedLength}} characters after {{amount}} aliases have been created.",
|
||||||
|
"resetLabel": "Reset to defaults"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@ import * as yup from "yup"
|
|||||||
import {useFormik} from "formik"
|
import {useFormik} from "formik"
|
||||||
import {TbCursorText} from "react-icons/tb"
|
import {TbCursorText} from "react-icons/tb"
|
||||||
import {useTranslation} from "react-i18next"
|
import {useTranslation} from "react-i18next"
|
||||||
import {MdCheck, MdOutlineChangeCircle, MdTextFormat} from "react-icons/md"
|
import {MdCheck, MdClear, MdOutlineChangeCircle, MdTextFormat} from "react-icons/md"
|
||||||
import {BsImage} from "react-icons/bs"
|
import {BsImage} from "react-icons/bs"
|
||||||
import {AxiosError} from "axios"
|
import {AxiosError} from "axios"
|
||||||
|
|
||||||
@ -122,6 +122,8 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
initialValues: settings,
|
initialValues: settings,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Fields will either have a value or be filled from the default values.
|
||||||
|
// That means we will never have a `null` value.
|
||||||
return (
|
return (
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={formik.handleSubmit}>
|
||||||
<Grid
|
<Grid
|
||||||
@ -193,7 +195,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
"routes.AdminRoute.forms.settings.randomEmailIdChars.label",
|
"routes.AdminRoute.forms.settings.randomEmailIdChars.label",
|
||||||
)}
|
)}
|
||||||
name="randomEmailIdChars"
|
name="randomEmailIdChars"
|
||||||
value={formik.values.randomEmailIdChars}
|
value={formik.values.randomEmailIdChars!}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
error={
|
error={
|
||||||
formik.touched.randomEmailIdChars &&
|
formik.touched.randomEmailIdChars &&
|
||||||
@ -216,8 +218,8 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item marginX="auto">
|
<Grid item marginX="auto">
|
||||||
<RandomAliasGenerator
|
<RandomAliasGenerator
|
||||||
characters={formik.values.randomEmailIdChars}
|
characters={formik.values.randomEmailIdChars!}
|
||||||
length={formik.values.randomEmailIdMinLength}
|
length={formik.values.randomEmailIdMinLength!}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
@ -255,9 +257,9 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<AliasesPercentageAmount
|
<AliasesPercentageAmount
|
||||||
percentage={formik.values.randomEmailLengthIncreaseOnPercentage}
|
percentage={formik.values.randomEmailLengthIncreaseOnPercentage!}
|
||||||
length={formik.values.randomEmailIdMinLength}
|
length={formik.values.randomEmailIdMinLength!}
|
||||||
characters={formik.values.randomEmailIdChars}
|
characters={formik.values.randomEmailIdChars!}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item md={6}>
|
<Grid item md={6}>
|
||||||
@ -304,7 +306,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
"routes.AdminRoute.forms.settings.customEmailSuffixChars.label",
|
"routes.AdminRoute.forms.settings.customEmailSuffixChars.label",
|
||||||
)}
|
)}
|
||||||
name="customEmailSuffixChars"
|
name="customEmailSuffixChars"
|
||||||
value={formik.values.customEmailSuffixChars}
|
value={formik.values.customEmailSuffixChars!}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
error={
|
error={
|
||||||
formik.touched.customEmailSuffixChars &&
|
formik.touched.customEmailSuffixChars &&
|
||||||
@ -403,7 +405,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={formik.values.userEmailEnableOtherRelays}
|
checked={formik.values.userEmailEnableOtherRelays!}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
name="userEmailEnableOtherRelays"
|
name="userEmailEnableOtherRelays"
|
||||||
/>
|
/>
|
||||||
@ -431,7 +433,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={formik.values.enableImageProxy}
|
checked={formik.values.enableImageProxy!}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
name="enableImageProxy"
|
name="enableImageProxy"
|
||||||
/>
|
/>
|
||||||
@ -459,7 +461,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={formik.values.allowStatistics}
|
checked={formik.values.allowStatistics!}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
name="allowStatistics"
|
name="allowStatistics"
|
||||||
/>
|
/>
|
||||||
@ -485,7 +487,22 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Grid container justifyContent="center">
|
<Grid container justifyContent="center" gap={2}>
|
||||||
|
<Grid item>
|
||||||
|
<LoadingButton
|
||||||
|
loading={formik.isSubmitting}
|
||||||
|
variant="outlined"
|
||||||
|
type="reset"
|
||||||
|
startIcon={<MdClear />}
|
||||||
|
color="warning"
|
||||||
|
onClick={() => {
|
||||||
|
formik.setValues(DEFAULT_ADMIN_SETTINGS)
|
||||||
|
formik.submitForm()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("routes.AdminRoute.forms.settings.resetLabel")}
|
||||||
|
</LoadingButton>
|
||||||
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={formik.isSubmitting}
|
loading={formik.isSubmitting}
|
||||||
|
@ -200,14 +200,14 @@ export interface GetPageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminSettings {
|
export interface AdminSettings {
|
||||||
randomEmailIdMinLength: number
|
randomEmailIdMinLength: number | null
|
||||||
randomEmailIdChars: string
|
randomEmailIdChars: string | null
|
||||||
randomEmailLengthIncreaseOnPercentage: number
|
randomEmailLengthIncreaseOnPercentage: number | null
|
||||||
customEmailSuffixLength: number
|
customEmailSuffixLength: number
|
||||||
customEmailSuffixChars: string
|
customEmailSuffixChars: string | null
|
||||||
imageProxyStorageLifeTimeInHours: number
|
imageProxyStorageLifeTimeInHours: number
|
||||||
enableImageProxy: boolean
|
enableImageProxy: boolean | null
|
||||||
userEmailEnableDisposableEmails: boolean
|
userEmailEnableDisposableEmails: boolean
|
||||||
userEmailEnableOtherRelays: boolean
|
userEmailEnableOtherRelays: boolean | null
|
||||||
allowStatistics: boolean
|
allowStatistics: boolean | null
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user