diff --git a/frontend/src/pages/AlertDetails/AlertDetails.tsx b/frontend/src/pages/AlertDetails/AlertDetails.tsx index 5ee95dfce2..29bb8df2f9 100644 --- a/frontend/src/pages/AlertDetails/AlertDetails.tsx +++ b/frontend/src/pages/AlertDetails/AlertDetails.tsx @@ -8,7 +8,7 @@ import RouteTab from 'components/RouteTab'; import Spinner from 'components/Spinner'; import ROUTES from 'constants/routes'; import history from 'lib/history'; -import { useMemo } from 'react'; +import { useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation } from 'react-router-dom'; @@ -80,6 +80,11 @@ function AlertDetails(): JSX.Element { alertDetailsResponse, } = useGetAlertRuleDetails(); + useEffect(() => { + const alertTitle = alertDetailsResponse?.payload?.data.alert; + document.title = alertTitle || document.title; + }, [alertDetailsResponse?.payload?.data.alert, isRefetching]); + if ( isError || !isValidRuleId || diff --git a/frontend/src/pages/NewDashboard/DashboardPage.tsx b/frontend/src/pages/NewDashboard/DashboardPage.tsx index 7da194aad0..befefa88eb 100644 --- a/frontend/src/pages/NewDashboard/DashboardPage.tsx +++ b/frontend/src/pages/NewDashboard/DashboardPage.tsx @@ -4,6 +4,7 @@ import NotFound from 'components/NotFound'; import Spinner from 'components/Spinner'; import NewDashboard from 'container/NewDashboard'; import { useDashboard } from 'providers/Dashboard/Dashboard'; +import { useEffect } from 'react'; import { ErrorType } from 'types/common'; function DashboardPage(): JSX.Element { @@ -17,6 +18,11 @@ function DashboardPage(): JSX.Element { (dashboardResponse?.error as AxiosError)?.response?.data?.errorType : 'Something went wrong'; + useEffect(() => { + const dashboardTitle = dashboardResponse.data?.data.title; + document.title = dashboardTitle || document.title; + }, [dashboardResponse.data?.data.title, isFetching]); + if (isError && !isFetching && errorMessage === ErrorType.NotFound) { return ; }