Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Split alert history tab section owners

rcourtmanad3275d1f0ad
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 3653ccf246..60f5f36ad1 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -254,11 +254,17 @@ alert-history fetch, persistent filter state, resource-incident panel loading,
and history-clear flow, while the pure analytics model for history-item
projection, trend buckets, group labels, axis ticks, and selected bucket
detail now lives in
-`frontend-modern/src/features/alerts/alertHistoryModel.ts`. Future alert
-history control-flow work should extend the feature hook, while new grouping or
-trend semantics should extend the history model instead of putting data fetch
-or resource-incident state back into
-`frontend-modern/src/features/alerts/tabs/HistoryTab.tsx`.
+`frontend-modern/src/features/alerts/alertHistoryModel.ts`. The tab shell in
+`frontend-modern/src/features/alerts/tabs/HistoryTab.tsx` now composes
+`frontend-modern/src/features/alerts/AlertHistoryFrequencyCard.tsx`,
+`frontend-modern/src/features/alerts/AlertHistoryFiltersCard.tsx`,
+`frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx`,
+`frontend-modern/src/features/alerts/AlertHistoryTableSection.tsx`, and
+`frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx`.
+Future alert-history control-flow work should extend the feature hook, new
+grouping or trend semantics should extend the history model, and render-heavy
+history surfaces should extend those section owners instead of putting fetch,
+resource-incident state, or table rendering back into the shell.
Alert configuration load/save state, notification config reloads, and threshold
override normalization now route through
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 45e16dd0be..ec15d2f9a1 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -515,10 +515,16 @@ Alert history runtime now follows that same pattern. The shell stays in
`frontend-modern/src/features/alerts/useAlertHistoryState.ts` owns history
fetch, persistent filters, resource-incident panel state, and history-clear
behavior, while `frontend-modern/src/features/alerts/alertHistoryModel.ts`
-owns grouped/trend derivation and the bucket/range analytics contract. Future
-alert-history control flow should extend the hook, and pure history analytics
-should extend the model, rather than rebuilding either concern in the tab
-shell.
+owns grouped/trend derivation and the bucket/range analytics contract. The
+render-heavy surfaces now route through
+`frontend-modern/src/features/alerts/AlertHistoryFrequencyCard.tsx`,
+`frontend-modern/src/features/alerts/AlertHistoryFiltersCard.tsx`,
+`frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx`,
+`frontend-modern/src/features/alerts/AlertHistoryTableSection.tsx`, and
+`frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx`.
+Future alert-history control flow should extend the hook, pure history analytics
+should extend the model, and section rendering should extend those owners
+rather than rebuilding any of those concerns in the tab shell.
Top-level settings surfaces must route through `Settings.tsx`,
`SettingsPageShell.tsx`, and
`frontend-modern/src/components/shared/SettingsPanel.tsx` instead of
diff --git a/frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx b/frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx
new file mode 100644
index 0000000000..1209698e8a
--- /dev/null
+++ b/frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx
@@ -0,0 +1,41 @@
+import { Show } from 'solid-js';
+
+import {
+ getAlertAdministrationClearHistoryLabel,
+ getAlertAdministrationSectionDescription,
+ getAlertAdministrationSectionTitle,
+} from '@/utils/alertAdministrationPresentation';
+
+import type { AlertHistoryState } from './useAlertHistoryState';
+
+interface AlertHistoryAdministrationCardProps {
+ state: AlertHistoryState;
+}
+
+export function AlertHistoryAdministrationCard(props: AlertHistoryAdministrationCardProps) {
+ return (
+ <Show when={props.state.alertHistory().length > 0}>
+ <div class="mt-8 border-t border-border pt-6">
+ <div class="rounded-md bg-surface-alt p-4">
+ <div class="flex items-start justify-between">
+ <div>
+ <h4 class="mb-1 text-sm font-medium text-base-content">
+ {getAlertAdministrationSectionTitle()}
+ </h4>
+ <p class="text-xs text-muted">{getAlertAdministrationSectionDescription()}</p>
+ </div>
+ <button
+ type="button"
+ onClick={() => {
+ void props.state.clearAlertHistory();
+ }}
+ class="flex-shrink-0 rounded-md border border-red-300 px-3 py-2 text-xs text-red-600 transition-colors hover:bg-red-50 dark:border-red-600 dark:text-red-400 dark:hover:bg-red-900"
+ >
+ {getAlertAdministrationClearHistoryLabel()}
+ </button>
+ </div>
+ </div>
+ </div>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/features/alerts/AlertHistoryFiltersCard.tsx b/frontend-modern/src/features/alerts/AlertHistoryFiltersCard.tsx
new file mode 100644
index 0000000000..cf5130ac0b
--- /dev/null
+++ b/frontend-modern/src/features/alerts/AlertHistoryFiltersCard.tsx
@@ -0,0 +1,67 @@
+import { Card } from '@/components/shared/Card';
+import { LabeledFilterSelect } from '@/components/shared/FilterToolbar';
+import { PageControls } from '@/components/shared/PageControls';
+import { SearchInput } from '@/components/shared/SearchInput';
+import { getAlertHistorySearchPlaceholder } from '@/utils/alertOverviewPresentation';
+
+import type { AlertHistoryState } from './useAlertHistoryState';
+
+interface AlertHistoryFiltersCardProps {
+ state: AlertHistoryState;
+ isMobile: boolean;
+}
+
+export function AlertHistoryFiltersCard(props: AlertHistoryFiltersCardProps) {
+ return (
+ <Card padding="sm" class="mb-4">
+ <PageControls
+ search={
+ <SearchInput
+ value={props.state.searchTerm}
+ onChange={props.state.setSearchTerm}
+ placeholder={getAlertHistorySearchPlaceholder()}
+ class="w-full"
+ clearOnEscape
+ history={{ storageKey: props.state.STORAGE_KEYS.ALERTS_SEARCH_HISTORY }}
+ />
+ }
+ mobileFilters={{
+ enabled: props.isMobile,
+ onToggle: () => props.state.setFiltersOpen((open) => !open),
+ count: props.state.activeFilterCount(),
+ }}
+ showFilters={!props.isMobile || props.state.filtersOpen()}
+ >
+ <LabeledFilterSelect
+ id="alert-time-filter"
+ label="Period"
+ value={props.state.timeFilter()}
+ onChange={(event) =>
+ props.state.setTimeFilter(event.currentTarget.value as '24h' | '7d' | '30d' | 'all')
+ }
+ selectClass="min-w-[7rem]"
+ >
+ <option value="24h">Last 24h</option>
+ <option value="7d">Last 7d</option>
+ <option value="30d">Last 30d</option>
+ <option value="all">All Time</option>
+ </LabeledFilterSelect>
+ <LabeledFilterSelect
+ id="alert-severity-filter"
+ label="Severity"
+ value={props.state.severityFilter()}
+ onChange={(event) =>
+ props.state.setSeverityFilter(
+ event.currentTarget.value as 'warning' | 'critical' | 'all',
+ )
+ }
+ selectClass="min-w-[7rem]"
+ >
+ <option value="all">All</option>
+ <option value="critical">Critical</option>
+ <option value="warning">Warning</option>
+ </LabeledFilterSelect>
+ </PageControls>
+ </Card>
+ );
+}
diff --git a/frontend-modern/src/features/alerts/AlertHistoryFrequencyCard.tsx b/frontend-modern/src/features/alerts/AlertHistoryFrequencyCard.tsx
new file mode 100644
index 0000000000..d9c70f92a8
--- /dev/null
+++ b/frontend-modern/src/features/alerts/AlertHistoryFrequencyCard.tsx
@@ -0,0 +1,201 @@
+import { createMemo, For, Show } from 'solid-js';
+
+import { Card } from '@/components/shared/Card';
+import { SectionHeader } from '@/components/shared/SectionHeader';
+import { hideTooltip, showTooltip } from '@/components/shared/Tooltip';
+import { getAlertBucketCountLabel } from '@/utils/alertOverviewPresentation';
+import {
+ getAlertFrequencyClearFilterButtonClass,
+ getAlertFrequencySelectionPresentation,
+} from '@/utils/alertFrequencyPresentation';
+import { getAlertSeverityDotClass } from '@/utils/alertSeverityPresentation';
+
+import { MS_PER_HOUR } from './alertHistoryModel';
+import type { AlertHistoryState } from './useAlertHistoryState';
+
+interface AlertHistoryFrequencyCardProps {
+ state: AlertHistoryState;
+}
+
+export function AlertHistoryFrequencyCard(props: AlertHistoryFrequencyCardProps) {
+ const alertFrequencySelectionPresentation = createMemo(() =>
+ getAlertFrequencySelectionPresentation(),
+ );
+
+ return (
+ <Card padding="md">
+ <div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3">
+ <SectionHeader
+ title="Alert frequency"
+ description={<span class="text-xs text-muted">{props.state.alertData().length} alerts</span>}
+ size="sm"
+ class="flex-1"
+ />
+ <div class="flex flex-col items-start gap-2 sm:items-end">
+ <Show when={props.state.selectedBucketDetails()}>
+ {(selection) => (
+ <div class={alertFrequencySelectionPresentation().containerClass}>
+ <span class={alertFrequencySelectionPresentation().labelClass}>Filtered Range</span>
+ <span class="font-mono text-[11px]">{selection().rangeLabel}</span>
+ </div>
+ )}
+ </Show>
+ <div class="flex flex-col items-start gap-1 text-xs text-muted sm:items-end">
+ <div>
+ <span class="font-medium text-muted">Bar size:</span>{' '}
+ {props.state.bucketDurationLabel()}
+ </div>
+ <Show when={props.state.rangeSummary()}>
+ {(summary) => (
+ <div class="flex items-center gap-1 whitespace-nowrap">
+ <span class="font-medium text-muted">Range:</span>
+ <span>{summary().startLabel}</span>
+ <span class="text-muted">→</span>
+ <span>{summary().endLabel}</span>
+ </div>
+ )}
+ </Show>
+ <div class="flex flex-wrap items-center justify-end gap-2">
+ <Show when={props.state.selectedBarIndex() !== null}>
+ <button
+ type="button"
+ onClick={() => props.state.setSelectedBarIndex(null)}
+ class={getAlertFrequencyClearFilterButtonClass()}
+ >
+ Clear filter
+ </button>
+ </Show>
+ <div class="flex items-center gap-2 text-xs text-muted">
+ <span class="flex items-center gap-1">
+ <div class={getAlertSeverityDotClass('warning')}></div>
+ {
+ props.state
+ .alertData()
+ .filter((alert) => alert.severity === 'warning').length
+ }{' '}
+ warnings
+ </span>
+ <span class="flex items-center gap-1">
+ <div class={getAlertSeverityDotClass('critical')}></div>
+ {
+ props.state
+ .alertData()
+ .filter((alert) => alert.severity === 'critical').length
+ }{' '}
+ critical
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="mb-1 text-[10px] text-muted">
+ Showing {props.state.alertTrends().buckets.length} time periods (
+ {props.state.bucketDurationLabel()} each) · Total: {props.state.alertData().length} alerts
+ </div>
+
+ {(() => {
+ const trends = props.state.alertTrends();
+ return (
+ <div class="rounded bg-surface-alt p-1">
+ <div class="flex h-12 items-end gap-1">
+ {trends.buckets.map((value, index) => {
+ const scaledHeight =
+ value > 0 ? Math.min(100, Math.max(20, Math.log(value + 1) * 20)) : 0;
+ const pixelHeight = value > 0 ? Math.max(8, (scaledHeight / 100) * 40) : 0;
+ const isSelected = props.state.selectedBarIndex() === index;
+ const bucketStart = trends.bucketTimes[index];
+ const bucketEnd = bucketStart + trends.bucketSize * MS_PER_HOUR;
+ const bucketRangeLabel = props.state.formatBucketRange(bucketStart, bucketEnd);
+ const bucketDurationText =
+ trends.bucketSize % 24 === 0
+ ? `${trends.bucketSize / 24} day${trends.bucketSize / 24 === 1 ? '' : 's'}`
+ : `${trends.bucketSize} hour${trends.bucketSize === 1 ? '' : 's'}`;
+ const countLabel = getAlertBucketCountLabel(value);
+ const tooltipContent = [
+ countLabel,
+ `${bucketDurationText} period`,
+ bucketRangeLabel,
+ ].join('\n');
+
+ return (
+ <div
+ class="relative flex flex-1 cursor-pointer items-end"
+ role="button"
+ tabIndex={0}
+ aria-pressed={isSelected}
+ aria-label={`${countLabel} between ${bucketRangeLabel}`}
+ onClick={() =>
+ props.state.setSelectedBarIndex(
+ index === props.state.selectedBarIndex() ? null : index,
+ )
+ }
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault();
+ props.state.setSelectedBarIndex(
+ index === props.state.selectedBarIndex() ? null : index,
+ );
+ }
+ }}
+ >
+ <div class="absolute bottom-0 h-1 w-full rounded-full bg-slate-300 opacity-30"></div>
+ <div
+ class="relative w-full rounded-sm transition-all"
+ style={{
+ height: `${pixelHeight}px`,
+ 'background-color':
+ value > 0 ? (isSelected ? '#2563eb' : '#3b82f6') : 'transparent',
+ opacity: isSelected ? '1' : '0.8',
+ 'box-shadow': isSelected ? '0 0 0 2px rgba(37, 99, 235, 0.4)' : 'none',
+ }}
+ title={bucketRangeLabel}
+ onMouseEnter={(event) => {
+ if (value <= 0) {
+ hideTooltip();
+ return;
+ }
+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
+ showTooltip(tooltipContent, rect.left + rect.width / 2, rect.top, {
+ align: 'center',
+ direction: 'up',
+ });
+ }}
+ onMouseLeave={() => hideTooltip()}
+ />
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+ })()}
+
+ <Show when={props.state.axisTicks().length > 0}>
+ <div class="relative mt-3 h-10">
+ <div class="absolute inset-x-0 top-0 h-px bg-surface-hover"></div>
+ <For each={props.state.axisTicks()}>
+ {(tick) => (
+ <div
+ class="pointer-events-none absolute top-0 flex h-full flex-col items-center"
+ style={{ left: `${tick.position * 100}%` }}
+ >
+ <div class="h-3 w-px bg-slate-300"></div>
+ <div
+ class="mt-1 whitespace-nowrap text-[10px] text-muted transform"
+ classList={{
+ '-translate-x-1/2': tick.align === 'center',
+ '-translate-x-full': tick.align === 'end',
+ }}
+ >
+ {tick.label}
+ </div>
+ </div>
+ )}
+ </For>
+ </div>
+ </Show>
+ </Card>
+ );
+}
diff --git a/frontend-modern/src/features/alerts/AlertHistoryTableSection.tsx b/frontend-modern/src/features/alerts/AlertHistoryTableSection.tsx
new file mode 100644
index 0000000000..33a5d5182c
--- /dev/null
+++ b/frontend-modern/src/features/alerts/AlertHistoryTableSection.tsx
@@ -0,0 +1,314 @@
+import { For, Show } from 'solid-js';
+
+import { IncidentTimelinePanel } from '@/components/Alerts/IncidentTimelinePanel';
+import { InvestigateAlertButton } from '@/components/Alerts/InvestigateAlertButton';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import {
+ getAlertHistoryEmptyState,
+ getAlertHistoryLoadingState,
+} from '@/utils/alertOverviewPresentation';
+import {
+ getAlertHistoryResourceTypeBadgeClass,
+ getAlertHistorySourcePresentation,
+} from '@/utils/alertHistoryPresentation';
+import {
+ getAlertHistoryStatusPresentation,
+ getAlertIncidentLevelBadgeClass,
+ getAlertResourceIncidentViewTitle,
+} from '@/utils/alertIncidentPresentation';
+import { getTypeColumnLabel } from '@/utils/typeColumnPresentation';
+
+import type { AlertHistoryState } from './useAlertHistoryState';
+
+interface AlertHistoryTableSectionProps {
+ state: AlertHistoryState;
+ hasAIAlertsFeature: () => boolean;
+ licenseLoading: () => boolean;
+}
+
+export function AlertHistoryTableSection(props: AlertHistoryTableSectionProps) {
+ return (
+ <Show
+ when={props.state.loading()}
+ fallback={
+ <Show
+ when={props.state.alertData().length > 0}
+ fallback={
+ <div class="py-12 text-center text-muted">
+ <p class="text-sm">{getAlertHistoryEmptyState().title}</p>
+ <p class="mt-1 text-xs">{getAlertHistoryEmptyState().description}</p>
+ </div>
+ }
+ >
+ <div class="mb-2 overflow-hidden rounded border border-border">
+ <div class="overflow-x-auto">
+ <Table class="w-full min-w-[max-content] text-[11px] sm:text-sm">
+ <TableHeader>
+ <TableRow class="border-b border-border bg-surface-hover text-muted">
+ <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Timestamp
+ </TableHead>
+ <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Source
+ </TableHead>
+ <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Resource
+ </TableHead>
+ <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ {getTypeColumnLabel()}
+ </TableHead>
+ <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Severity
+ </TableHead>
+ <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Message
+ </TableHead>
+ <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Duration
+ </TableHead>
+ <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Status
+ </TableHead>
+ <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Node
+ </TableHead>
+ <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
+ Actions
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ <For each={props.state.groupedAlerts()}>
+ {(group) => (
+ <>
+ <TableRow class="bg-surface-alt">
+ <TableCell
+ colspan={10}
+ class="py-1.5 pr-3 pl-4 text-[12px] font-semibold sm:text-sm"
+ >
+ <div class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
+ <span class="truncate" title={group.fullLabel}>
+ {group.label}
+ </span>
+ <span class="text-[10px] font-medium text-muted">
+ {(() => {
+ const alertCount = group.alerts.filter(
+ (alert) => alert.source === 'alert',
+ ).length;
+ const aiCount = group.alerts.filter(
+ (alert) => alert.source === 'ai',
+ ).length;
+ const parts = [];
+ if (alertCount > 0) {
+ parts.push(`${alertCount} alert${alertCount === 1 ? '' : 's'}`);
+ }
+ if (aiCount > 0) {
+ parts.push(
+ `${aiCount} patrol insight${aiCount === 1 ? '' : 's'}`,
+ );
+ }
+ return (
+ parts.join(', ') ||
+ `${group.alerts.length} item${group.alerts.length === 1 ? '' : 's'}`
+ );
+ })()}
+ </span>
+ </div>
+ </TableCell>
+ </TableRow>
+
+ <For each={group.alerts}>
+ {(alert) => {
+ const rowKey = props.state.getIncidentRowKey(alert);
+ const historyStatusPresentation = getAlertHistoryStatusPresentation(
+ alert.status,
+ );
+ const sourcePresentation = getAlertHistorySourcePresentation(
+ alert.source,
+ );
+
+ return (
+ <>
+ <TableRow
+ class={`border-b border-border hover:bg-surface-hover ${historyStatusPresentation.rowClassName}`}
+ >
+ <TableCell class="p-1 px-1 font-mono whitespace-nowrap text-muted sm:p-1.5 sm:px-2">
+ {new Date(alert.startTime).toLocaleTimeString('en-US', {
+ hour: '2-digit',
+ minute: '2-digit',
+ })}
+ </TableCell>
+
+ <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
+ <span class={sourcePresentation.className}>
+ {sourcePresentation.label}
+ </span>
+ </TableCell>
+
+ <TableCell class="max-w-[150px] truncate p-1 px-1 font-medium text-base-content sm:p-1.5 sm:px-2">
+ {alert.resourceName}
+ </TableCell>
+
+ <TableCell class="p-1 px-1 sm:p-1.5 sm:px-2">
+ <span class={getAlertHistoryResourceTypeBadgeClass(alert.resourceType)}>
+ {alert.resourceType}
+ </span>
+ </TableCell>
+
+ <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
+ <span class={getAlertIncidentLevelBadgeClass(alert.severity)}>
+ {alert.severity}
+ </span>
+ </TableCell>
+
+ <TableCell
+ class="max-w-[300px] truncate p-1 px-1 text-base-content sm:p-1.5 sm:px-2"
+ title={alert.description}
+ >
+ {alert.description}
+ </TableCell>
+
+ <TableCell class="p-1 px-1 text-center text-muted sm:p-1.5 sm:px-2">
+ {alert.duration}
+ </TableCell>
+
+ <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
+ <span class={historyStatusPresentation.className}>
+ {historyStatusPresentation.label}
+ </span>
+ </TableCell>
+
+ <TableCell class="truncate p-1 px-1 text-muted sm:p-1.5 sm:px-2">
+ {alert.nodeDisplayName || alert.node || '—'}
+ </TableCell>
+
+ <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
+ <div class="flex items-center justify-center gap-1">
+ <Show when={alert.source === 'alert'}>
+ <button
+ type="button"
+ class="rounded-md border border-border px-2 py-1 text-[10px] text-muted hover:bg-surface-hover"
+ onClick={() => {
+ void props.state.toggleIncidentTimeline(
+ rowKey,
+ alert.id,
+ alert.startTime,
+ );
+ }}
+ >
+ {props.state.expandedIncidents().has(rowKey)
+ ? 'Hide'
+ : 'Timeline'}
+ </button>
+ </Show>
+ <Show when={alert.source === 'alert' && alert.resourceId}>
+ <button
+ type="button"
+ class="rounded-md border border-border px-2 py-1 text-[10px] text-muted hover:bg-surface-hover"
+ title={getAlertResourceIncidentViewTitle()}
+ onClick={() => {
+ void props.state.openResourceIncidentPanel(
+ alert.resourceId as string,
+ alert.resourceName,
+ );
+ }}
+ >
+ Resource
+ </button>
+ </Show>
+ <Show
+ when={
+ alert.source === 'alert' &&
+ (alert.status === 'active' ||
+ alert.status === 'acknowledged')
+ }
+ >
+ <InvestigateAlertButton
+ alert={{
+ id: alert.id,
+ type: alert.rawAlertType || alert.title,
+ level: alert.severity as 'warning' | 'critical',
+ resourceId: alert.resourceId || '',
+ resourceName: alert.resourceName,
+ node: alert.node || '',
+ nodeDisplayName: alert.nodeDisplayName,
+ instance: '',
+ message: alert.description || '',
+ value: 0,
+ threshold: 0,
+ startTime: alert.startTime,
+ lastSeen: alert.startTime,
+ acknowledged: alert.status === 'acknowledged',
+ }}
+ resourceType={alert.resourceType}
+ variant="icon"
+ size="sm"
+ licenseLocked={
+ !props.hasAIAlertsFeature() && !props.licenseLoading()
+ }
+ />
+ </Show>
+ </div>
+ </TableCell>
+ </TableRow>
+ <Show when={alert.source === 'alert' && props.state.expandedIncidents().has(rowKey)}>
+ <TableRow class="border-b border-border bg-surface-alt">
+ <TableCell colspan={11} class="p-3">
+ <IncidentTimelinePanel
+ loading={props.state.incidentLoading()[rowKey]}
+ error={props.state.incidentErrors()[rowKey]}
+ timeline={props.state.incidentTimelines()[rowKey]}
+ filters={props.state.historyIncidentEventFilters}
+ setFilters={props.state.setHistoryIncidentEventFilters}
+ filterVariant="compact"
+ eventCardVariant="surface"
+ noteDraft={props.state.incidentNoteDrafts()[rowKey] || ''}
+ onNoteDraftChange={(value) =>
+ props.state.setIncidentNoteDraft(rowKey, value)
+ }
+ noteSaving={props.state.incidentNoteSaving().has(rowKey)}
+ onSaveNote={() => {
+ void props.state.saveIncidentNote(
+ rowKey,
+ alert.id,
+ alert.startTime,
+ );
+ }}
+ onRetry={() => {
+ void props.state.loadIncidentTimeline(
+ rowKey,
+ alert.id,
+ alert.startTime,
+ );
+ }}
+ />
+ </TableCell>
+ </TableRow>
+ </Show>
+ </>
+ );
+ }}
+ </For>
+ </>
+ )}
+ </For>
+ </TableBody>
+ </Table>
+ </div>
+ </div>
+ </Show>
+ }
+ >
+ <div class="py-12 text-center text-muted">
+ <p class="text-sm">{getAlertHistoryLoadingState().text}</p>
+ </div>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx
new file mode 100644
index 0000000000..b17a218092
--- /dev/null
+++ b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx
@@ -0,0 +1,235 @@
+import { For, Show } from 'solid-js';
+
+import { IncidentEventFilters } from '@/components/Alerts/IncidentEventFilters';
+import { IncidentTimelineEventCard } from '@/components/Alerts/IncidentTimelineEventCard';
+import { Card } from '@/components/shared/Card';
+import {
+ getAlertIncidentLevelBadgeClass,
+ getAlertIncidentStatusPresentation,
+ getAlertIncidentTimelineHeadingClass,
+ getAlertIncidentTimelineMetaRowClass,
+ getAlertIncidentTimelineOutputClass,
+ getAlertResourceIncidentAcknowledgedByLabel,
+ getAlertResourceIncidentActivityChipClass,
+ getAlertResourceIncidentActivitySummaryClass,
+ getAlertResourceIncidentCardClass,
+ getAlertResourceIncidentCountLabel,
+ getAlertResourceIncidentEmptyState,
+ getAlertResourceIncidentFilteredEventsEmptyState,
+ getAlertResourceIncidentLoadingState,
+ getAlertResourceIncidentPanelTitle,
+ getAlertResourceIncidentRefreshLabel,
+ getAlertResourceIncidentSummaryRowClass,
+ getAlertResourceIncidentToggleButtonClass,
+ getAlertResourceIncidentToggleLabel,
+ getAlertResourceIncidentTruncatedEventsLabel,
+} from '@/utils/alertIncidentPresentation';
+
+import { filterIncidentEvents, summarizeIncidentEvents } from './types';
+import type { AlertHistoryState } from './useAlertHistoryState';
+
+interface AlertResourceIncidentsPanelProps {
+ state: AlertHistoryState;
+}
+
+export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelProps) {
+ return (
+ <Show when={props.state.resourceIncidentPanel()}>
+ {(selection) => {
+ const resourceId = selection().resourceId;
+ const incidents = () => props.state.resourceIncidents()[resourceId] || [];
+ const isLoading = () => props.state.resourceIncidentLoading()[resourceId];
+
+ return (
+ <Card padding="md">
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
+ <div>
+ <h3 class="text-sm font-semibold text-base-content">
+ {getAlertResourceIncidentPanelTitle()}
+ </h3>
+ <p class="text-xs text-muted">
+ {selection().resourceName}
+ <Show when={incidents().length > 0}>
+ <span> · {getAlertResourceIncidentCountLabel(incidents().length)}</span>
+ </Show>
+ </p>
+ </div>
+ <div class="flex items-center gap-2">
+ <button
+ type="button"
+ class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover disabled:opacity-50"
+ disabled={isLoading()}
+ onClick={() => {
+ void props.state.refreshResourceIncidentPanel();
+ }}
+ >
+ {getAlertResourceIncidentRefreshLabel(isLoading())}
+ </button>
+ <button
+ type="button"
+ class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover"
+ onClick={() => props.state.setResourceIncidentPanel(null)}
+ >
+ Close
+ </button>
+ </div>
+ </div>
+ <Show when={isLoading()}>
+ <p class="mt-2 text-xs text-muted">{getAlertResourceIncidentLoadingState().text}</p>
+ </Show>
+ <Show when={!isLoading()}>
+ <Show when={incidents().length > 0}>
+ <div class="mt-2">
+ <IncidentEventFilters
+ filters={props.state.resourceIncidentEventFilters}
+ setFilters={props.state.setResourceIncidentEventFilters}
+ variant="compact"
+ showQuickSelection
+ />
+ </div>
+ </Show>
+ <Show
+ when={incidents().length > 0}
+ fallback={
+ <p class="mt-2 text-xs text-muted">
+ {getAlertResourceIncidentEmptyState().text}
+ </p>
+ }
+ >
+ <div class="mt-3 space-y-3">
+ <For each={incidents()}>
+ {(incident) => {
+ const statusPresentation = getAlertIncidentStatusPresentation(
+ incident.status,
+ incident.acknowledged,
+ );
+ const isExpanded = props.state.expandedResourceIncidentIds().has(incident.id);
+ const events = incident.events || [];
+ const filteredEvents = filterIncidentEvents(
+ events,
+ props.state.resourceIncidentEventFilters(),
+ );
+ const eventSummary = summarizeIncidentEvents(filteredEvents);
+ const recentEvents =
+ filteredEvents.length > 6
+ ? filteredEvents.slice(filteredEvents.length - 6)
+ : filteredEvents;
+ const lastEvent =
+ filteredEvents.length > 0
+ ? filteredEvents[filteredEvents.length - 1]
+ : undefined;
+ const filteredLabel =
+ filteredEvents.length !== events.length
+ ? `${filteredEvents.length}/${events.length}`
+ : `${events.length}`;
+
+ return (
+ <div class={getAlertResourceIncidentCardClass()}>
+ <div class={getAlertIncidentTimelineMetaRowClass()}>
+ <span class={getAlertIncidentTimelineHeadingClass()}>
+ {incident.alertType}
+ </span>
+ <span class={getAlertIncidentLevelBadgeClass(incident.level)}>
+ {incident.level}
+ </span>
+ <span class={statusPresentation.className}>
+ {statusPresentation.label}
+ </span>
+ <span>opened {new Date(incident.openedAt).toLocaleString()}</span>
+ <Show when={incident.closedAt}>
+ <span>
+ closed {new Date(incident.closedAt as string).toLocaleString()}
+ </span>
+ </Show>
+ </div>
+ <Show when={incident.message}>
+ <p class={getAlertIncidentTimelineOutputClass()}>{incident.message}</p>
+ </Show>
+ <Show when={incident.acknowledged && incident.ackUser}>
+ <p class={getAlertIncidentTimelineOutputClass()}>
+ {getAlertResourceIncidentAcknowledgedByLabel(
+ incident.ackUser ?? '',
+ )}
+ </p>
+ </Show>
+ <Show when={events.length > 0}>
+ <div class={getAlertResourceIncidentSummaryRowClass()}>
+ <Show
+ when={filteredEvents.length > 0}
+ fallback={
+ <span>
+ {getAlertResourceIncidentFilteredEventsEmptyState().text}
+ </span>
+ }
+ >
+ <div class={getAlertResourceIncidentActivitySummaryClass()}>
+ <span class="text-[10px] font-medium uppercase tracking-wide text-muted">
+ Activity
+ </span>
+ <For each={eventSummary}>
+ {(summary) => (
+ <span class={getAlertResourceIncidentActivityChipClass()}>
+ {summary.label} {summary.count}
+ </span>
+ )}
+ </For>
+ <span>
+ {filteredEvents.length !== events.length
+ ? `${filteredEvents.length}/${events.length} events`
+ : `${events.length} event${events.length === 1 ? '' : 's'}`}
+ </span>
+ <Show when={lastEvent}>
+ <span>Latest: {lastEvent?.summary}</span>
+ </Show>
+ </div>
+ </Show>
+ <button
+ type="button"
+ class={getAlertResourceIncidentToggleButtonClass()}
+ onClick={() =>
+ props.state.toggleResourceIncidentDetails(incident.id)
+ }
+ >
+ {getAlertResourceIncidentToggleLabel(isExpanded, filteredLabel)}
+ </button>
+ </div>
+ </Show>
+ <Show when={isExpanded}>
+ <div class="mt-2 space-y-2">
+ <Show
+ when={filteredEvents.length > 0}
+ fallback={
+ <p class="text-[10px] text-muted">
+ {getAlertResourceIncidentFilteredEventsEmptyState().text}
+ </p>
+ }
+ >
+ <For each={recentEvents}>
+ {(event) => (
+ <IncidentTimelineEventCard event={event} variant="alt" />
+ )}
+ </For>
+ <Show when={filteredEvents.length > 0}>
+ <p class="text-[10px] text-muted">
+ {getAlertResourceIncidentTruncatedEventsLabel(
+ recentEvents.length,
+ filteredEvents.length,
+ )}
+ </p>
+ </Show>
+ </Show>
+ </div>
+ </Show>
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ </Show>
+ </Show>
+ </Card>
+ );
+ }}
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx b/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx
index 3f1dd57835..8e7d8fdeb4 100644
--- a/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx
+++ b/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx
@@ -1,74 +1,16 @@
-import { createMemo, For, Show } from 'solid-js';
+import { createSignal, onCleanup, createEffect } from 'solid-js';
+import { useLocation } from '@solidjs/router';
import type { Resource } from '@/types/resource';
import { useWebSocket } from '@/App';
-import { IncidentEventFilters } from '@/components/Alerts/IncidentEventFilters';
-import { IncidentTimelineEventCard } from '@/components/Alerts/IncidentTimelineEventCard';
-import { IncidentTimelinePanel } from '@/components/Alerts/IncidentTimelinePanel';
-import { InvestigateAlertButton } from '@/components/Alerts/InvestigateAlertButton';
-import { Card } from '@/components/shared/Card';
-import { LabeledFilterSelect } from '@/components/shared/FilterToolbar';
-import { PageControls } from '@/components/shared/PageControls';
-import { SearchInput } from '@/components/shared/SearchInput';
-import { SectionHeader } from '@/components/shared/SectionHeader';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
import { useBreakpoint } from '@/hooks/useBreakpoint';
-import { hideTooltip, showTooltip } from '@/components/shared/Tooltip';
-import {
- getAlertAdministrationClearHistoryLabel,
- getAlertAdministrationSectionDescription,
- getAlertAdministrationSectionTitle,
-} from '@/utils/alertAdministrationPresentation';
-import {
- getAlertBucketCountLabel,
- getAlertHistoryEmptyState,
- getAlertHistoryLoadingState,
- getAlertHistorySearchPlaceholder,
-} from '@/utils/alertOverviewPresentation';
-import {
- getAlertFrequencyClearFilterButtonClass,
- getAlertFrequencySelectionPresentation,
-} from '@/utils/alertFrequencyPresentation';
-import {
- getAlertHistoryResourceTypeBadgeClass,
- getAlertHistorySourcePresentation,
-} from '@/utils/alertHistoryPresentation';
-import {
- getAlertHistoryStatusPresentation,
- getAlertIncidentLevelBadgeClass,
- getAlertIncidentStatusPresentation,
- getAlertIncidentTimelineHeadingClass,
- getAlertIncidentTimelineMetaRowClass,
- getAlertIncidentTimelineOutputClass,
- getAlertResourceIncidentAcknowledgedByLabel,
- getAlertResourceIncidentActivityChipClass,
- getAlertResourceIncidentActivitySummaryClass,
- getAlertResourceIncidentCardClass,
- getAlertResourceIncidentCountLabel,
- getAlertResourceIncidentEmptyState,
- getAlertResourceIncidentFilteredEventsEmptyState,
- getAlertResourceIncidentLoadingState,
- getAlertResourceIncidentPanelTitle,
- getAlertResourceIncidentRefreshLabel,
- getAlertResourceIncidentSummaryRowClass,
- getAlertResourceIncidentToggleButtonClass,
- getAlertResourceIncidentToggleLabel,
- getAlertResourceIncidentTruncatedEventsLabel,
- getAlertResourceIncidentViewTitle,
-} from '@/utils/alertIncidentPresentation';
-import { getAlertSeverityDotClass } from '@/utils/alertSeverityPresentation';
-import { getTypeColumnLabel } from '@/utils/typeColumnPresentation';
-import { MS_PER_HOUR } from '../alertHistoryModel';
+import { AlertHistoryAdministrationCard } from '../AlertHistoryAdministrationCard';
+import { AlertHistoryFiltersCard } from '../AlertHistoryFiltersCard';
+import { AlertHistoryFrequencyCard } from '../AlertHistoryFrequencyCard';
+import { AlertHistoryTableSection } from '../AlertHistoryTableSection';
+import { AlertResourceIncidentsPanel } from '../AlertResourceIncidentsPanel';
import { useAlertHistoryState } from '../useAlertHistoryState';
-import { filterIncidentEvents, summarizeIncidentEvents } from '../types';
export interface HistoryTabProps {
hasAIAlertsFeature: () => boolean;
@@ -78,769 +20,65 @@ export interface HistoryTabProps {
}
export function HistoryTab(props: HistoryTabProps) {
+ const location = useLocation();
const { activeAlerts } = useWebSocket();
- const alertFrequencySelectionPresentation = createMemo(() =>
- getAlertFrequencySelectionPresentation(),
- );
const { isMobile } = useBreakpoint();
- const {
- STORAGE_KEYS,
- timeFilter,
- setTimeFilter,
- severityFilter,
- setSeverityFilter,
- searchTerm,
- setSearchTerm,
- alertHistory,
- loading,
- selectedBarIndex,
- setSelectedBarIndex,
- resourceIncidentPanel,
- setResourceIncidentPanel,
- resourceIncidents,
- resourceIncidentLoading,
- expandedResourceIncidentIds,
- resourceIncidentEventFilters,
- setResourceIncidentEventFilters,
- filtersOpen,
- setFiltersOpen,
- activeFilterCount,
- incidentTimelines,
- incidentLoading,
- incidentErrors,
- expandedIncidents,
- incidentNoteDrafts,
- incidentNoteSaving,
- historyIncidentEventFilters,
- setHistoryIncidentEventFilters,
- loadIncidentTimeline,
- toggleIncidentTimeline,
- setIncidentNoteDraft,
- saveIncidentNote,
- openResourceIncidentPanel,
- refreshResourceIncidentPanel,
- toggleResourceIncidentDetails,
- alertData,
- groupedAlerts,
- alertTrends,
- bucketDurationLabel,
- rangeSummary,
- axisTicks,
- selectedBucketDetails,
- formatBucketRange,
- getIncidentRowKey,
- clearAlertHistory,
- } = useAlertHistoryState({
+ let hashScrollRafId: number | undefined;
+ const [lastHashScrolled, setLastHashScrolled] = createSignal<string | null>(null);
+
+ const historyState = useAlertHistoryState({
activeAlerts: () => activeAlerts || {},
getResource: props.getResource,
allResources: props.allResources,
});
- return (
- <div class="space-y-4">
- <Card padding="md">
- <div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3">
- <SectionHeader
- title="Alert frequency"
- description={<span class="text-xs text-muted">{alertData().length} alerts</span>}
- size="sm"
- class="flex-1"
- />
- <div class="flex flex-col items-start gap-2 sm:items-end">
- <Show when={selectedBucketDetails()}>
- {(selection) => (
- <div class={alertFrequencySelectionPresentation().containerClass}>
- <span class={alertFrequencySelectionPresentation().labelClass}>
- Filtered Range
- </span>
- <span class="font-mono text-[11px]">{selection().rangeLabel}</span>
- </div>
- )}
- </Show>
- <div class="flex flex-col items-start gap-1 text-xs text-muted sm:items-end">
- <div>
- <span class="font-medium text-muted">Bar size:</span> {bucketDurationLabel()}
- </div>
- <Show when={rangeSummary()}>
- {(summary) => (
- <div class="flex items-center gap-1 whitespace-nowrap">
- <span class="font-medium text-muted">Range:</span>
- <span>{summary().startLabel}</span>
- <span class="text-muted">→</span>
- <span>{summary().endLabel}</span>
- </div>
- )}
- </Show>
- </div>
- <div class="flex flex-wrap items-center justify-end gap-2">
- <Show when={selectedBarIndex() !== null}>
- <button
- type="button"
- onClick={() => setSelectedBarIndex(null)}
- class={getAlertFrequencyClearFilterButtonClass()}
- >
- Clear filter
- </button>
- </Show>
- <div class="flex items-center gap-2 text-xs text-muted">
- <span class="flex items-center gap-1">
- <div class={getAlertSeverityDotClass('warning')}></div>
- {alertData().filter((alert) => alert.severity === 'warning').length} warnings
- </span>
- <span class="flex items-center gap-1">
- <div class={getAlertSeverityDotClass('critical')}></div>
- {alertData().filter((alert) => alert.severity === 'critical').length} critical
- </span>
- </div>
- </div>
- </div>
- </div>
-
- <div class="mb-1 text-[10px] text-muted">
- Showing {alertTrends().buckets.length} time periods ({bucketDurationLabel()} each) ·
- Total: {alertData().length} alerts
- </div>
-
- {(() => {
- const trends = alertTrends();
- return (
- <div class="rounded bg-surface-alt p-1">
- <div class="flex h-12 items-end gap-1">
- {trends.buckets.map((value, index) => {
- const scaledHeight =
- value > 0 ? Math.min(100, Math.max(20, Math.log(value + 1) * 20)) : 0;
- const pixelHeight = value > 0 ? Math.max(8, (scaledHeight / 100) * 40) : 0;
- const isSelected = selectedBarIndex() === index;
- const bucketStart = trends.bucketTimes[index];
- const bucketEnd = bucketStart + trends.bucketSize * MS_PER_HOUR;
- const bucketRangeLabel = formatBucketRange(bucketStart, bucketEnd);
- const bucketDurationText =
- trends.bucketSize % 24 === 0
- ? `${trends.bucketSize / 24} day${trends.bucketSize / 24 === 1 ? '' : 's'}`
- : `${trends.bucketSize} hour${trends.bucketSize === 1 ? '' : 's'}`;
- const countLabel = getAlertBucketCountLabel(value);
- const tooltipContent = [
- countLabel,
- `${bucketDurationText} period`,
- bucketRangeLabel,
- ].join('\n');
- return (
- <div
- class="relative flex flex-1 cursor-pointer items-end"
- role="button"
- tabIndex={0}
- aria-pressed={isSelected}
- aria-label={`${countLabel} between ${bucketRangeLabel}`}
- onClick={() => setSelectedBarIndex(index === selectedBarIndex() ? null : index)}
- onKeyDown={(event) => {
- if (event.key === 'Enter' || event.key === ' ') {
- event.preventDefault();
- setSelectedBarIndex(index === selectedBarIndex() ? null : index);
- }
- }}
- >
- <div class="absolute bottom-0 h-1 w-full rounded-full bg-slate-300 opacity-30"></div>
- <div
- class="relative w-full rounded-sm transition-all"
- style={{
- height: `${pixelHeight}px`,
- 'background-color':
- value > 0 ? (isSelected ? '#2563eb' : '#3b82f6') : 'transparent',
- opacity: isSelected ? '1' : '0.8',
- 'box-shadow': isSelected ? '0 0 0 2px rgba(37, 99, 235, 0.4)' : 'none',
- }}
- title={bucketRangeLabel}
- onMouseEnter={(event) => {
- if (value <= 0) {
- hideTooltip();
- return;
- }
- const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
- showTooltip(tooltipContent, rect.left + rect.width / 2, rect.top, {
- align: 'center',
- direction: 'up',
- });
- }}
- onMouseLeave={() => hideTooltip()}
- />
- </div>
- );
- })}
- </div>
- </div>
- );
- })()}
-
- <Show when={axisTicks().length > 0}>
- <div class="relative mt-3 h-10">
- <div class="absolute inset-x-0 top-0 h-px bg-surface-hover"></div>
- <For each={axisTicks()}>
- {(tick) => (
- <div
- class="pointer-events-none absolute top-0 flex h-full flex-col items-center"
- style={{ left: `${tick.position * 100}%` }}
- >
- <div class="h-3 w-px bg-slate-300"></div>
- <div
- class="mt-1 whitespace-nowrap text-[10px] text-muted transform"
- classList={{
- '-translate-x-1/2': tick.align === 'center',
- '-translate-x-full': tick.align === 'end',
- }}
- >
- {tick.label}
- </div>
- </div>
- )}
- </For>
- </div>
- </Show>
- </Card>
-
- <Card padding="sm" class="mb-4">
- <PageControls
- search={
- <SearchInput
- value={searchTerm}
- onChange={setSearchTerm}
- placeholder={getAlertHistorySearchPlaceholder()}
- class="w-full"
- clearOnEscape
- history={{ storageKey: STORAGE_KEYS.ALERTS_SEARCH_HISTORY }}
- />
- }
- mobileFilters={{
- enabled: isMobile(),
- onToggle: () => setFiltersOpen((open) => !open),
- count: activeFilterCount(),
- }}
- showFilters={!isMobile() || filtersOpen()}
- >
- <LabeledFilterSelect
- id="alert-time-filter"
- label="Period"
- value={timeFilter()}
- onChange={(event) =>
- setTimeFilter(event.currentTarget.value as '24h' | '7d' | '30d' | 'all')
- }
- selectClass="min-w-[7rem]"
- >
- <option value="24h">Last 24h</option>
- <option value="7d">Last 7d</option>
- <option value="30d">Last 30d</option>
- <option value="all">All Time</option>
- </LabeledFilterSelect>
- <LabeledFilterSelect
- id="alert-severity-filter"
- label="Severity"
- value={severityFilter()}
- onChange={(event) =>
- setSeverityFilter(event.currentTarget.value as 'warning' | 'critical' | 'all')
- }
- selectClass="min-w-[7rem]"
- >
- <option value="all">All</option>
- <option value="critical">Critical</option>
- <option value="warning">Warning</option>
- </LabeledFilterSelect>
- </PageControls>
- </Card>
-
- <Show when={resourceIncidentPanel()}>
- {(selection) => {
- const resourceId = selection().resourceId;
- const incidents = () => resourceIncidents()[resourceId] || [];
- const isLoading = () => resourceIncidentLoading()[resourceId];
- return (
- <Card padding="md">
- <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
- <div>
- <h3 class="text-sm font-semibold text-base-content">
- {getAlertResourceIncidentPanelTitle()}
- </h3>
- <p class="text-xs text-muted">
- {selection().resourceName}
- <Show when={incidents().length > 0}>
- <span>
- {' '}
- · {getAlertResourceIncidentCountLabel(incidents().length)}
- </span>
- </Show>
- </p>
- </div>
- <div class="flex items-center gap-2">
- <button
- type="button"
- class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover disabled:opacity-50"
- disabled={isLoading()}
- onClick={() => {
- void refreshResourceIncidentPanel();
- }}
- >
- {getAlertResourceIncidentRefreshLabel(isLoading())}
- </button>
- <button
- type="button"
- class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover"
- onClick={() => setResourceIncidentPanel(null)}
- >
- Close
- </button>
- </div>
- </div>
- <Show when={isLoading()}>
- <p class="mt-2 text-xs text-muted">{getAlertResourceIncidentLoadingState().text}</p>
- </Show>
- <Show when={!isLoading()}>
- <Show when={incidents().length > 0}>
- <div class="mt-2">
- <IncidentEventFilters
- filters={resourceIncidentEventFilters}
- setFilters={setResourceIncidentEventFilters}
- variant="compact"
- showQuickSelection
- />
- </div>
- </Show>
- <Show
- when={incidents().length > 0}
- fallback={
- <p class="mt-2 text-xs text-muted">
- {getAlertResourceIncidentEmptyState().text}
- </p>
- }
- >
- <div class="mt-3 space-y-3">
- <For each={incidents()}>
- {(incident) => {
- const statusPresentation = getAlertIncidentStatusPresentation(
- incident.status,
- incident.acknowledged,
- );
- const isExpanded = expandedResourceIncidentIds().has(incident.id);
- const events = incident.events || [];
- const filteredEvents = filterIncidentEvents(
- events,
- resourceIncidentEventFilters(),
- );
- const eventSummary = summarizeIncidentEvents(filteredEvents);
- const recentEvents =
- filteredEvents.length > 6
- ? filteredEvents.slice(filteredEvents.length - 6)
- : filteredEvents;
- const lastEvent =
- filteredEvents.length > 0
- ? filteredEvents[filteredEvents.length - 1]
- : undefined;
- const filteredLabel =
- filteredEvents.length !== events.length
- ? `${filteredEvents.length}/${events.length}`
- : `${events.length}`;
- return (
- <div class={getAlertResourceIncidentCardClass()}>
- <div class={getAlertIncidentTimelineMetaRowClass()}>
- <span class={getAlertIncidentTimelineHeadingClass()}>
- {incident.alertType}
- </span>
- <span class={getAlertIncidentLevelBadgeClass(incident.level)}>
- {incident.level}
- </span>
- <span class={statusPresentation.className}>
- {statusPresentation.label}
- </span>
- <span>opened {new Date(incident.openedAt).toLocaleString()}</span>
- <Show when={incident.closedAt}>
- <span>
- closed {new Date(incident.closedAt as string).toLocaleString()}
- </span>
- </Show>
- </div>
- <Show when={incident.message}>
- <p class={getAlertIncidentTimelineOutputClass()}>{incident.message}</p>
- </Show>
- <Show when={incident.acknowledged && incident.ackUser}>
- <p class={getAlertIncidentTimelineOutputClass()}>
- {getAlertResourceIncidentAcknowledgedByLabel(
- incident.ackUser ?? '',
- )}
- </p>
- </Show>
- <Show when={events.length > 0}>
- <div class={getAlertResourceIncidentSummaryRowClass()}>
- <Show
- when={filteredEvents.length > 0}
- fallback={
- <span>
- {getAlertResourceIncidentFilteredEventsEmptyState().text}
- </span>
- }
- >
- <div class={getAlertResourceIncidentActivitySummaryClass()}>
- <span class="text-[10px] font-medium uppercase tracking-wide text-muted">
- Activity
- </span>
- <For each={eventSummary}>
- {(summary) => (
- <span class={getAlertResourceIncidentActivityChipClass()}>
- {summary.label} {summary.count}
- </span>
- )}
- </For>
- <span>
- {filteredEvents.length !== events.length
- ? `${filteredEvents.length}/${events.length} events`
- : `${events.length} event${events.length === 1 ? '' : 's'}`}
- </span>
- <Show when={lastEvent}>
- <span>Latest: {lastEvent?.summary}</span>
- </Show>
- </div>
- </Show>
- <button
- type="button"
- class={getAlertResourceIncidentToggleButtonClass()}
- onClick={() => toggleResourceIncidentDetails(incident.id)}
- >
- {getAlertResourceIncidentToggleLabel(isExpanded, filteredLabel)}
- </button>
- </div>
- </Show>
- <Show when={isExpanded}>
- <div class="mt-2 space-y-2">
- <Show
- when={filteredEvents.length > 0}
- fallback={
- <p class="text-[10px] text-muted">
- {getAlertResourceIncidentFilteredEventsEmptyState().text}
- </p>
- }
- >
- <For each={recentEvents}>
- {(event) => (
- <IncidentTimelineEventCard event={event} variant="alt" />
- )}
- </For>
- <Show when={filteredEvents.length > 0}>
- <p class="text-[10px] text-muted">
- {getAlertResourceIncidentTruncatedEventsLabel(
- recentEvents.length,
- filteredEvents.length,
- )}
- </p>
- </Show>
- </Show>
- </div>
- </Show>
- </div>
- );
- }}
- </For>
- </div>
- </Show>
- </Show>
- </Card>
- );
- }}
- </Show>
-
- <Show
- when={loading()}
- fallback={
- <Show
- when={alertData().length > 0}
- fallback={
- <div class="py-12 text-center text-muted">
- <p class="text-sm">{getAlertHistoryEmptyState().title}</p>
- <p class="mt-1 text-xs">{getAlertHistoryEmptyState().description}</p>
- </div>
- }
- >
- <div class="mb-2 overflow-hidden rounded border border-border">
- <div class="overflow-x-auto">
- <Table class="w-full min-w-[max-content] text-[11px] sm:text-sm">
- <TableHeader>
- <TableRow class="border-b border-border bg-surface-hover text-muted">
- <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Timestamp
- </TableHead>
- <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Source
- </TableHead>
- <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Resource
- </TableHead>
- <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- {getTypeColumnLabel()}
- </TableHead>
- <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Severity
- </TableHead>
- <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Message
- </TableHead>
- <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Duration
- </TableHead>
- <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Status
- </TableHead>
- <TableHead class="p-1 px-1 text-left text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Node
- </TableHead>
- <TableHead class="p-1 px-1 text-center text-[10px] font-medium uppercase tracking-wider sm:p-1.5 sm:px-2 sm:text-xs">
- Actions
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- <For each={groupedAlerts()}>
- {(group) => (
- <>
- <TableRow class="bg-surface-alt">
- <TableCell
- colspan={10}
- class="py-1.5 pr-3 pl-4 text-[12px] font-semibold sm:text-sm"
- >
- <div class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
- <span class="truncate" title={group.fullLabel}>
- {group.label}
- </span>
- <span class="text-[10px] font-medium text-muted">
- {(() => {
- const alertCount = group.alerts.filter(
- (alert) => alert.source === 'alert',
- ).length;
- const aiCount = group.alerts.filter(
- (alert) => alert.source === 'ai',
- ).length;
- const parts = [];
- if (alertCount > 0) {
- parts.push(
- `${alertCount} alert${alertCount === 1 ? '' : 's'}`,
- );
- }
- if (aiCount > 0) {
- parts.push(
- `${aiCount} patrol insight${aiCount === 1 ? '' : 's'}`,
- );
- }
- return (
- parts.join(', ') ||
- `${group.alerts.length} item${group.alerts.length === 1 ? '' : 's'}`
- );
- })()}
- </span>
- </div>
- </TableCell>
- </TableRow>
-
- <For each={group.alerts}>
- {(alert) => {
- const rowKey = getIncidentRowKey(alert);
- const historyStatusPresentation = getAlertHistoryStatusPresentation(
- alert.status,
- );
- const sourcePresentation = getAlertHistorySourcePresentation(
- alert.source,
- );
- return (
- <>
- <TableRow
- class={`border-b border-border hover:bg-surface-hover ${historyStatusPresentation.rowClassName}`}
- >
- <TableCell class="p-1 px-1 font-mono whitespace-nowrap text-muted sm:p-1.5 sm:px-2">
- {new Date(alert.startTime).toLocaleTimeString('en-US', {
- hour: '2-digit',
- minute: '2-digit',
- })}
- </TableCell>
-
- <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
- <span class={sourcePresentation.className}>
- {sourcePresentation.label}
- </span>
- </TableCell>
-
- <TableCell class="max-w-[150px] truncate p-1 px-1 font-medium text-base-content sm:p-1.5 sm:px-2">
- {alert.resourceName}
- </TableCell>
-
- <TableCell class="p-1 px-1 sm:p-1.5 sm:px-2">
- <span class={getAlertHistoryResourceTypeBadgeClass(alert.resourceType)}>
- {alert.resourceType}
- </span>
- </TableCell>
-
- <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
- <span class={getAlertIncidentLevelBadgeClass(alert.severity)}>
- {alert.severity}
- </span>
- </TableCell>
-
- <TableCell
- class="max-w-[300px] truncate p-1 px-1 text-base-content sm:p-1.5 sm:px-2"
- title={alert.description}
- >
- {alert.description}
- </TableCell>
-
- <TableCell class="p-1 px-1 text-center text-muted sm:p-1.5 sm:px-2">
- {alert.duration}
- </TableCell>
-
- <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
- <span class={historyStatusPresentation.className}>
- {historyStatusPresentation.label}
- </span>
- </TableCell>
-
- <TableCell class="truncate p-1 px-1 text-muted sm:p-1.5 sm:px-2">
- {alert.nodeDisplayName || alert.node || '—'}
- </TableCell>
+ const scrollToAlertHash = () => {
+ const hash = location.hash;
+ if (!hash || !hash.startsWith('#alert-')) {
+ setLastHashScrolled(null);
+ return;
+ }
+ if (hash === lastHashScrolled()) {
+ return;
+ }
+ const target = document.getElementById(hash.slice(1));
+ if (!target) {
+ return;
+ }
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
+ setLastHashScrolled(hash);
+ };
+
+ createEffect(() => {
+ location.hash;
+ historyState.filteredAlerts().length;
+ if (hashScrollRafId !== undefined) {
+ cancelAnimationFrame(hashScrollRafId);
+ }
+ hashScrollRafId = requestAnimationFrame(() => {
+ hashScrollRafId = undefined;
+ scrollToAlertHash();
+ });
+ });
- <TableCell class="p-1 px-1 text-center sm:p-1.5 sm:px-2">
- <div class="flex items-center justify-center gap-1">
- <Show when={alert.source === 'alert'}>
- <button
- type="button"
- class="rounded-md border border-border px-2 py-1 text-[10px] text-muted hover:bg-surface-hover"
- onClick={() => {
- void toggleIncidentTimeline(
- rowKey,
- alert.id,
- alert.startTime,
- );
- }}
- >
- {expandedIncidents().has(rowKey) ? 'Hide' : 'Timeline'}
- </button>
- </Show>
- <Show when={alert.source === 'alert' && alert.resourceId}>
- <button
- type="button"
- class="rounded-md border border-border px-2 py-1 text-[10px] text-muted hover:bg-surface-hover"
- title={getAlertResourceIncidentViewTitle()}
- onClick={() => {
- void openResourceIncidentPanel(
- alert.resourceId as string,
- alert.resourceName,
- );
- }}
- >
- Resource
- </button>
- </Show>
- <Show
- when={
- alert.source === 'alert' &&
- (alert.status === 'active' ||
- alert.status === 'acknowledged')
- }
- >
- <InvestigateAlertButton
- alert={{
- id: alert.id,
- type: alert.rawAlertType || alert.title,
- level: alert.severity as 'warning' | 'critical',
- resourceId: alert.resourceId || '',
- resourceName: alert.resourceName,
- node: alert.node || '',
- nodeDisplayName: alert.nodeDisplayName,
- instance: '',
- message: alert.description || '',
- value: 0,
- threshold: 0,
- startTime: alert.startTime,
- lastSeen: alert.startTime,
- acknowledged: alert.status === 'acknowledged',
- }}
- resourceType={alert.resourceType}
- variant="icon"
- size="sm"
- licenseLocked={
- !props.hasAIAlertsFeature() && !props.licenseLoading()
- }
- />
- </Show>
- </div>
- </TableCell>
- </TableRow>
- <Show
- when={
- alert.source === 'alert' && expandedIncidents().has(rowKey)
- }
- >
- <TableRow class="border-b border-border bg-surface-alt">
- <TableCell colspan={11} class="p-3">
- <IncidentTimelinePanel
- loading={incidentLoading()[rowKey]}
- error={incidentErrors()[rowKey]}
- timeline={incidentTimelines()[rowKey]}
- filters={historyIncidentEventFilters}
- setFilters={setHistoryIncidentEventFilters}
- filterVariant="compact"
- eventCardVariant="surface"
- noteDraft={incidentNoteDrafts()[rowKey] || ''}
- onNoteDraftChange={(value) =>
- setIncidentNoteDraft(rowKey, value)
- }
- noteSaving={incidentNoteSaving().has(rowKey)}
- onSaveNote={() => {
- void saveIncidentNote(rowKey, alert.id, alert.startTime);
- }}
- onRetry={() => {
- void loadIncidentTimeline(
- rowKey,
- alert.id,
- alert.startTime,
- );
- }}
- />
- </TableCell>
- </TableRow>
- </Show>
- </>
- );
- }}
- </For>
- </>
- )}
- </For>
- </TableBody>
- </Table>
- </div>
- </div>
- </Show>
- }
- >
- <div class="py-12 text-center text-muted">
- <p class="text-sm">{getAlertHistoryLoadingState().text}</p>
- </div>
- </Show>
+ onCleanup(() => {
+ if (hashScrollRafId !== undefined) {
+ cancelAnimationFrame(hashScrollRafId);
+ hashScrollRafId = undefined;
+ }
+ });
- <Show when={alertHistory().length > 0}>
- <div class="mt-8 border-t border-border pt-6">
- <div class="rounded-md bg-surface-alt p-4">
- <div class="flex items-start justify-between">
- <div>
- <h4 class="mb-1 text-sm font-medium text-base-content">
- {getAlertAdministrationSectionTitle()}
- </h4>
- <p class="text-xs text-muted">{getAlertAdministrationSectionDescription()}</p>
- </div>
- <button
- type="button"
- onClick={() => {
- void clearAlertHistory();
- }}
- class="flex-shrink-0 rounded-md border border-red-300 px-3 py-2 text-xs text-red-600 transition-colors hover:bg-red-50 dark:border-red-600 dark:text-red-400 dark:hover:bg-red-900"
- >
- {getAlertAdministrationClearHistoryLabel()}
- </button>
- </div>
- </div>
- </div>
- </Show>
+ return (
+ <div class="space-y-4">
+ <AlertHistoryFrequencyCard state={historyState} />
+ <AlertHistoryFiltersCard state={historyState} isMobile={isMobile()} />
+ <AlertResourceIncidentsPanel state={historyState} />
+ <AlertHistoryTableSection
+ state={historyState}
+ hasAIAlertsFeature={props.hasAIAlertsFeature}
+ licenseLoading={props.licenseLoading}
+ />
+ <AlertHistoryAdministrationCard state={historyState} />
</div>
);
}
diff --git a/frontend-modern/src/features/alerts/useAlertHistoryState.ts b/frontend-modern/src/features/alerts/useAlertHistoryState.ts
index 1046471e10..bdaf5e05c6 100644
--- a/frontend-modern/src/features/alerts/useAlertHistoryState.ts
+++ b/frontend-modern/src/features/alerts/useAlertHistoryState.ts
@@ -323,3 +323,5 @@ export function useAlertHistoryState(props: UseAlertHistoryStateProps) {
clearAlertHistory,
};
}
+
+export type AlertHistoryState = ReturnType<typeof useAlertHistoryState>;
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index dc83bc51d1..f8251b8d00 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -8,6 +8,11 @@ import alertDestinationsStateSource from '@/features/alerts/useAlertDestinations
import alertDestinationsTabStateSource from '@/features/alerts/useAlertDestinationsTabState.ts?raw';
import alertWebhookDestinationsStateSource from '@/features/alerts/useAlertWebhookDestinationsState.ts?raw';
import alertAcknowledgementStateSource from '@/features/alerts/useAlertAcknowledgementState.ts?raw';
+import alertHistoryAdministrationCardSource from '@/features/alerts/AlertHistoryAdministrationCard.tsx?raw';
+import alertHistoryFiltersCardSource from '@/features/alerts/AlertHistoryFiltersCard.tsx?raw';
+import alertHistoryFrequencyCardSource from '@/features/alerts/AlertHistoryFrequencyCard.tsx?raw';
+import alertHistoryTableSectionSource from '@/features/alerts/AlertHistoryTableSection.tsx?raw';
+import alertResourceIncidentsPanelSource from '@/features/alerts/AlertResourceIncidentsPanel.tsx?raw';
import alertHistoryStateSource from '@/features/alerts/useAlertHistoryState.ts?raw';
import alertHistoryModelSource from '@/features/alerts/alertHistoryModel.ts?raw';
import alertIncidentTimelineStateSource from '@/features/alerts/useAlertIncidentTimelineState.ts?raw';
@@ -257,6 +262,11 @@ describe('tab path helpers', () => {
);
expect(alertsPageSource).not.toContain('function HistoryTab(');
expect(alertHistoryTabSource).toContain('useAlertHistoryState');
+ expect(alertHistoryTabSource).toContain('AlertHistoryFrequencyCard');
+ expect(alertHistoryTabSource).toContain('AlertHistoryFiltersCard');
+ expect(alertHistoryTabSource).toContain('AlertResourceIncidentsPanel');
+ expect(alertHistoryTabSource).toContain('AlertHistoryTableSection');
+ expect(alertHistoryTabSource).toContain('AlertHistoryAdministrationCard');
expect(alertDestinationsTabSource).toContain('useAlertDestinationsTabState');
expect(alertDestinationsTabSource).toContain('AlertDestinationsLoadingState');
expect(alertDestinationsTabSource).toContain('AlertDestinationsLoadErrorCard');
@@ -269,7 +279,6 @@ describe('tab path helpers', () => {
expect(alertDestinationsTabSource).not.toContain('ALERT_DESTINATIONS_EMAIL_PANEL_TITLE');
expect(alertDestinationsTabSource).not.toContain('ALERT_DESTINATIONS_APPRISE_PANEL_TITLE');
expect(alertDestinationsTabSource).not.toContain('getAlertWebhooksSectionTitle');
- expect(alertHistoryTabSource).toContain('IncidentTimelinePanel');
expect(alertHistoryTabSource).not.toContain('useAlertIncidentTimelineState');
expect(alertHistoryTabSource).not.toContain('AlertsAPI.getHistory');
expect(alertHistoryTabSource).not.toContain('AlertsAPI.getIncidentsForResource');
@@ -280,7 +289,25 @@ describe('tab path helpers', () => {
expect(alertHistoryTabSource).not.toContain('const saveIncidentNote = async');
expect(alertHistoryTabSource).not.toContain('usePersistentSignal(');
expect(alertHistoryTabSource).not.toContain("const [searchTerm, setSearchTerm] = createSignal");
+ expect(alertHistoryFrequencyCardSource).toContain('export function AlertHistoryFrequencyCard');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertFrequencySelectionPresentation');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertBucketCountLabel');
+ expect(alertHistoryFiltersCardSource).toContain('export function AlertHistoryFiltersCard');
+ expect(alertHistoryFiltersCardSource).toContain('getAlertHistorySearchPlaceholder');
+ expect(alertResourceIncidentsPanelSource).toContain('export function AlertResourceIncidentsPanel');
+ expect(alertResourceIncidentsPanelSource).toContain('IncidentEventFilters');
+ expect(alertResourceIncidentsPanelSource).toContain('IncidentTimelineEventCard');
+ expect(alertHistoryTableSectionSource).toContain('export function AlertHistoryTableSection');
+ expect(alertHistoryTableSectionSource).toContain('IncidentTimelinePanel');
+ expect(alertHistoryTableSectionSource).toContain('InvestigateAlertButton');
+ expect(alertHistoryAdministrationCardSource).toContain(
+ 'export function AlertHistoryAdministrationCard',
+ );
+ expect(alertHistoryAdministrationCardSource).toContain(
+ 'getAlertAdministrationClearHistoryLabel',
+ );
expect(alertHistoryStateSource).toContain('export function useAlertHistoryState');
+ expect(alertHistoryStateSource).toContain('export type AlertHistoryState');
expect(alertHistoryStateSource).toContain('AlertsAPI.getHistory');
expect(alertHistoryStateSource).toContain('AlertsAPI.getIncidentsForResource');
expect(alertHistoryStateSource).toContain('AlertsAPI.clearHistory');
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 36ee8133fe..d7cb08c0bb 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -332,6 +332,11 @@ import alertDestinationsStateSource from '@/features/alerts/useAlertDestinations
import alertDestinationsTabStateSource from '@/features/alerts/useAlertDestinationsTabState.ts?raw';
import alertWebhookDestinationsStateSource from '@/features/alerts/useAlertWebhookDestinationsState.ts?raw';
import alertAcknowledgementStateSource from '@/features/alerts/useAlertAcknowledgementState.ts?raw';
+import alertHistoryAdministrationCardSource from '@/features/alerts/AlertHistoryAdministrationCard.tsx?raw';
+import alertHistoryFiltersCardSource from '@/features/alerts/AlertHistoryFiltersCard.tsx?raw';
+import alertHistoryFrequencyCardSource from '@/features/alerts/AlertHistoryFrequencyCard.tsx?raw';
+import alertHistoryTableSectionSource from '@/features/alerts/AlertHistoryTableSection.tsx?raw';
+import alertResourceIncidentsPanelSource from '@/features/alerts/AlertResourceIncidentsPanel.tsx?raw';
import alertHistoryStateSource from '@/features/alerts/useAlertHistoryState.ts?raw';
import alertHistoryModelSource from '@/features/alerts/alertHistoryModel.ts?raw';
import alertIncidentTimelineStateSource from '@/features/alerts/useAlertIncidentTimelineState.ts?raw';
@@ -2781,8 +2786,8 @@ describe('frontend resource type boundaries', () => {
'export function getDeployInstallCommandLoadingState',
);
expect(deployStatusPresentationSource).toContain('export const getDeployStatusPresentation');
- expect(alertHistoryTabSource).toContain('getAlertIncidentStatusPresentation');
- expect(alertHistoryTabSource).toContain('getAlertIncidentLevelBadgeClass');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistoryStatusPresentation');
+ expect(alertHistoryTableSectionSource).toContain('getAlertIncidentLevelBadgeClass');
expect(alertsPageSource).toContain(
"import { AlertsConfigurationSurface } from '@/features/alerts/AlertsConfigurationSurface';",
);
@@ -2854,39 +2859,12 @@ describe('frontend resource type boundaries', () => {
expect(alertsPageSource).not.toContain('function HistoryTab(');
expect(alertOverviewTabSource).toContain('useAlertIncidentTimelineState');
expect(alertHistoryTabSource).toContain('useAlertHistoryState');
- expect(alertHistoryTabSource).toContain('getAlertHistoryStatusPresentation');
- expect(alertHistoryTabSource).toContain('getAlertHistorySourcePresentation');
- expect(alertHistoryTabSource).toContain('getAlertHistoryResourceTypeBadgeClass');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentPanelTitle');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentCountLabel');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentLoadingState');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentEmptyState');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentRefreshLabel');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentAcknowledgedByLabel');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentToggleLabel');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentFilteredEventsEmptyState');
- expect(alertHistoryTabSource).toContain('IncidentEventFilters');
- expect(alertHistoryTabSource).toContain('IncidentTimelinePanel');
- expect(alertHistoryTabSource).toContain('getAlertIncidentTimelineMetaRowClass');
- expect(alertHistoryTabSource).toContain('getAlertIncidentTimelineHeadingClass');
- expect(alertHistoryTabSource).toContain('IncidentTimelineEventCard');
- expect(alertHistoryTabSource).not.toContain('getAlertIncidentTimelineEventCardClass');
- expect(alertHistoryTabSource).not.toContain('getAlertIncidentTimelineDetailClass');
- expect(alertHistoryTabSource).not.toContain('getAlertIncidentTimelineCommandClass');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentCardClass');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentSummaryRowClass');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentToggleButtonClass');
- expect(alertHistoryTabSource).toContain('getAlertResourceIncidentTruncatedEventsLabel');
- expect(alertHistoryTabSource).toContain('getAlertBucketCountLabel');
- expect(alertHistoryTabSource).toContain('getAlertHistorySearchPlaceholder');
+ expect(alertHistoryTabSource).toContain('AlertHistoryFrequencyCard');
+ expect(alertHistoryTabSource).toContain('AlertHistoryFiltersCard');
+ expect(alertHistoryTabSource).toContain('AlertResourceIncidentsPanel');
+ expect(alertHistoryTabSource).toContain('AlertHistoryTableSection');
+ expect(alertHistoryTabSource).toContain('AlertHistoryAdministrationCard');
expect(alertsPageSource).toContain('getAlertsPageHeaderMeta');
- expect(alertHistoryTabSource).toContain('getAlertHistoryEmptyState');
- expect(alertHistoryTabSource).toContain('getAlertHistoryLoadingState');
- expect(alertHistoryTabSource).toContain('getAlertAdministrationSectionTitle');
- expect(alertHistoryTabSource).toContain('getAlertAdministrationSectionDescription');
- expect(alertHistoryTabSource).toContain('getAlertAdministrationClearHistoryLabel');
- expect(alertHistoryTabSource).not.toContain('getAlertAdministrationClearHistoryError');
- expect(alertHistoryTabSource).not.toContain('getAlertAdministrationClearHistoryConfirmation');
expect(alertHistoryTabSource).not.toContain('useAlertIncidentTimelineState');
expect(alertHistoryTabSource).not.toContain('AlertsAPI.getHistory');
expect(alertHistoryTabSource).not.toContain('AlertsAPI.getIncidentsForResource');
@@ -2899,10 +2877,36 @@ describe('frontend resource type boundaries', () => {
expect(alertsPageSource).toContain('getAlertActivationFailure');
expect(alertsPageSource).toContain('getAlertDeactivationSuccess');
expect(alertsPageSource).toContain('getAlertDeactivationFailure');
- expect(alertHistoryTabSource).toContain('getAlertFrequencySelectionPresentation');
- expect(alertHistoryTabSource).toContain('getAlertFrequencyClearFilterButtonClass');
- expect(alertHistoryTabSource).toContain('getAlertSeverityDotClass');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertFrequencySelectionPresentation');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertFrequencyClearFilterButtonClass');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertSeverityDotClass');
+ expect(alertHistoryFrequencyCardSource).toContain('getAlertBucketCountLabel');
+ expect(alertHistoryFiltersCardSource).toContain('getAlertHistorySearchPlaceholder');
+ expect(alertResourceIncidentsPanelSource).toContain('IncidentEventFilters');
+ expect(alertResourceIncidentsPanelSource).toContain('IncidentTimelineEventCard');
+ expect(alertResourceIncidentsPanelSource).toContain('getAlertResourceIncidentCardClass');
+ expect(alertResourceIncidentsPanelSource).toContain('getAlertResourceIncidentSummaryRowClass');
+ expect(alertResourceIncidentsPanelSource).toContain('getAlertResourceIncidentToggleButtonClass');
+ expect(alertResourceIncidentsPanelSource).toContain('getAlertResourceIncidentTruncatedEventsLabel');
+ expect(alertResourceIncidentsPanelSource).not.toContain('getAlertIncidentTimelineEventCardClass');
+ expect(alertResourceIncidentsPanelSource).not.toContain('getAlertIncidentTimelineDetailClass');
+ expect(alertResourceIncidentsPanelSource).not.toContain('getAlertIncidentTimelineCommandClass');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistoryStatusPresentation');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistorySourcePresentation');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistoryResourceTypeBadgeClass');
+ expect(alertHistoryTableSectionSource).toContain('IncidentTimelinePanel');
+ expect(alertHistoryTableSectionSource).toContain('InvestigateAlertButton');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistoryEmptyState');
+ expect(alertHistoryTableSectionSource).toContain('getAlertHistoryLoadingState');
+ expect(alertHistoryAdministrationCardSource).toContain('getAlertAdministrationSectionTitle');
+ expect(alertHistoryAdministrationCardSource).toContain(
+ 'getAlertAdministrationSectionDescription',
+ );
+ expect(alertHistoryAdministrationCardSource).toContain(
+ 'getAlertAdministrationClearHistoryLabel',
+ );
expect(alertHistoryStateSource).toContain('export function useAlertHistoryState');
+ expect(alertHistoryStateSource).toContain('export type AlertHistoryState');
expect(alertHistoryStateSource).toContain('AlertsAPI.getHistory');
expect(alertHistoryStateSource).toContain('AlertsAPI.getIncidentsForResource');
expect(alertHistoryStateSource).toContain('AlertsAPI.clearHistory');