feat(client): split uptime monitor creation into a 3-step wizard

This commit is contained in:
Br0wnHammer committed 2026-05-28 00:21:02 +05:30
1 parent 37dfc67e33
commit 3cce1aa842
2 files changed
+46 -52

No files matched your search

+4 -28
View File
@@ -47,7 +47,7 @@ import {
} from "@/Types/Monitor";
import type { Notification } from "@/Types/Notification";
import type { Tag } from "@/Types/Tag";
import { monitorFieldsByType, type MonitorFormData } from "@/Validation/monitor";
import { stepFieldsFor, type MonitorFormData } from "@/Validation/monitor";
interface GeneralSettingsConfig {
urlLabel: string;
@@ -218,32 +218,6 @@ const getGeneralSettingsConfig = (
const hasAdvancedStep = (type: MonitorType): boolean =>
type === "http" || type === "grpc" || type === "websocket" || supportsGeoCheck(type);
// The wizard step on which each field is validated. Fields not listed default
// to step 0, so a field added to the schema is validated by default rather than
// silently skipped. Step membership is the only thing hardcoded here; the field
// set itself is derived from the schema via `monitorFieldsByType`.
const FIELD_STEP: Record<string, number> = {
interval: 1,
statusWindowSize: 1,
statusWindowThreshold: 1,
notifications: 1,
tags: 1,
ignoreTlsErrors: 2,
useAdvancedMatching: 2,
matchMethod: 2,
expectedValue: 2,
jsonPath: 2,
geoCheckEnabled: 2,
geoCheckLocations: 2,
geoCheckInterval: 2,
};
// Exactly the selected type's fields that belong to the given step.
const stepFieldsFor = (type: MonitorType, step: number): FieldPath<MonitorFormData>[] =>
(monitorFieldsByType[type] ?? []).filter(
(field) => (FIELD_STEP[field] ?? 0) === step
) as FieldPath<MonitorFormData>[];
const CreateMonitorPage = () => {
const theme = useTheme();
const { t } = useTranslation();
@@ -305,7 +279,9 @@ const CreateMonitorPage = () => {
const totalSteps = hasAdvancedStep(watchedType) ? 3 : 2;
const handleNext = async () => {
const isValid = await trigger(stepFieldsFor(watchedType, currentStep));
const isValid = await trigger(
stepFieldsFor(watchedType, currentStep) as FieldPath<MonitorFormData>[]
);
if (isValid) {
setCurrentStep((step) => step + 1);
}