mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-31 14:02:01 +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(() => {
|
||||
// Set selectedQueryName based on the length of queryOptions
|
||||
setAlertDef((def) => ({
|
||||
...def,
|
||||
condition: {
|
||||
...def.condition,
|
||||
selectedQueryName:
|
||||
queryOptions.length > 0 ? String(queryOptions[0].value) : undefined,
|
||||
},
|
||||
}));
|
||||
}, [currentQuery?.queryType, queryOptions]);
|
||||
const selectedQueryName = alertDef?.condition?.selectedQueryName;
|
||||
if (
|
||||
!selectedQueryName ||
|
||||
!queryOptions.some((option) => option.value === selectedQueryName)
|
||||
) {
|
||||
setAlertDef((def) => ({
|
||||
...def,
|
||||
condition: {
|
||||
...def.condition,
|
||||
selectedQueryName:
|
||||
queryOptions.length > 0 ? String(queryOptions[0].value) : undefined,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}, [alertDef, currentQuery?.queryType, queryOptions]);
|
||||
|
||||
const onCancelHandler = useCallback(() => {
|
||||
history.replace(ROUTES.LIST_ALL_ALERT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user