From 9960fd8c368907ba6a3e0baaa4f7d0dccbf2a75a Mon Sep 17 00:00:00 2001
From: hsiegeln <37154749+hsiegeln@users.noreply.github.com>
Date: Wed, 22 Apr 2026 17:48:51 +0200
Subject: [PATCH] =?UTF-8?q?ui(alerts):=20applyFireModeChange=20=E2=80=94?=
=?UTF-8?q?=20clear=20mode-specific=20fields=20on=20toggle?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Prevents stale COUNT_IN_WINDOW threshold/windowSeconds from surviving
PER_EXCHANGE save (would trip the Task 3.3 server-side validator).
Also forces reNotifyMinutes=0 and forDurationSeconds=0 when switching to
PER_EXCHANGE.
Turns green: form-state.test.ts#applyFireModeChange (3 tests).
---
.../condition-forms/ExchangeMatchForm.tsx | 5 +--
ui/src/pages/Alerts/RuleEditor/form-state.ts | 34 ++++++++++++++++++-
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/ui/src/pages/Alerts/RuleEditor/condition-forms/ExchangeMatchForm.tsx b/ui/src/pages/Alerts/RuleEditor/condition-forms/ExchangeMatchForm.tsx
index 2100a8b4..52fd4f29 100644
--- a/ui/src/pages/Alerts/RuleEditor/condition-forms/ExchangeMatchForm.tsx
+++ b/ui/src/pages/Alerts/RuleEditor/condition-forms/ExchangeMatchForm.tsx
@@ -1,6 +1,7 @@
import { FormField, Input, Select } from '@cameleer/design-system';
import type { FormState } from '../form-state';
-import { EXCHANGE_FIRE_MODE_OPTIONS } from '../../enums';
+import { applyFireModeChange } from '../form-state';
+import { EXCHANGE_FIRE_MODE_OPTIONS, type ExchangeFireMode } from '../../enums';
// ExchangeFilter.status is typed as `String` on the backend (no @Schema
// allowableValues yet) so options stay hand-typed. Follow-up: annotate the
@@ -23,7 +24,7 @@ export function ExchangeMatchForm({ form, setForm }: { form: FormState; setForm:
diff --git a/ui/src/pages/Alerts/RuleEditor/form-state.ts b/ui/src/pages/Alerts/RuleEditor/form-state.ts
index 0924a452..8e2879e2 100644
--- a/ui/src/pages/Alerts/RuleEditor/form-state.ts
+++ b/ui/src/pages/Alerts/RuleEditor/form-state.ts
@@ -3,7 +3,7 @@ import type {
AlertRuleResponse,
AlertCondition,
} from '../../../api/queries/alertRules';
-import type { ConditionKind, Severity, TargetKind } from '../enums';
+import type { ConditionKind, ExchangeFireMode, Severity, TargetKind } from '../enums';
export type WizardStep = 'scope' | 'condition' | 'trigger' | 'notify' | 'review';
export const WIZARD_STEPS: WizardStep[] = ['scope', 'condition', 'trigger', 'notify', 'review'];
@@ -137,6 +137,38 @@ export function toRequest(f: FormState): AlertRuleRequest {
} as AlertRuleRequest;
}
+/**
+ * Pure helper for the ExchangeMatchForm's Fire-mode