mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 04:11:59 +08:00
fix: retain the alerts table sorting when editing or discarding the opened alert (#5066)
This commit is contained in:
parent
3b599ea41a
commit
0d043bf380
@ -31,4 +31,5 @@ export enum QueryParams {
|
|||||||
pagination = 'pagination',
|
pagination = 'pagination',
|
||||||
relativeTime = 'relativeTime',
|
relativeTime = 'relativeTime',
|
||||||
alertType = 'alertType',
|
alertType = 'alertType',
|
||||||
|
ruleId = 'ruleId',
|
||||||
}
|
}
|
||||||
|
@ -157,8 +157,12 @@ function FormAlertRules({
|
|||||||
}, [alertDef, currentQuery?.queryType, queryOptions]);
|
}, [alertDef, currentQuery?.queryType, queryOptions]);
|
||||||
|
|
||||||
const onCancelHandler = useCallback(() => {
|
const onCancelHandler = useCallback(() => {
|
||||||
history.replace(ROUTES.LIST_ALL_ALERT);
|
urlQuery.delete(QueryParams.compositeQuery);
|
||||||
}, []);
|
urlQuery.delete(QueryParams.panelTypes);
|
||||||
|
urlQuery.delete(QueryParams.ruleId);
|
||||||
|
urlQuery.delete(QueryParams.relativeTime);
|
||||||
|
history.replace(`${ROUTES.LIST_ALL_ALERT}?${urlQuery.toString()}`);
|
||||||
|
}, [urlQuery]);
|
||||||
|
|
||||||
// onQueryCategoryChange handles changes to query category
|
// onQueryCategoryChange handles changes to query category
|
||||||
// in state as well as sets additional defaults
|
// in state as well as sets additional defaults
|
||||||
@ -343,8 +347,13 @@ function FormAlertRules({
|
|||||||
// invalidate rule in cache
|
// invalidate rule in cache
|
||||||
ruleCache.invalidateQueries(['ruleId', ruleId]);
|
ruleCache.invalidateQueries(['ruleId', ruleId]);
|
||||||
|
|
||||||
|
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
history.replace(ROUTES.LIST_ALL_ALERT);
|
urlQuery.delete(QueryParams.compositeQuery);
|
||||||
|
urlQuery.delete(QueryParams.panelTypes);
|
||||||
|
urlQuery.delete(QueryParams.ruleId);
|
||||||
|
urlQuery.delete(QueryParams.relativeTime);
|
||||||
|
history.replace(`${ROUTES.LIST_ALL_ALERT}?${urlQuery.toString()}`);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
} else {
|
||||||
notifications.error({
|
notifications.error({
|
||||||
@ -360,12 +369,13 @@ function FormAlertRules({
|
|||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [
|
}, [
|
||||||
t,
|
|
||||||
isFormValid,
|
isFormValid,
|
||||||
ruleId,
|
|
||||||
ruleCache,
|
|
||||||
memoizedPreparePostData,
|
memoizedPreparePostData,
|
||||||
|
ruleId,
|
||||||
notifications,
|
notifications,
|
||||||
|
t,
|
||||||
|
ruleCache,
|
||||||
|
urlQuery,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onSaveHandler = useCallback(async () => {
|
const onSaveHandler = useCallback(async () => {
|
||||||
|
@ -117,14 +117,19 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
|
|||||||
.refetch()
|
.refetch()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const compositeQuery = mapQueryDataFromApi(record.condition.compositeQuery);
|
const compositeQuery = mapQueryDataFromApi(record.condition.compositeQuery);
|
||||||
|
params.set(
|
||||||
history.push(
|
QueryParams.compositeQuery,
|
||||||
`${ROUTES.EDIT_ALERTS}?ruleId=${record.id.toString()}&${
|
encodeURIComponent(JSON.stringify(compositeQuery)),
|
||||||
QueryParams.compositeQuery
|
|
||||||
}=${encodeURIComponent(JSON.stringify(compositeQuery))}&panelTypes=${
|
|
||||||
record.condition.compositeQuery.panelType
|
|
||||||
}`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
params.set(
|
||||||
|
QueryParams.panelTypes,
|
||||||
|
record.condition.compositeQuery.panelType,
|
||||||
|
);
|
||||||
|
|
||||||
|
params.set(QueryParams.ruleId, record.id.toString());
|
||||||
|
|
||||||
|
history.push(`${ROUTES.EDIT_ALERTS}?${params.toString()}`);
|
||||||
})
|
})
|
||||||
.catch(handleError);
|
.catch(handleError);
|
||||||
};
|
};
|
||||||
@ -151,7 +156,8 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
|
|||||||
setData(refetchData.payload || []);
|
setData(refetchData.payload || []);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const clonedAlert = refetchData.payload[refetchData.payload.length - 1];
|
const clonedAlert = refetchData.payload[refetchData.payload.length - 1];
|
||||||
history.push(`${ROUTES.EDIT_ALERTS}?ruleId=${clonedAlert.id}`);
|
params.set(QueryParams.ruleId, String(clonedAlert.id));
|
||||||
|
history.push(`${ROUTES.EDIT_ALERTS}?${params.toString()}`);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
if (status === 'error') {
|
if (status === 'error') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user