mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Observabililty] [Alert details] Fix active tab when opening new alert from Related alerts tab (#224287)
Fixes tab selection issue when user opens alert details page from "Related alerts" tab. In this case, "Overview" tab should be selected by default. In other cases, tab Id passed from URL should be used otherwise default to "Overview".
This commit is contained in:
parent
fd4e551340
commit
4553774d5a
1 changed files with 5 additions and 6 deletions
|
@ -133,11 +133,7 @@ export function AlertDetails() {
|
|||
const [alertStatus, setAlertStatus] = useState<AlertStatus>();
|
||||
const { euiTheme } = useEuiTheme();
|
||||
const [sources, setSources] = useState<AlertDetailsSource[]>();
|
||||
const [activeTabId, setActiveTabId] = useState<TabId>(() => {
|
||||
const searchParams = new URLSearchParams(search);
|
||||
const urlTabId = searchParams.get(ALERT_DETAILS_TAB_URL_STORAGE_KEY);
|
||||
return urlTabId && isTabId(urlTabId) ? urlTabId : 'overview';
|
||||
});
|
||||
const [activeTabId, setActiveTabId] = useState<TabId>();
|
||||
const handleSetTabId = async (tabId: TabId) => {
|
||||
setActiveTabId(tabId);
|
||||
|
||||
|
@ -174,8 +170,11 @@ export function AlertDetails() {
|
|||
if (alertDetail) {
|
||||
setRuleTypeModel(ruleTypeRegistry.get(alertDetail?.formatted.fields[ALERT_RULE_TYPE_ID]!));
|
||||
setAlertStatus(alertDetail?.formatted?.fields[ALERT_STATUS] as AlertStatus);
|
||||
const searchParams = new URLSearchParams(search);
|
||||
const urlTabId = searchParams.get(ALERT_DETAILS_TAB_URL_STORAGE_KEY);
|
||||
setActiveTabId(urlTabId && isTabId(urlTabId) ? urlTabId : 'overview');
|
||||
}
|
||||
}, [alertDetail, ruleTypeRegistry]);
|
||||
}, [alertDetail, ruleTypeRegistry, search]);
|
||||
|
||||
useBreadcrumbs(
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue