select -> radio, update descriptions

This commit is contained in:
Alex Holliday committed 2026-08-25 09:55:34 -07:00
1 parent 0c21dcdd2a
commit 6e271f834c
3 files changed
+39 -41

No files matched your search

@@ -8,6 +8,7 @@ import {
} from "react-hook-form"; } from "react-hook-form";
import { LAYOUT } from "@/Utils/Theme/constants"; import { LAYOUT } from "@/Utils/Theme/constants";
import { RadioWithDescription } from "@/Components/inputs/Radio"; import { RadioWithDescription } from "@/Components/inputs/Radio";
import { FieldLabel } from "@/Components/inputs/FieldLabel";
export interface FormRadioOption { export interface FormRadioOption {
value: string; value: string;
label: string; label: string;
@@ -17,10 +18,12 @@ export interface FormRadioOption {
interface FormRadioGroupProps<T extends FieldValues> { interface FormRadioGroupProps<T extends FieldValues> {
name: FieldPath<T>; name: FieldPath<T>;
options: FormRadioOption[]; options: FormRadioOption[];
fieldLabel?: string;
} }
export const FormRadioGroup = <T extends FieldValues>({ export const FormRadioGroup = <T extends FieldValues>({
name, name,
options, options,
fieldLabel,
}: FormRadioGroupProps<T>) => { }: FormRadioGroupProps<T>) => {
const { control } = useFormContext<T>(); const { control } = useFormContext<T>();
const theme = useTheme(); const theme = useTheme();
@@ -30,6 +33,7 @@ export const FormRadioGroup = <T extends FieldValues>({
control={control} control={control}
render={({ field, fieldState }) => ( render={({ field, fieldState }) => (
<FormControl error={!!fieldState.error}> <FormControl error={!!fieldState.error}>
{fieldLabel && <FieldLabel>{fieldLabel}</FieldLabel>}
<RadioGroup <RadioGroup
{...field} {...field}
sx={{ gap: theme.spacing(LAYOUT.MD) }} sx={{ gap: theme.spacing(LAYOUT.MD) }}
+25 -34
View File
@@ -484,13 +484,31 @@ const CreateMonitorPage = () => {
})), })),
[t] [t]
); );
const globalProxyName =
appSettings?.settings?.globalProxyEnabled === true
? proxies?.find((proxy) => proxy.id === appSettings?.settings?.globalProxyId)?.name
: undefined;
const proxyModeOptions = useMemo( const proxyModeOptions = useMemo(
() => () =>
ProxyModes.map((mode) => ({ ProxyModes.map((mode) => {
value: mode, const key =
label: t(`pages.createMonitor.form.general.option.proxyMode.value.${mode}`), mode === "inherit"
})), ? globalProxyName
[t] ? "inheritGlobal"
: "inheritDirect"
: mode;
return {
value: mode,
label: t(`pages.createMonitor.form.general.option.proxyMode.value.${key}`, {
name: globalProxyName,
}),
description: t(
`pages.createMonitor.form.general.option.proxyMode.description.${key}`
),
};
}),
[t, globalProxyName]
); );
const proxyOptions = useMemo( const proxyOptions = useMemo(
@@ -502,13 +520,6 @@ const CreateMonitorPage = () => {
[proxies] [proxies]
); );
const globalProxyName =
appSettings?.settings?.globalProxyEnabled === true
? proxies?.find((proxy) => proxy.id === appSettings?.settings?.globalProxyId)?.name
: undefined;
console.log({ appSettings });
return ( return (
<FormProvider {...form}> <FormProvider {...form}>
<BasePage <BasePage
@@ -577,33 +588,13 @@ const CreateMonitorPage = () => {
{/* Proxy fields - only shown for HTTP */} {/* Proxy fields - only shown for HTTP */}
{generalSettingsConfig.showProxy && ( {generalSettingsConfig.showProxy && (
<> <>
<FormSelectField <FormRadioGroup
name="proxyMode" name="proxyMode"
options={proxyModeOptions}
fieldLabel={t( fieldLabel={t(
"pages.createMonitor.form.general.option.proxyMode.label" "pages.createMonitor.form.general.option.proxyMode.label"
)} )}
options={proxyModeOptions}
/> />
{watchedProxyMode === "inherit" && (
<Typography
component="span"
color={
globalProxyName
? theme.palette.text.secondary
: theme.palette.warning.main
}
sx={{ opacity: 0.8 }}
>
{globalProxyName
? t(
"pages.createMonitor.form.general.option.proxyMode.effect.global",
{ name: globalProxyName }
)
: t(
"pages.createMonitor.form.general.option.proxyMode.effect.direct"
)}
</Typography>
)}
{watchedProxyMode === "custom" && ( {watchedProxyMode === "custom" && (
<FormSelectField <FormSelectField
name="proxyId" name="proxyId"
+10 -7
View File
@@ -640,15 +640,18 @@
"placeholder": "https://www.google.com" "placeholder": "https://www.google.com"
}, },
"proxyMode": { "proxyMode": {
"label": "Proxy mode", "label": "Proxy",
"value": { "value": {
"inherit": "Use global proxy setting", "inheritDirect": "Default (direct connection)",
"none": "No proxy (direct connection)", "inheritGlobal": "Default (global proxy: {{name}})",
"custom": "Custom" "none": "Never use a proxy",
"custom": "Custom proxy"
}, },
"effect": { "description": {
"global": "Checks currently go through the global proxy: {{name}}", "inheritDirect": "No global proxy is configured, connect directly. If a global proxy is later configured, this monitor will use it.",
"direct": "Global proxy not enabled, will use direct connection" "inheritGlobal": "Follows the global proxy setting — changing it in Settings also changes this monitor's connection.",
"none": "Always connects directly even if a global proxy is enabled later.",
"custom": "Route this monitor's checks through a specific proxy. Overrides global proxy"
} }
}, },
"proxy": { "proxy": {