refactor settings page
This commit is contained in:
1 parent
05f265743b
commit
08bd2d56f3
3 files changed
+86
-247
No files matched your search
@@ -18,7 +18,10 @@ interface FormAutocompleteProps<T extends FieldValues, O extends AutocompleteOpt
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormAutocomplete = <T extends FieldValues, O extends AutocompleteOption>({
|
export const FormAutocompleteField = <
|
||||||
|
T extends FieldValues,
|
||||||
|
O extends AutocompleteOption,
|
||||||
|
>({
|
||||||
name,
|
name,
|
||||||
options,
|
options,
|
||||||
fieldLabel,
|
fieldLabel,
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ import { SPACING } from "@/Utils/Theme/constants";
|
|||||||
interface FormSwitchProps<T extends FieldValues> {
|
interface FormSwitchProps<T extends FieldValues> {
|
||||||
name: FieldPath<T>;
|
name: FieldPath<T>;
|
||||||
label: string;
|
label: string;
|
||||||
|
labelPlacement?: "start" | "end"; // left | right
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormSwitchField = <T extends FieldValues>({
|
export const FormSwitchField = <T extends FieldValues>({
|
||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
|
labelPlacement = "end",
|
||||||
}: FormSwitchProps<T>) => {
|
}: FormSwitchProps<T>) => {
|
||||||
const { control } = useFormContext<T>();
|
const { control } = useFormContext<T>();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -29,14 +31,27 @@ export const FormSwitchField = <T extends FieldValues>({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems={"center"}
|
alignItems="center"
|
||||||
spacing={theme.spacing(SPACING.LG)}
|
spacing={labelPlacement === "start" ? undefined : theme.spacing(SPACING.LG)}
|
||||||
|
justifyContent={labelPlacement === "start" ? "space-between" : undefined}
|
||||||
>
|
>
|
||||||
|
{labelPlacement === "start" ? (
|
||||||
|
<>
|
||||||
|
<Typography>{label}</Typography>
|
||||||
|
<SwitchComponent
|
||||||
|
checked={field.value ?? false}
|
||||||
|
onChange={(e) => field.onChange(e.target.checked)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<SwitchComponent
|
<SwitchComponent
|
||||||
checked={field.value ?? false}
|
checked={field.value ?? false}
|
||||||
onChange={(e) => field.onChange(e.target.checked)}
|
onChange={(e) => field.onChange(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
<Typography>{label}</Typography>
|
<Typography>{label}</Typography>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { BasePage, ConfigBox, TextLink } from "@/Components/design-elements";
|
import { BasePage, ConfigBox, TextLink } from "@/Components/design-elements";
|
||||||
import { Autocomplete, Select, Dialog, SwitchComponent } from "@/Components/inputs";
|
import { Autocomplete, Select, Dialog } from "@/Components/inputs";
|
||||||
import { logger } from "@/Utils/logger";
|
import { logger } from "@/Utils/logger";
|
||||||
import { LAYOUT } from "@/Utils/Theme/constants";
|
import { LAYOUT } from "@/Utils/Theme/constants";
|
||||||
import {
|
import {
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
type SelectChangeEvent,
|
type SelectChangeEvent,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { FormProvider, useForm, type FieldPath } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
@@ -22,8 +22,7 @@ import { useSettingsForm } from "@/Hooks/useSettingsForm";
|
|||||||
import { useIsAdmin } from "@/Hooks/useIsAdmin.js";
|
import { useIsAdmin } from "@/Hooks/useIsAdmin.js";
|
||||||
import type { SettingsFormData, SettingsFormInput } from "@/Validation/settings";
|
import type { SettingsFormData, SettingsFormInput } from "@/Validation/settings";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Controller } from "react-hook-form";
|
import { Button, FieldLabel } from "@/Components/inputs";
|
||||||
import { TextField, Button, FieldLabel, SliderWithLabel } from "@/Components/inputs";
|
|
||||||
import { languageNames } from "@/Components/inputs/LanguageSelector";
|
import { languageNames } from "@/Components/inputs/LanguageSelector";
|
||||||
import { Box, Typography } from "@mui/material";
|
import { Box, Typography } from "@mui/material";
|
||||||
import { useDelete } from "@/Hooks/UseApi";
|
import { useDelete } from "@/Hooks/UseApi";
|
||||||
@@ -39,6 +38,9 @@ import {
|
|||||||
import timezones from "@/Utils/timezones.json";
|
import timezones from "@/Utils/timezones.json";
|
||||||
import type { RootState } from "@/Types/state";
|
import type { RootState } from "@/Types/state";
|
||||||
import { CHECK_TTL_SENTINEL } from "@/Types/Check";
|
import { CHECK_TTL_SENTINEL } from "@/Types/Check";
|
||||||
|
import { FormTextField } from "@/Components/inputs/forms/FormTextField";
|
||||||
|
import { FormSliderField } from "@/Components/inputs/forms/FormSliderField";
|
||||||
|
import { FormSwitchField } from "@/Components/inputs/forms/FormSwitchField";
|
||||||
|
|
||||||
interface Timezone {
|
interface Timezone {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -90,6 +92,26 @@ export const SettingsPage = () => {
|
|||||||
// Initialize form with schema and defaults
|
// Initialize form with schema and defaults
|
||||||
const { schema, defaults } = useSettingsForm({ data: fetchedSettings?.settings });
|
const { schema, defaults } = useSettingsForm({ data: fetchedSettings?.settings });
|
||||||
|
|
||||||
|
const emailSwitches: { name: FieldPath<SettingsFormInput>; label: string }[] = [
|
||||||
|
{
|
||||||
|
name: "systemEmailSecure",
|
||||||
|
label: t("pages.settings.form.email.option.secure.label"),
|
||||||
|
},
|
||||||
|
{ name: "systemEmailPool", label: t("pages.settings.form.email.option.pool.label") },
|
||||||
|
{
|
||||||
|
name: "systemEmailIgnoreTLS",
|
||||||
|
label: t("pages.settings.form.email.option.ignoreTLS.label"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "systemEmailRequireTLS",
|
||||||
|
label: t("pages.settings.form.email.option.requireTLS.label"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "systemEmailRejectUnauthorized",
|
||||||
|
label: t("pages.settings.form.email.option.rejectUnauthorized.label"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const form = useForm<SettingsFormInput, unknown, SettingsFormData>({
|
const form = useForm<SettingsFormInput, unknown, SettingsFormData>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: defaults,
|
defaultValues: defaults,
|
||||||
@@ -280,6 +302,7 @@ export const SettingsPage = () => {
|
|||||||
const languages = Object.keys(i18n.options.resources || {});
|
const languages = Object.keys(i18n.options.resources || {});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<FormProvider {...form}>
|
||||||
<BasePage
|
<BasePage
|
||||||
headerKey="settings"
|
headerKey="settings"
|
||||||
component="form"
|
component="form"
|
||||||
@@ -358,24 +381,13 @@ export const SettingsPage = () => {
|
|||||||
rightContent={
|
rightContent={
|
||||||
<>
|
<>
|
||||||
{(isApiKeySet === false || apiKeyHasBeenReset === true) && (
|
{(isApiKeySet === false || apiKeyHasBeenReset === true) && (
|
||||||
<Controller
|
<FormTextField
|
||||||
name="pagespeedApiKey"
|
name="pagespeedApiKey"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.pagespeedApiKey}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t(
|
|
||||||
"pages.settings.form.pagespeed.option.apiKey.label"
|
|
||||||
)}
|
|
||||||
type="password"
|
type="password"
|
||||||
|
fieldLabel={t("pages.settings.form.pagespeed.option.apiKey.label")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"pages.settings.form.pagespeed.option.apiKey.placeholder"
|
"pages.settings.form.pagespeed.option.apiKey.placeholder"
|
||||||
)}
|
)}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -403,29 +415,10 @@ export const SettingsPage = () => {
|
|||||||
title={t("pages.settings.form.url.title")}
|
title={t("pages.settings.form.url.title")}
|
||||||
subtitle={t("pages.settings.form.url.description")}
|
subtitle={t("pages.settings.form.url.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Controller
|
<FormSwitchField
|
||||||
name="showURL"
|
name="showURL"
|
||||||
control={form.control}
|
label={t("pages.settings.form.url.option.showURL.label")}
|
||||||
defaultValue={defaults.showURL}
|
labelPlacement="start"
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<Select
|
|
||||||
{...field}
|
|
||||||
value={field.value === undefined ? "false" : field.value.toString()}
|
|
||||||
onChange={(e) => {
|
|
||||||
const value = e.target.value === "true";
|
|
||||||
field.onChange(value);
|
|
||||||
}}
|
|
||||||
fieldLabel={t("pages.settings.form.url.option.showURL.label")}
|
|
||||||
error={!!fieldState.error}
|
|
||||||
>
|
|
||||||
<MenuItem value="true">
|
|
||||||
{t("pages.settings.form.url.option.showURL.enabled")}
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem value="false">
|
|
||||||
{t("pages.settings.form.url.option.showURL.disabled")}
|
|
||||||
</MenuItem>
|
|
||||||
</Select>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -453,19 +446,11 @@ export const SettingsPage = () => {
|
|||||||
title={t("pages.settings.form.retention.title")}
|
title={t("pages.settings.form.retention.title")}
|
||||||
subtitle={t("pages.settings.form.retention.description")}
|
subtitle={t("pages.settings.form.retention.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Controller
|
<FormSliderField
|
||||||
name="checkTTL"
|
name="checkTTL"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.checkTTL}
|
|
||||||
render={({ field }) => (
|
|
||||||
<SliderWithLabel
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t("pages.settings.form.retention.option.days.label")}
|
fieldLabel={t("pages.settings.form.retention.option.days.label")}
|
||||||
min={1}
|
min={1}
|
||||||
max={CHECK_TTL_SENTINEL}
|
max={CHECK_TTL_SENTINEL}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
|
||||||
value={field.value || 30}
|
|
||||||
onChange={(_, value) => field.onChange(value)}
|
|
||||||
valueLabelDisplay="auto"
|
valueLabelDisplay="auto"
|
||||||
valueLabelFormat={(value: number) =>
|
valueLabelFormat={(value: number) =>
|
||||||
value >= CHECK_TTL_SENTINEL
|
value >= CHECK_TTL_SENTINEL
|
||||||
@@ -478,8 +463,6 @@ export const SettingsPage = () => {
|
|||||||
: `${value}`
|
: `${value}`
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -491,75 +474,36 @@ export const SettingsPage = () => {
|
|||||||
subtitle={t("pages.settings.form.thresholds.description")}
|
subtitle={t("pages.settings.form.thresholds.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={2}>
|
<Stack spacing={2}>
|
||||||
<Controller
|
<FormSliderField
|
||||||
name="globalThresholds.cpu"
|
name="globalThresholds.cpu"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.globalThresholds?.cpu}
|
|
||||||
render={({ field }) => (
|
|
||||||
<SliderWithLabel
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t("pages.settings.form.thresholds.option.cpu.label")}
|
fieldLabel={t("pages.settings.form.thresholds.option.cpu.label")}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
min={1}
|
min={1}
|
||||||
max={100}
|
max={100}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
|
||||||
value={field.value || 1}
|
|
||||||
onChange={(_, value) => field.onChange(value)}
|
|
||||||
valueLabelDisplay="auto"
|
|
||||||
/>
|
/>
|
||||||
)}
|
<FormSliderField
|
||||||
/>
|
|
||||||
<Controller
|
|
||||||
name="globalThresholds.memory"
|
name="globalThresholds.memory"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.globalThresholds?.memory}
|
|
||||||
render={({ field }) => (
|
|
||||||
<SliderWithLabel
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t("pages.settings.form.thresholds.option.memory.label")}
|
fieldLabel={t("pages.settings.form.thresholds.option.memory.label")}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
min={1}
|
min={1}
|
||||||
max={100}
|
max={100}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
|
||||||
value={field.value || 1}
|
|
||||||
onChange={(_, value) => field.onChange(value)}
|
|
||||||
valueLabelDisplay="auto"
|
|
||||||
/>
|
/>
|
||||||
)}
|
<FormSliderField
|
||||||
/>
|
|
||||||
<Controller
|
|
||||||
name="globalThresholds.disk"
|
name="globalThresholds.disk"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.globalThresholds?.disk}
|
|
||||||
render={({ field }) => (
|
|
||||||
<SliderWithLabel
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t("pages.settings.form.thresholds.option.disk.label")}
|
fieldLabel={t("pages.settings.form.thresholds.option.disk.label")}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
min={1}
|
min={1}
|
||||||
max={100}
|
max={100}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
|
||||||
value={field.value || 1}
|
|
||||||
onChange={(_, value) => field.onChange(value)}
|
|
||||||
valueLabelDisplay="auto"
|
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
/>
|
<FormSliderField
|
||||||
<Controller
|
|
||||||
name="globalThresholds.temperature"
|
name="globalThresholds.temperature"
|
||||||
control={form.control}
|
|
||||||
defaultValue={defaults.globalThresholds?.temperature}
|
|
||||||
render={({ field }) => (
|
|
||||||
<SliderWithLabel
|
|
||||||
{...field}
|
|
||||||
fieldLabel={t(
|
fieldLabel={t(
|
||||||
"pages.settings.form.thresholds.option.temperature.label"
|
"pages.settings.form.thresholds.option.temperature.label"
|
||||||
)}
|
)}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
min={1}
|
min={1}
|
||||||
max={150}
|
max={150}
|
||||||
sliderMaxWidth={{ xs: "100%", md: "50%" }}
|
|
||||||
value={field.value || 1}
|
|
||||||
onChange={(_, value) => field.onChange(value)}
|
|
||||||
valueLabelDisplay="auto"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
@@ -605,7 +549,8 @@ export const SettingsPage = () => {
|
|||||||
user: form.watch("systemEmailUser") || address,
|
user: form.watch("systemEmailUser") || address,
|
||||||
pass: "<your_password>",
|
pass: "<your_password>",
|
||||||
},
|
},
|
||||||
name: form.watch("systemEmailConnectionHost") || "localhost",
|
name:
|
||||||
|
form.watch("systemEmailConnectionHost") || "localhost",
|
||||||
pool: form.watch("systemEmailPool") ?? false,
|
pool: form.watch("systemEmailPool") ?? false,
|
||||||
tls: {
|
tls: {
|
||||||
rejectUnauthorized:
|
rejectUnauthorized:
|
||||||
@@ -644,98 +589,41 @@ export const SettingsPage = () => {
|
|||||||
rightContent={
|
rightContent={
|
||||||
<Stack gap={theme.spacing(LAYOUT.MD)}>
|
<Stack gap={theme.spacing(LAYOUT.MD)}>
|
||||||
{/* Email Host */}
|
{/* Email Host */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailHost"
|
name="systemEmailHost"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.host.label")}
|
fieldLabel={t("pages.settings.form.email.option.host.label")}
|
||||||
placeholder={t("pages.settings.form.email.option.host.placeholder")}
|
placeholder={t("pages.settings.form.email.option.host.placeholder")}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email Port */}
|
{/* Email Port */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailPort"
|
name="systemEmailPort"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
name={field.name}
|
|
||||||
ref={field.ref}
|
|
||||||
onBlur={field.onBlur}
|
|
||||||
value={
|
|
||||||
field.value === undefined || field.value === 0 ? "" : field.value
|
|
||||||
}
|
|
||||||
onChange={(e) => {
|
|
||||||
const val = e.target.value;
|
|
||||||
field.onChange(val === "" ? 0 : Number(val));
|
|
||||||
}}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.port.label")}
|
fieldLabel={t("pages.settings.form.email.option.port.label")}
|
||||||
type="number"
|
|
||||||
inputProps={{ min: 0 }}
|
|
||||||
placeholder={t("pages.settings.form.email.option.port.placeholder")}
|
placeholder={t("pages.settings.form.email.option.port.placeholder")}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email Address */}
|
{/* Email Address */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailAddress"
|
name="systemEmailAddress"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.address.label")}
|
|
||||||
placeholder={t(
|
|
||||||
"pages.settings.form.email.option.address.placeholder"
|
|
||||||
)}
|
|
||||||
type="email"
|
type="email"
|
||||||
error={!!fieldState.error}
|
fieldLabel={t("pages.settings.form.email.option.address.label")}
|
||||||
helperText={fieldState.error?.message}
|
placeholder={t("pages.settings.form.email.option.address.placeholder")}
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email Display Name (Optional) */}
|
{/* Email Display Name (Optional) */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailDisplayName"
|
name="systemEmailDisplayName"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.displayName.label")}
|
fieldLabel={t("pages.settings.form.email.option.displayName.label")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"pages.settings.form.email.option.displayName.placeholder"
|
"pages.settings.form.email.option.displayName.placeholder"
|
||||||
)}
|
)}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email User (Optional) */}
|
{/* Email User (Optional) */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailUser"
|
name="systemEmailUser"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.user.label")}
|
fieldLabel={t("pages.settings.form.email.option.user.label")}
|
||||||
placeholder={t("pages.settings.form.email.option.user.placeholder")}
|
placeholder={t("pages.settings.form.email.option.user.placeholder")}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email Password with Reset Pattern */}
|
{/* Email Password with Reset Pattern */}
|
||||||
@@ -760,114 +648,46 @@ export const SettingsPage = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailPassword"
|
name="systemEmailPassword"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.password.label")}
|
|
||||||
type="password"
|
type="password"
|
||||||
|
fieldLabel={t("pages.settings.form.email.option.password.label")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"pages.settings.form.email.option.password.placeholder"
|
"pages.settings.form.email.option.password.placeholder"
|
||||||
)}
|
)}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* TLS Servername (Optional) */}
|
{/* TLS Servername (Optional) */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailTLSServername"
|
name="systemEmailTLSServername"
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t("pages.settings.form.email.option.tlsServername.label")}
|
fieldLabel={t("pages.settings.form.email.option.tlsServername.label")}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"pages.settings.form.email.option.tlsServername.placeholder"
|
"pages.settings.form.email.option.tlsServername.placeholder"
|
||||||
)}
|
)}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Connection Host (Optional) */}
|
{/* Connection Host (Optional) */}
|
||||||
<Controller
|
<FormTextField
|
||||||
name="systemEmailConnectionHost"
|
name="systemEmailConnectionHost"
|
||||||
control={form.control}
|
fieldLabel={t("pages.settings.form.email.option.connectionHost.label")}
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextField
|
|
||||||
{...field}
|
|
||||||
value={field.value ?? ""}
|
|
||||||
fieldLabel={t(
|
|
||||||
"pages.settings.form.email.option.connectionHost.label"
|
|
||||||
)}
|
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"pages.settings.form.email.option.connectionHost.placeholder"
|
"pages.settings.form.email.option.connectionHost.placeholder"
|
||||||
)}
|
)}
|
||||||
error={!!fieldState.error}
|
|
||||||
helperText={fieldState.error?.message}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Boolean Switches */}
|
{/* Boolean Switches */}
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
display={"flex"}
|
||||||
display: "flex",
|
flexDirection={"column"}
|
||||||
flexDirection: "column",
|
gap={theme.spacing(LAYOUT.XS)}
|
||||||
gap: theme.spacing(LAYOUT.XS),
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{[
|
{emailSwitches.map(({ name, label }) => (
|
||||||
{
|
<FormSwitchField
|
||||||
name: "systemEmailSecure",
|
|
||||||
label: t("pages.settings.form.email.option.secure.label"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "systemEmailPool",
|
|
||||||
label: t("pages.settings.form.email.option.pool.label"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "systemEmailIgnoreTLS",
|
|
||||||
label: t("pages.settings.form.email.option.ignoreTLS.label"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "systemEmailRequireTLS",
|
|
||||||
label: t("pages.settings.form.email.option.requireTLS.label"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "systemEmailRejectUnauthorized",
|
|
||||||
label: t("pages.settings.form.email.option.rejectUnauthorized.label"),
|
|
||||||
},
|
|
||||||
].map(({ name, label }) => (
|
|
||||||
<Controller
|
|
||||||
key={name}
|
key={name}
|
||||||
name={name as any}
|
name={name}
|
||||||
control={form.control}
|
label={label}
|
||||||
render={({ field }) => (
|
labelPlacement="start"
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography>{label}</Typography>
|
|
||||||
<SwitchComponent
|
|
||||||
checked={field.value ?? false}
|
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
||||||
field.onChange(e.target.checked)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
@@ -1078,6 +898,7 @@ export const SettingsPage = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</BasePage>
|
</BasePage>
|
||||||
|
</FormProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user