feat(alerting): server-side state+severity filters, ButtonGroup filter UI
Backend: `GET /environments/{envSlug}/alerts` now accepts optional multi-value
`state=…` and `severity=…` query params. Filters are pushed down to
PostgresAlertInstanceRepository, which appends `AND state::text = ANY(?)` /
`AND severity::text = ANY(?)` to the inbox query (null/empty = no filter).
`AlertInstanceRepository.listForInbox` gained a 7-arg overload; the old 5-arg
form is preserved as a default delegate so existing callers (evaluator,
AlertingFullLifecycleIT, PostgresAlertInstanceRepositoryIT) compile unchanged.
`InAppInboxQuery.listInbox` also has a new filtered overload.
UI: InboxPage severity filter migrated from `SegmentedTabs` (single-select,
no color cues) to `ButtonGroup` (multi-select with severity-coloured dots),
matching the topnavbar status-filter pattern. `useAlerts` forwards the
filters as query params and cache-keys on the filter tuple so each combo
is independently cached.
Unit + hook tests updated to the new contract (5 UI tests + 8 Java unit
tests passing). OpenAPI types regenerated from the fresh local backend.
This commit is contained in:
@@ -75,13 +75,31 @@ class InAppInboxQueryTest {
|
||||
.thenReturn(List.of(new RoleSummary(roleId, "OPERATOR", true, "direct")));
|
||||
|
||||
when(instanceRepo.listForInbox(eq(ENV_ID), eq(List.of(groupId.toString())),
|
||||
eq(USER_ID), eq(List.of("OPERATOR")), eq(20)))
|
||||
eq(USER_ID), eq(List.of("OPERATOR")), isNull(), isNull(), eq(20)))
|
||||
.thenReturn(List.of());
|
||||
|
||||
List<AlertInstance> result = query.listInbox(ENV_ID, USER_ID, 20);
|
||||
assertThat(result).isEmpty();
|
||||
verify(instanceRepo).listForInbox(ENV_ID, List.of(groupId.toString()),
|
||||
USER_ID, List.of("OPERATOR"), 20);
|
||||
USER_ID, List.of("OPERATOR"), null, null, 20);
|
||||
}
|
||||
|
||||
@Test
|
||||
void listInbox_forwardsStateAndSeverityFilters() {
|
||||
when(rbacService.getEffectiveGroupsForUser(USER_ID)).thenReturn(List.of());
|
||||
when(rbacService.getEffectiveRolesForUser(USER_ID)).thenReturn(List.of());
|
||||
|
||||
List<com.cameleer.server.core.alerting.AlertState> states =
|
||||
List.of(com.cameleer.server.core.alerting.AlertState.FIRING);
|
||||
List<AlertSeverity> severities = List.of(AlertSeverity.CRITICAL, AlertSeverity.WARNING);
|
||||
|
||||
when(instanceRepo.listForInbox(eq(ENV_ID), eq(List.of()), eq(USER_ID), eq(List.of()),
|
||||
eq(states), eq(severities), eq(25)))
|
||||
.thenReturn(List.of());
|
||||
|
||||
query.listInbox(ENV_ID, USER_ID, states, severities, 25);
|
||||
verify(instanceRepo).listForInbox(ENV_ID, List.of(), USER_ID, List.of(),
|
||||
states, severities, 25);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user