@@ -3,33 +3,54 @@ import React from 'react';
33import type { Store } from '@reduxjs/toolkit' ;
44import type { History } from 'history' ;
55import { Helmet } from 'react-helmet-async' ;
6- import { connect } from 'react-redux' ;
76
87import { componentsRegistry } from '../../components/ComponentsProvider/componentsRegistry' ;
9- import type { RootState } from '../../store ' ;
8+ import { useTypedSelector } from '../../utils/hooks ' ;
109import ReduxTooltip from '../ReduxTooltip/ReduxTooltip' ;
1110import type { YDBEmbeddedUISettings } from '../UserSettings/settings' ;
1211
12+ import { useAppTitle } from './AppTitleContext' ;
1313import ContentWrapper , { Content } from './Content' ;
1414import { NavigationWrapper } from './NavigationWrapper' ;
1515import { Providers } from './Providers' ;
1616
1717import './App.scss' ;
1818
19+ const defaultAppTitle = 'YDB Monitoring' ;
20+
1921export interface AppProps {
2022 store : Store ;
2123 history : History ;
22- singleClusterMode : boolean ;
2324 userSettings ?: YDBEmbeddedUISettings ;
2425 children ?: React . ReactNode ;
26+ appTitle ?: string ;
2527}
2628
27- function App ( { store, history, singleClusterMode , children, userSettings} : AppProps ) {
29+ function App ( { store, history, children, userSettings, appTitle = defaultAppTitle } : AppProps ) {
2830 const ChatPanel = componentsRegistry . get ( 'ChatPanel' ) ;
2931
3032 return (
31- < Providers store = { store } history = { history } >
32- < Helmet defaultTitle = "YDB Monitoring" titleTemplate = "%s — YDB Monitoring" />
33+ < Providers store = { store } history = { history } appTitle = { appTitle } >
34+ < AppContent userSettings = { userSettings } > { children } </ AppContent >
35+ { ChatPanel && < ChatPanel /> }
36+ < ReduxTooltip />
37+ </ Providers >
38+ ) ;
39+ }
40+
41+ function AppContent ( {
42+ userSettings,
43+ children,
44+ } : {
45+ userSettings ?: YDBEmbeddedUISettings ;
46+ children ?: React . ReactNode ;
47+ } ) {
48+ const { appTitle} = useAppTitle ( ) ;
49+ const singleClusterMode = useTypedSelector ( ( state ) => state . singleClusterMode ) ;
50+
51+ return (
52+ < React . Fragment >
53+ < Helmet defaultTitle = { appTitle } titleTemplate = { `%s — ${ appTitle } ` } />
3354 < ContentWrapper >
3455 < NavigationWrapper
3556 singleClusterMode = { singleClusterMode }
@@ -39,16 +60,8 @@ function App({store, history, singleClusterMode, children, userSettings}: AppPro
3960 < div id = "fullscreen-root" > </ div >
4061 </ NavigationWrapper >
4162 </ ContentWrapper >
42- { ChatPanel && < ChatPanel /> }
43- < ReduxTooltip />
44- </ Providers >
63+ </ React . Fragment >
4564 ) ;
4665}
4766
48- function mapStateToProps ( state : RootState ) {
49- return {
50- singleClusterMode : state . singleClusterMode ,
51- } ;
52- }
53-
54- export default connect ( mapStateToProps ) ( App ) ;
67+ export default App ;
0 commit comments