Skip to content

Commit e1868b3

Browse files
[Bugfix / Incident Management] Set proximal filter to true only when indicated (#225461)
Resolves #225460 Addresses an issue where the related alerts by timestamp filter is applied without user request https://github.com/user-attachments/assets/b911295e-0748-4a8d-a365-f2af06855d72
1 parent 7d20301 commit e1868b3

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

x-pack/solutions/observability/plugins/observability/public/pages/alert_details/alert_details.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { css } from '@emotion/react';
3737
import { omit } from 'lodash';
3838
import { usePageReady } from '@kbn/ebt-tools';
3939
import { RelatedAlerts } from './components/related_alerts/related_alerts';
40-
import { AlertDetailsSource } from './types';
40+
import { AlertDetailsSource, TAB_IDS, TabId } from './types';
4141
import { SourceBar } from './components';
4242
import { InvestigationGuide } from './components/investigation_guide';
4343
import { StatusBar } from './components/status_bar';
@@ -77,16 +77,6 @@ export const LOG_DOCUMENT_COUNT_RULE_TYPE_ID = 'logs.alert.document.count';
7777
export const METRIC_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.threshold';
7878
export const METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.inventory.threshold';
7979

80-
const TAB_IDS = [
81-
'overview',
82-
'metadata',
83-
'related_alerts',
84-
'investigation_guide',
85-
'related_dashboards',
86-
] as const;
87-
88-
type TabId = (typeof TAB_IDS)[number];
89-
9080
const isTabId = (value: string): value is TabId => {
9181
return Object.values<string>(TAB_IDS).includes(value);
9282
};
@@ -137,13 +127,11 @@ export function AlertDetails() {
137127
const [sources, setSources] = useState<AlertDetailsSource[]>();
138128
const [activeTabId, setActiveTabId] = useState<TabId>();
139129

140-
const handleSetTabId = async (tabId: TabId) => {
130+
const handleSetTabId = async (tabId: TabId, newUrlState?: Record<string, string>) => {
141131
setActiveTabId(tabId);
142132

143-
if (tabId === 'related_alerts') {
144-
setUrlTabId(tabId, true, {
145-
filterProximal: 'true',
146-
});
133+
if (newUrlState) {
134+
setUrlTabId(tabId, true, newUrlState);
147135
} else {
148136
setUrlTabId(tabId, true);
149137
}
@@ -199,7 +187,9 @@ export function AlertDetails() {
199187
}, []);
200188

201189
const showRelatedAlertsFromCallout = () => {
202-
handleSetTabId('related_alerts');
190+
handleSetTabId('related_alerts', {
191+
filterProximal: 'true',
192+
});
203193
};
204194

205195
usePageReady({

x-pack/solutions/observability/plugins/observability/public/pages/alert_details/hooks/use_tab_id.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import { useHistory, useLocation } from 'react-router-dom';
9+
import { TabId } from '../types';
910

1011
const ALERT_DETAILS_TAB_URL_STORAGE_KEY = 'tabId';
1112

@@ -19,7 +20,7 @@ export const useTabId = () => {
1920
};
2021

2122
const setUrlTabId = (
22-
tabId: string,
23+
tabId: TabId,
2324
overrideSearchState?: boolean,
2425
newSearchState?: Record<string, string>
2526
) => {

x-pack/solutions/observability/plugins/observability/public/pages/alert_details/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ export interface AlertDetailsSource {
1515
export interface AlertDetailsAppSectionProps {
1616
setSources: React.Dispatch<React.SetStateAction<AlertDetailsSource[] | undefined>>;
1717
}
18+
19+
export const TAB_IDS = [
20+
'overview',
21+
'metadata',
22+
'related_alerts',
23+
'investigation_guide',
24+
'related_dashboards',
25+
] as const;
26+
27+
export type TabId = (typeof TAB_IDS)[number];

0 commit comments

Comments
 (0)