mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 07:59:00 +08:00
fix(ruler): improve the user experience for rule id migration (#7841)
* fix(ruler): improve the user experience for rule id migration * fix(ruler): improve the user experience for rule id migration
This commit is contained in:
parent
b80626f5e2
commit
3648027576
@ -531,6 +531,7 @@ export const oldRoutes = [
|
||||
'/traces-save-views',
|
||||
'/settings/access-tokens',
|
||||
'/messaging-queues',
|
||||
'/alerts/edit',
|
||||
];
|
||||
|
||||
export const oldNewRoutesMapping: Record<string, string> = {
|
||||
@ -541,6 +542,7 @@ export const oldNewRoutesMapping: Record<string, string> = {
|
||||
'/traces-save-views': '/traces/saved-views',
|
||||
'/settings/access-tokens': '/settings/api-keys',
|
||||
'/messaging-queues': '/messaging-queues/overview',
|
||||
'/alerts/edit': '/alerts/overview',
|
||||
};
|
||||
|
||||
export const ROUTES_NOT_TO_BE_OVERRIDEN: string[] = [
|
||||
|
@ -6,7 +6,11 @@ import { Filters } from 'components/AlertDetailsFilters/Filters';
|
||||
import NotFound from 'components/NotFound';
|
||||
import RouteTab from 'components/RouteTab';
|
||||
import Spinner from 'components/Spinner';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { useNotifications } from 'hooks/useNotifications';
|
||||
import { useSafeNavigate } from 'hooks/useSafeNavigate';
|
||||
import useUrlQuery from 'hooks/useUrlQuery';
|
||||
import history from 'lib/history';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -70,6 +74,9 @@ BreadCrumbItem.defaultProps = {
|
||||
function AlertDetails(): JSX.Element {
|
||||
const { pathname } = useLocation();
|
||||
const { routes } = useRouteTabUtils();
|
||||
const urlQuery = useUrlQuery();
|
||||
const { safeNavigate } = useSafeNavigate();
|
||||
const { notifications } = useNotifications();
|
||||
|
||||
const {
|
||||
isLoading,
|
||||
@ -85,6 +92,27 @@ function AlertDetails(): JSX.Element {
|
||||
document.title = alertTitle || document.title;
|
||||
}, [alertDetailsResponse?.payload?.data.alert, isRefetching]);
|
||||
|
||||
useEffect(() => {
|
||||
if (alertDetailsResponse?.payload?.data?.id) {
|
||||
const ruleUUID = alertDetailsResponse.payload.data.id;
|
||||
if (ruleId !== ruleUUID) {
|
||||
urlQuery.set(QueryParams.ruleId, ruleUUID);
|
||||
const generatedUrl = `${window.location.pathname}?${urlQuery}`;
|
||||
notifications.info({
|
||||
message:
|
||||
"We're transitioning alert rule IDs from integers to UUIDs.Both old and new alert links will continue to work after this change - existing notifications using integer IDs will remain functional while new alerts will use the UUID format. Please use the updated link in the URL for future references",
|
||||
});
|
||||
safeNavigate(generatedUrl);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
alertDetailsResponse?.payload?.data.id,
|
||||
notifications,
|
||||
ruleId,
|
||||
safeNavigate,
|
||||
urlQuery,
|
||||
]);
|
||||
|
||||
if (
|
||||
isError ||
|
||||
!isValidRuleId ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user