mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 10:52:02 +08:00
fix: alert threshold form is resetting to default query option on stage & run (#4876)
* fix: alert threshold form is resetting to default query option on stage & run * fix: alert threshold - added safety check when the queryOption is deleted
This commit is contained in:
parent
1a8f063b4b
commit
1306e99ca8
@ -139,15 +139,21 @@ function FormAlertRules({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Set selectedQueryName based on the length of queryOptions
|
// Set selectedQueryName based on the length of queryOptions
|
||||||
setAlertDef((def) => ({
|
const selectedQueryName = alertDef?.condition?.selectedQueryName;
|
||||||
...def,
|
if (
|
||||||
condition: {
|
!selectedQueryName ||
|
||||||
...def.condition,
|
!queryOptions.some((option) => option.value === selectedQueryName)
|
||||||
selectedQueryName:
|
) {
|
||||||
queryOptions.length > 0 ? String(queryOptions[0].value) : undefined,
|
setAlertDef((def) => ({
|
||||||
},
|
...def,
|
||||||
}));
|
condition: {
|
||||||
}, [currentQuery?.queryType, queryOptions]);
|
...def.condition,
|
||||||
|
selectedQueryName:
|
||||||
|
queryOptions.length > 0 ? String(queryOptions[0].value) : undefined,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, [alertDef, currentQuery?.queryType, queryOptions]);
|
||||||
|
|
||||||
const onCancelHandler = useCallback(() => {
|
const onCancelHandler = useCallback(() => {
|
||||||
history.replace(ROUTES.LIST_ALL_ALERT);
|
history.replace(ROUTES.LIST_ALL_ALERT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user