SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: retain the alerts table sorting when editing or discarding the opened alert (#5066)
Vikrant Gupta0d043bf3801f
diff --git a/frontend/src/constants/query.ts b/frontend/src/constants/query.tsindex 3759fb26b6..9b731ca089 100644--- a/frontend/src/constants/query.ts+++ b/frontend/src/constants/query.ts@@ -31,4 +31,5 @@ export enum QueryParams {pagination = 'pagination',relativeTime = 'relativeTime',alertType = 'alertType',+ ruleId = 'ruleId',}diff --git a/frontend/src/container/FormAlertRules/index.tsx b/frontend/src/container/FormAlertRules/index.tsxindex 24edb957aa..3514f6c7ea 100644--- a/frontend/src/container/FormAlertRules/index.tsx+++ b/frontend/src/container/FormAlertRules/index.tsx@@ -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 cacheruleCache.invalidateQueries(['ruleId', ruleId]);+ // eslint-disable-next-line sonarjs/no-identical-functionssetTimeout(() => {- 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 () => {diff --git a/frontend/src/container/ListAlertRules/ListAlert.tsx b/frontend/src/container/ListAlertRules/ListAlert.tsxindex 39465e28a8..37a56ba921 100644--- a/frontend/src/container/ListAlertRules/ListAlert.tsx+++ b/frontend/src/container/ListAlertRules/ListAlert.tsx@@ -117,14 +117,19 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {.refetch().then(() => {const compositeQuery = mapQueryDataFromApi(record.condition.compositeQuery);+ params.set(+ QueryParams.compositeQuery,+ encodeURIComponent(JSON.stringify(compositeQuery)),+ );- history.push(- `${ROUTES.EDIT_ALERTS}?ruleId=${record.id.toString()}&${- 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);};@@ -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') {