diff --git a/client/src/Components/design-elements/StepProgress.tsx b/client/src/Components/design-elements/StepProgress.tsx
new file mode 100644
index 000000000..33a49b15d
--- /dev/null
+++ b/client/src/Components/design-elements/StepProgress.tsx
@@ -0,0 +1,42 @@
+import Stack from "@mui/material/Stack";
+import Box from "@mui/material/Box";
+import { useTheme, alpha } from "@mui/material/styles";
+import { LAYOUT } from "@/Utils/Theme/constants";
+
+interface StepProgressProps {
+ steps: number;
+ current: number;
+}
+
+export const StepProgress = ({ steps, current }: StepProgressProps) => {
+ const theme = useTheme();
+ const activeBg = `linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.primary.main} 100%)`;
+ const completedBg = `linear-gradient(135deg, ${alpha(theme.palette.primary.light, 0.5)} 0%, ${alpha(theme.palette.primary.main, 0.5)} 100%)`;
+
+ const getSegmentBackground = (index: number) => {
+ if (index < current) return completedBg;
+ if (index === current) return activeBg;
+ return theme.palette.divider;
+ };
+
+ return (
+
+ {Array.from({ length: steps }).map((_, index) => (
+
+ ))}
+
+ );
+};
diff --git a/client/src/Components/design-elements/index.tsx b/client/src/Components/design-elements/index.tsx
index 130ccd831..d7d38d014 100644
--- a/client/src/Components/design-elements/index.tsx
+++ b/client/src/Components/design-elements/index.tsx
@@ -27,3 +27,4 @@ export * from "./OfflineBanner";
export * from "./Avatar";
export * from "./StatusCodeLabel";
export * from "./StrategyBadge";
+export * from "./StepProgress";
diff --git a/client/src/Hooks/useMonitorForm.ts b/client/src/Hooks/useMonitorForm.ts
index eeb5c138e..50fa62ec3 100644
--- a/client/src/Hooks/useMonitorForm.ts
+++ b/client/src/Hooks/useMonitorForm.ts
@@ -16,126 +16,140 @@ const getBaseDefaults = (data?: Monitor | null) => ({
tags: data?.tags || [],
statusWindowSize: data?.statusWindowSize || 5,
statusWindowThreshold: data?.statusWindowThreshold || 60,
+});
+
+// Geo-check defaults — only http and ping support geo checks.
+const getGeoCheckDefaults = (data?: Monitor | null) => ({
geoCheckEnabled: data?.geoCheckEnabled ?? false,
geoCheckLocations: data?.geoCheckLocations || [],
geoCheckInterval: data?.geoCheckInterval || 300000,
});
+export const getMonitorDefaults = (
+ type: MonitorType,
+ data: Monitor | null = null
+): MonitorFormData => {
+ const base = getBaseDefaults(data);
+
+ let defaults: MonitorFormData;
+
+ switch (type) {
+ case "http":
+ defaults = {
+ ...base,
+ ...getGeoCheckDefaults(data),
+ type: "http",
+ url: data?.url || "",
+ ignoreTlsErrors: data?.ignoreTlsErrors || false,
+ useAdvancedMatching: data?.useAdvancedMatching || false,
+ matchMethod: data?.matchMethod || "",
+ expectedValue: data?.expectedValue || "",
+ jsonPath: data?.jsonPath || "",
+ };
+ break;
+ case "ping":
+ defaults = {
+ ...base,
+ ...getGeoCheckDefaults(data),
+ type: "ping",
+ url: data?.url || "",
+ };
+ break;
+ case "port":
+ defaults = {
+ ...base,
+ type: "port",
+ url: data?.url || "",
+ port: data?.port || 80,
+ };
+ break;
+ case "docker":
+ defaults = {
+ ...base,
+ type: "docker",
+ url: data?.url || "",
+ };
+ break;
+ case "game":
+ defaults = {
+ ...base,
+ type: "game",
+ url: data?.url || "",
+ port: data?.port || 27015,
+ gameId: data?.gameId || "",
+ };
+ break;
+ case "grpc":
+ defaults = {
+ ...base,
+ type: "grpc",
+ url: data?.url || "",
+ port: data?.port || 50051,
+ grpcServiceName: data?.grpcServiceName || "",
+ ignoreTlsErrors: data?.ignoreTlsErrors || false,
+ };
+ break;
+ case "pagespeed":
+ defaults = {
+ ...base,
+ type: "pagespeed",
+ url: data?.url || "",
+ strategy: data?.strategy ?? DefaultPageSpeedStrategy,
+ };
+ break;
+ case "hardware":
+ defaults = {
+ ...base,
+ type: "hardware",
+ url: data?.url || "",
+ secret: data?.secret || "",
+ cpuAlertThreshold: data?.cpuAlertThreshold ?? 100,
+ memoryAlertThreshold: data?.memoryAlertThreshold ?? 100,
+ diskAlertThreshold: data?.diskAlertThreshold ?? 100,
+ tempAlertThreshold: data?.tempAlertThreshold ?? 100,
+ selectedDisks: data?.selectedDisks || [],
+ };
+ break;
+ case "websocket":
+ defaults = {
+ ...base,
+ type: "websocket",
+ url: data?.url || "",
+ ignoreTlsErrors: data?.ignoreTlsErrors || false,
+ };
+ break;
+ case "dns":
+ defaults = {
+ ...base,
+ type: "dns",
+ url: data?.url || "",
+ dnsServer: data?.dnsServer || "",
+ dnsRecordType: data?.dnsRecordType || "A",
+ };
+ break;
+ default:
+ defaults = {
+ ...base,
+ ...getGeoCheckDefaults(data),
+ type: "http",
+ url: "",
+ ignoreTlsErrors: false,
+ useAdvancedMatching: false,
+ matchMethod: "",
+ expectedValue: "",
+ jsonPath: "",
+ };
+ }
+
+ return defaults;
+};
+
export const useMonitorForm = ({
data = null,
defaultType = "http",
}: UseMonitorFormOptions = {}) => {
return useMemo(() => {
const type = data?.type || defaultType;
- const base = getBaseDefaults(data);
-
- let defaults: MonitorFormData;
-
- switch (type) {
- case "http":
- defaults = {
- ...base,
- type: "http",
- url: data?.url || "",
- ignoreTlsErrors: data?.ignoreTlsErrors || false,
- useAdvancedMatching: data?.useAdvancedMatching || false,
- matchMethod: data?.matchMethod || "",
- expectedValue: data?.expectedValue || "",
- jsonPath: data?.jsonPath || "",
- };
- break;
- case "ping":
- defaults = {
- ...base,
- type: "ping",
- url: data?.url || "",
- };
- break;
- case "port":
- defaults = {
- ...base,
- type: "port",
- url: data?.url || "",
- port: data?.port || 80,
- };
- break;
- case "docker":
- defaults = {
- ...base,
- type: "docker",
- url: data?.url || "",
- };
- break;
- case "game":
- defaults = {
- ...base,
- type: "game",
- url: data?.url || "",
- port: data?.port || 27015,
- gameId: data?.gameId || "",
- };
- break;
- case "grpc":
- defaults = {
- ...base,
- type: "grpc",
- url: data?.url || "",
- port: data?.port || 50051,
- grpcServiceName: data?.grpcServiceName || "",
- ignoreTlsErrors: data?.ignoreTlsErrors || false,
- };
- break;
- case "pagespeed":
- defaults = {
- ...base,
- type: "pagespeed",
- url: data?.url || "",
- strategy: data?.strategy ?? DefaultPageSpeedStrategy,
- };
- break;
- case "hardware":
- defaults = {
- ...base,
- type: "hardware",
- url: data?.url || "",
- secret: data?.secret || "",
- cpuAlertThreshold: data?.cpuAlertThreshold ?? 100,
- memoryAlertThreshold: data?.memoryAlertThreshold ?? 100,
- diskAlertThreshold: data?.diskAlertThreshold ?? 100,
- tempAlertThreshold: data?.tempAlertThreshold ?? 100,
- selectedDisks: data?.selectedDisks || [],
- };
- break;
- case "websocket":
- defaults = {
- ...base,
- type: "websocket",
- url: data?.url || "",
- ignoreTlsErrors: data?.ignoreTlsErrors || false,
- };
- break;
- case "dns":
- defaults = {
- ...base,
- type: "dns",
- url: data?.url || "",
- dnsServer: data?.dnsServer || "",
- dnsRecordType: data?.dnsRecordType || "A",
- };
- break;
- default:
- defaults = {
- ...base,
- type: "http",
- url: "",
- ignoreTlsErrors: false,
- useAdvancedMatching: false,
- matchMethod: "",
- expectedValue: "",
- jsonPath: "",
- };
- }
-
- return { schema: monitorSchema, defaults };
+ return { schema: monitorSchema, defaults: getMonitorDefaults(type, data) };
}, [data, defaultType]);
};
diff --git a/client/src/Pages/CreateMonitor/index.tsx b/client/src/Pages/CreateMonitor/index.tsx
index 3aae2e5e1..f34876359 100644
--- a/client/src/Pages/CreateMonitor/index.tsx
+++ b/client/src/Pages/CreateMonitor/index.tsx
@@ -18,7 +18,12 @@ import { Trash2 } from "lucide-react";
import { HeaderDeleteControls } from "@/Components/monitors";
import { GeoContinents } from "@/Types/GeoCheck";
-import { BasePage, ColoredLabel, ConfigBox } from "@/Components/design-elements";
+import {
+ BasePage,
+ ColoredLabel,
+ ConfigBox,
+ StepProgress,
+} from "@/Components/design-elements";
import {
RadioWithDescription,
Button,
@@ -31,7 +36,7 @@ import {
} from "@/Components/inputs";
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
import { useGet, usePost, usePatch, useDelete } from "@/Hooks/UseApi";
-import { useMonitorForm } from "@/Hooks/useMonitorForm";
+import { useMonitorForm, getMonitorDefaults } from "@/Hooks/useMonitorForm";
import {
type Monitor,
type MonitorType,
@@ -41,7 +46,11 @@ import {
} from "@/Types/Monitor";
import type { Notification } from "@/Types/Notification";
import type { Tag } from "@/Types/Tag";
-import type { MonitorFormData } from "@/Validation/monitor";
+import {
+ stepFieldsFor,
+ monitorStepCount,
+ type MonitorFormData,
+} from "@/Validation/monitor";
interface GeneralSettingsConfig {
urlLabel: string;
@@ -249,20 +258,41 @@ const CreateMonitorPage = () => {
resolver: zodResolver(schema),
defaultValues: defaults,
});
- const { control, watch, handleSubmit, clearErrors } = form;
+ const { control, watch, handleSubmit, clearErrors, trigger, reset } = form;
useEffect(() => {
- form.reset(defaults);
- }, [defaults, form]);
+ reset(defaults);
+ }, [defaults, reset]);
+
+ // Multi-step wizard, uptime create only (showTypeSelector). Other flows
+ // keep the flat form, where showStep() is always true.
+ const [currentStep, setCurrentStep] = useState(0);
+ const showStep = (step: number) => !showTypeSelector || currentStep === step;
const watchedType = watch("type") as MonitorType;
-
const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean;
const watchGeoCheckEnabled = watch("geoCheckEnabled") as boolean;
+ // Steps without an advanced section drop it, so the last step is the form's.
+ const totalSteps = monitorStepCount(watchedType);
+
+ const handleNext = async () => {
+ const isValid = await trigger(stepFieldsFor(watchedType, currentStep));
+ if (isValid) {
+ setCurrentStep((step) => step + 1);
+ }
+ };
+ const handleBack = () => setCurrentStep((step) => step - 1);
+
+ // Reset the form when the monitor type changes so stale type-specific fields
+ // can't produce an invalid monitor. Type can only be changed on step 0.
useEffect(() => {
- clearErrors();
- }, [watchedType, clearErrors]);
+ if (showTypeSelector) {
+ reset(getMonitorDefaults(watchedType));
+ } else {
+ clearErrors();
+ }
+ }, [watchedType, showTypeSelector, reset, clearErrors]);
const generalSettingsConfig = useMemo(
() => getGeneralSettingsConfig(watchedType, t),
@@ -332,8 +362,14 @@ const CreateMonitorPage = () => {
refetch={refetchMonitor}
onDelete={handleDeleteClick}
/>
- {/* Monitor Type Selection - only shown for uptime monitors */}
{showTypeSelector && (
+
+ )}
+ {/* Monitor Type Selection - only shown for uptime monitors */}
+ {showTypeSelector && showStep(0) && (
{
/>
)}
-
- ),
- }}
- />
- }
- rightContent={
-
- {/* URL/Host/Container field - not shown for hardware */}
- {generalSettingsConfig.showUrl && (
- (
-
- )}
- />
- )}
-
- {/* Strategy field - only for pagespeed type */}
- {generalSettingsConfig.showStrategy && (
- (
-
- )}
- />
- )}
-
- {/* Port field - only for port and game types */}
- {generalSettingsConfig.showPort && (
- (
- {
- const val = e.target.value;
- field.onChange(val === "" ? 0 : Number(val));
- }}
- type="number"
- fieldLabel={t("pages.createMonitor.form.general.option.port.label")}
- placeholder={t(
- "pages.createMonitor.form.general.option.port.placeholder"
- )}
- fullWidth
- error={!!fieldState.error}
- helperText={fieldState.error?.message ?? ""}
- />
- )}
- />
- )}
-
- {/* Game select - only for game type */}
- {generalSettingsConfig.showGameSelect && (
- (
-
- )}
- />
- )}
-
- {/* gRPC Service Name field - only for grpc type */}
- {generalSettingsConfig.showGrpcServiceName && (
- (
-
- )}
- />
- )}
-
- {/* Secret field - only for hardware type */}
- {generalSettingsConfig.showSecret && (
- (
-
- )}
- />
- )}
- {generalSettingsConfig.showDnsServer && (
- (
-
- )}
- />
- )}
- {generalSettingsConfig.showDnsRecordType && (
- (
-
- )}
- />
- )}
-
- (
-
+ }
+ rightContent={
+
+ {/* URL/Host/Container field - not shown for hardware */}
+ {generalSettingsConfig.showUrl && (
+ (
+
+ )}
/>
)}
- />
-
- }
- />
- (
-
+ }
+ />
+ )}
+
+ {showStep(1) && (
+ (
+
-
-
-
-
-
-
-
-
-
-
- )}
- />
- }
- />
+ error={!!fieldState.error}
+ >
+
+
+
+
+
+
+
+
+
+
+
+ )}
+ />
+ }
+ />
+ )}
{/* Alert Thresholds - only for hardware type */}
- {generalSettingsConfig.showSecret && (
+ {generalSettingsConfig.showSecret && showStep(1) && (
{
/>
)}
-
- (
-
- )}
- />
- (
-
- )}
- />
-
- }
- />
-
- {
- // Map notifications to have 'name' property for Autocomplete
- const notificationOptions = (notifications ?? []).map((n) => ({
- ...n,
- name: n.notificationName,
- }));
- const selectedNotifications = notificationOptions.filter((n) =>
- (field.value ?? []).includes(n.id)
- );
- return (
-
- option.name}
- onChange={(_: unknown, newValue: typeof notificationOptions) => {
- field.onChange(newValue.map((n) => n.id));
- }}
- isOptionEqualToValue={(option, value) => option.id === value.id}
- />
- {selectedNotifications.length > 0 && (
-
- {selectedNotifications.map((notification, index) => (
-
-
- {notification.notificationName}
-
- {
- field.onChange(
- (field.value ?? []).filter(
- (id: string) => id !== notification.id
- )
- );
- }}
- aria-label="Remove notification"
- >
-
-
- {index < selectedNotifications.length - 1 && }
-
- ))}
-
- )}
-
- );
- }}
- />
- }
- />
-
- {
- const tagOptions = tags ?? [];
- const selectedTags = tagOptions.filter((tag) =>
- (field.value ?? []).includes(tag.id)
- );
- return (
-
- option.name}
- onChange={(_: unknown, newValue: typeof tagOptions) => {
- field.onChange(newValue.map((tag) => tag.id));
- }}
- isOptionEqualToValue={(option, value) => option.id === value.id}
- renderOptionContent={(option) => (
-
- )}
- />
- {selectedTags.length > 0 && (
-
- {selectedTags.map((tag, index) => (
-
-
-
- {
- field.onChange(
- (field.value ?? []).filter((id: string) => id !== tag.id)
- );
- }}
- aria-label="Remove tag"
- >
-
-
- {index < selectedTags.length - 1 && }
-
- ))}
-
- )}
-
- );
- }}
- />
- }
- />
-
- {(watchedType === "http" ||
- watchedType === "grpc" ||
- watchedType === "websocket") && (
+ {showStep(1) && (
+ (
+
+ )}
+ />
+ (
+
+ )}
+ />
+
+ }
+ />
+ )}
+
+ {showStep(1) && (
+ (
-
- field.onChange(e.target.checked)}
- />
-
- {t("pages.createMonitor.form.ignoreTls.option.tls.label")}
-
-
- )}
+ render={({ field }) => {
+ // Map notifications to have 'name' property for Autocomplete
+ const notificationOptions = (notifications ?? []).map((n) => ({
+ ...n,
+ name: n.notificationName,
+ }));
+ const selectedNotifications = notificationOptions.filter((n) =>
+ (field.value ?? []).includes(n.id)
+ );
+ return (
+
+ option.name}
+ onChange={(_: unknown, newValue: typeof notificationOptions) => {
+ field.onChange(newValue.map((n) => n.id));
+ }}
+ isOptionEqualToValue={(option, value) => option.id === value.id}
+ />
+ {selectedNotifications.length > 0 && (
+
+ {selectedNotifications.map((notification, index) => (
+
+
+ {notification.notificationName}
+
+ {
+ field.onChange(
+ (field.value ?? []).filter(
+ (id: string) => id !== notification.id
+ )
+ );
+ }}
+ aria-label="Remove notification"
+ >
+
+
+ {index < selectedNotifications.length - 1 && }
+
+ ))}
+
+ )}
+
+ );
+ }}
/>
}
/>
)}
- {watchedType === "http" && (
+ {showStep(1) && (
+ {
+ const tagOptions = tags ?? [];
+ const selectedTags = tagOptions.filter((tag) =>
+ (field.value ?? []).includes(tag.id)
+ );
+ return (
+
+ option.name}
+ onChange={(_: unknown, newValue: typeof tagOptions) => {
+ field.onChange(newValue.map((tag) => tag.id));
+ }}
+ isOptionEqualToValue={(option, value) => option.id === value.id}
+ renderOptionContent={(option) => (
+
+ )}
+ />
+ {selectedTags.length > 0 && (
+
+ {selectedTags.map((tag, index) => (
+
+
+
+ {
+ field.onChange(
+ (field.value ?? []).filter(
+ (id: string) => id !== tag.id
+ )
+ );
+ }}
+ aria-label="Remove tag"
+ >
+
+
+ {index < selectedTags.length - 1 && }
+
+ ))}
+
+ )}
+
+ );
+ }}
+ />
+ }
+ />
+ )}
+
+ {showStep(2) &&
+ (watchedType === "http" ||
+ watchedType === "grpc" ||
+ watchedType === "websocket") && (
+ (
+
+ field.onChange(e.target.checked)}
+ />
+
+ {t("pages.createMonitor.form.ignoreTls.option.tls.label")}
+
+
+ )}
+ />
+ }
+ />
+ )}
+
+ {showStep(2) && watchedType === "http" && (
{
/>
)}
- {supportsGeoCheck(watchedType) && (
+ {showStep(2) && supportsGeoCheck(watchedType) && (
{
-
+ {showTypeSelector && (
+
+ )}
+ {showTypeSelector && currentStep < totalSteps - 1 ? (
+
+ ) : (
+
+ )}