Ops: Add query param essentials to open Essentials drawer (#93023)

* Add query param essentials to open Essentials drawer

* use query param for keeping the state of the essentials drawer
This commit is contained in:
Sonia Aguilar 2024-09-06 15:55:33 +02:00 committed by GitHub
parent 9b2c2be82d
commit 427af2e7ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,9 +1,10 @@
import { css } from '@emotion/css';
import { useEffect, useState } from 'react';
import { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { GrafanaTheme2 } from '@grafana/data';
import { IconName, Text, useStyles2 } from '@grafana/ui';
import { useURLSearchParams } from 'app/features/alerting/unified/hooks/useURLSearchParams';
import { getFirstCompatibleDataSource } from 'app/features/alerting/unified/utils/datasource';
import { DATASOURCES_ROUTES } from 'app/features/datasources/constants';
@ -58,7 +59,9 @@ export function ConfigureIRM() {
});
}, [dataSourceConfigurationData.dataSourceCompatibleWithAlerting]);
const [essentialsOpen, setEssentialsOpen] = useState(false);
// query param 'essentials' is used to open essentials drawer
const [queryParams, setQueryParams] = useURLSearchParams();
const essentialsOpen = queryParams.get('essentials') === 'open';
const handleActionClick = (configID: number, isDone?: boolean) => {
trackIrmConfigurationTrackerEvent(IRMInteractionNames.ClickDataSources, {
@ -75,7 +78,7 @@ export function ConfigureIRM() {
}
break;
case ConfigurationStepsEnum.ESSENTIALS:
setEssentialsOpen(true);
setQueryParams({ essentials: 'open' });
trackIrmConfigurationTrackerEvent(IRMInteractionNames.OpenEssentials, {
essentialStepsDone: essentialsConfigurationData.stepsDone,
essentialStepsToDo: essentialsConfigurationData.totalStepsToDo,
@ -88,7 +91,7 @@ export function ConfigureIRM() {
};
function onCloseEssentials() {
setEssentialsOpen(false);
setQueryParams({ essentials: undefined });
trackIrmConfigurationTrackerEvent(IRMInteractionNames.CloseEssentials, {
essentialStepsDone: essentialsConfigurationData.stepsDone,
essentialStepsToDo: essentialsConfigurationData.totalStepsToDo,