mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-31 07:32:01 +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',
|
||||
relativeTime = 'relativeTime',
|
||||
alertType = 'alertType',
|
||||
ruleId = 'ruleId',
|
||||
}
|
||||
|
@ -157,8 +157,12 @@ function FormAlertRules({
|
||||
}, [alertDef, currentQuery?.queryType, queryOptions]);
|
||||
|
||||
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
|
||||
// in state as well as sets additional defaults
|
||||
@ -343,8 +347,13 @@ function FormAlertRules({
|
||||
// invalidate rule in cache
|
||||
ruleCache.invalidateQueries(['ruleId', ruleId]);
|
||||
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
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);
|
||||
} else {
|
||||
notifications.error({
|
||||
@ -360,12 +369,13 @@ function FormAlertRules({
|
||||
}
|
||||
setLoading(false);
|
||||
}, [
|
||||
t,
|
||||
isFormValid,
|
||||
ruleId,
|
||||
ruleCache,
|
||||
memoizedPreparePostData,
|
||||
ruleId,
|
||||
notifications,
|
||||
t,
|
||||
ruleCache,
|
||||
urlQuery,
|
||||
]);
|
||||
|
||||
const onSaveHandler = useCallback(async () => {
|
||||
|
@ -117,14 +117,19 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
|
||||
.refetch()
|
||||
.then(() => {
|
||||
const compositeQuery = mapQueryDataFromApi(record.condition.compositeQuery);
|
||||
|
||||
history.push(
|
||||
`${ROUTES.EDIT_ALERTS}?ruleId=${record.id.toString()}&${
|
||||
QueryParams.compositeQuery
|
||||
}=${encodeURIComponent(JSON.stringify(compositeQuery))}&panelTypes=${
|
||||
record.condition.compositeQuery.panelType
|
||||
}`,
|
||||
params.set(
|
||||
QueryParams.compositeQuery,
|
||||
encodeURIComponent(JSON.stringify(compositeQuery)),
|
||||
);
|
||||
|
||||
params.set(
|
||||
QueryParams.panelTypes,
|
||||
record.condition.compositeQuery.panelType,
|
||||
);
|
||||
|
||||
params.set(QueryParams.ruleId, record.id.toString());
|
||||
|
||||
history.push(`${ROUTES.EDIT_ALERTS}?${params.toString()}`);
|
||||
})
|
||||
.catch(handleError);
|
||||
};
|
||||
@ -151,7 +156,8 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
|
||||
setData(refetchData.payload || []);
|
||||
setTimeout(() => {
|
||||
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);
|
||||
}
|
||||
if (status === 'error') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user