diff --git a/opencti-platform/opencti-front/src/components/AppThemeProvider.tsx b/opencti-platform/opencti-front/src/components/AppThemeProvider.tsx index 711ec7d2f5be..a7b55a85ebc7 100644 --- a/opencti-platform/opencti-front/src/components/AppThemeProvider.tsx +++ b/opencti-platform/opencti-front/src/components/AppThemeProvider.tsx @@ -5,8 +5,10 @@ import { ThemeOptions } from '@mui/material/styles/createTheme'; import { UserContext, UserContextType } from '../utils/hooks/useAuth'; import themeDark from './ThemeDark'; import themeLight from './ThemeLight'; -import { useDocumentFaviconModifier, useDocumentTitleModifier, useDocumentThemeModifier } from '../utils/hooks/useDocumentModifier'; +import { useDocumentFaviconModifier, useDocumentThemeModifier } from '../utils/hooks/useDocumentModifier'; import { AppThemeProvider_settings$data } from './__generated__/AppThemeProvider_settings.graphql'; +import useConnectedDocumentModifier from '../utils/hooks/useConnectedDocumentModifier'; +import { pascalize } from '../utils/String'; interface AppThemeProviderProps { children: React.ReactNode; @@ -62,8 +64,8 @@ const AppThemeProvider: FunctionComponent = ({ settings, }) => { const { me } = useContext(UserContext); - const platformTitle = settings?.platform_title ?? 'OpenCTI - Cyber Threat Intelligence Platform'; - useDocumentTitleModifier(platformTitle); + const { setTitle } = useConnectedDocumentModifier(); + setTitle(pascalize(window.location.pathname.split('/').at(-1))); useDocumentFaviconModifier(settings?.platform_favicon); // region theming const defaultTheme = settings?.platform_theme ?? null; diff --git a/opencti-platform/opencti-front/src/utils/hooks/useConnectedDocumentModifier.ts b/opencti-platform/opencti-front/src/utils/hooks/useConnectedDocumentModifier.ts index 9d4251a100dc..45b1adb5b713 100644 --- a/opencti-platform/opencti-front/src/utils/hooks/useConnectedDocumentModifier.ts +++ b/opencti-platform/opencti-front/src/utils/hooks/useConnectedDocumentModifier.ts @@ -1,13 +1,14 @@ -import useAuth from './useAuth'; +import { useContext } from 'react'; +import { UserContext, UserContextType } from './useAuth'; const setDocumentTitle = (title: string) => { document.title = title; }; const useConnectedDocumentModifier = () => { - const { settings } = useAuth(); + const { settings } = useContext(UserContext); const setTitle = (title: string) => { - setDocumentTitle(`${title} | ${settings.platform_title}`); + setDocumentTitle(`${title}${!settings ? '' : ` | ${settings.platform_title}`}`); }; return { setTitle }; };