mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 06:00:40 +08:00
fix: handle the edge cases for alerts create form (#4875)
This commit is contained in:
parent
0fc664a387
commit
48e5436167
@ -2,6 +2,7 @@ import { Form, Row } from 'antd';
|
|||||||
import { ENTITY_VERSION_V4 } from 'constants/app';
|
import { ENTITY_VERSION_V4 } from 'constants/app';
|
||||||
import FormAlertRules from 'container/FormAlertRules';
|
import FormAlertRules from 'container/FormAlertRules';
|
||||||
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
|
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
|
||||||
|
import { isEqual } from 'lodash-es';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
||||||
@ -18,9 +19,7 @@ import SelectAlertType from './SelectAlertType';
|
|||||||
|
|
||||||
function CreateRules(): JSX.Element {
|
function CreateRules(): JSX.Element {
|
||||||
const [initValues, setInitValues] = useState<AlertDef | null>(null);
|
const [initValues, setInitValues] = useState<AlertDef | null>(null);
|
||||||
const [alertType, setAlertType] = useState<AlertTypes>(
|
const [alertType, setAlertType] = useState<AlertTypes>();
|
||||||
AlertTypes.METRICS_BASED_ALERT,
|
|
||||||
);
|
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const queryParams = new URLSearchParams(location.search);
|
const queryParams = new URLSearchParams(location.search);
|
||||||
@ -56,10 +55,10 @@ function CreateRules(): JSX.Element {
|
|||||||
}
|
}
|
||||||
const dataSource = compositeQuery?.builder?.queryData[0]?.dataSource;
|
const dataSource = compositeQuery?.builder?.queryData[0]?.dataSource;
|
||||||
|
|
||||||
const alertType = ALERT_TYPE_VS_SOURCE_MAPPING[dataSource];
|
const alertTypeFromQuery = ALERT_TYPE_VS_SOURCE_MAPPING[dataSource];
|
||||||
|
|
||||||
if (alertType) {
|
if (alertTypeFromQuery && !isEqual(alertType, alertTypeFromQuery)) {
|
||||||
onSelectType(alertType);
|
onSelectType(alertTypeFromQuery);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [compositeQuery]);
|
}, [compositeQuery]);
|
||||||
|
@ -176,8 +176,6 @@ export function DashboardProvider({
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(variablesToGetUpdated);
|
|
||||||
const dashboardResponse = useQuery(
|
const dashboardResponse = useQuery(
|
||||||
[REACT_QUERY_KEY.DASHBOARD_BY_ID, isDashboardPage?.params],
|
[REACT_QUERY_KEY.DASHBOARD_BY_ID, isDashboardPage?.params],
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user