@@ -3,33 +3,58 @@ 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 ) {
30+ const singleClusterMode = useTypedSelector ( ( state ) => state . singleClusterMode ) ;
2831 const ChatPanel = componentsRegistry . get ( 'ChatPanel' ) ;
2932
3033 return (
31- < Providers store = { store } history = { history } >
32- < Helmet defaultTitle = "YDB Monitoring" titleTemplate = "%s — YDB Monitoring" />
34+ < Providers store = { store } history = { history } appTitle = { appTitle } >
35+ < AppContent singleClusterMode = { singleClusterMode } userSettings = { userSettings } >
36+ { children }
37+ </ AppContent >
38+ { ChatPanel && < ChatPanel /> }
39+ < ReduxTooltip />
40+ </ Providers >
41+ ) ;
42+ }
43+
44+ function AppContent ( {
45+ singleClusterMode,
46+ userSettings,
47+ children,
48+ } : {
49+ singleClusterMode : boolean ;
50+ userSettings ?: YDBEmbeddedUISettings ;
51+ children ?: React . ReactNode ;
52+ } ) {
53+ const { appTitle} = useAppTitle ( ) ;
54+
55+ return (
56+ < React . Fragment >
57+ < Helmet defaultTitle = { appTitle } titleTemplate = { `%s — ${ appTitle } ` } />
3358 < ContentWrapper >
3459 < NavigationWrapper
3560 singleClusterMode = { singleClusterMode }
@@ -39,16 +64,8 @@ function App({store, history, singleClusterMode, children, userSettings}: AppPro
3964 < div id = "fullscreen-root" > </ div >
4065 </ NavigationWrapper >
4166 </ ContentWrapper >
42- { ChatPanel && < ChatPanel /> }
43- < ReduxTooltip />
44- </ Providers >
67+ </ React . Fragment >
4568 ) ;
4669}
4770
48- function mapStateToProps ( state : RootState ) {
49- return {
50- singleClusterMode : state . singleClusterMode ,
51- } ;
52- }
53-
54- export default connect ( mapStateToProps ) ( App ) ;
71+ export default App ;
0 commit comments