@@ -3,7 +3,7 @@ import qs from 'qs';
33import cn from 'bem-cn-lite' ;
44import { Link } from 'react-router-dom' ;
55import { useDispatch , useSelector } from 'react-redux' ;
6- import { useHistory , useLocation } from 'react-router' ;
6+ import { useLocation } from 'react-router' ;
77
88import { Switch , Tabs } from '@yandex-cloud/uikit' ;
99
@@ -34,8 +34,10 @@ import {TenantGeneralTabsIds, TenantTabsGroups} from '../TenantPages';
3434import { GeneralPagesIds , DATABASE_PAGES , TABLE_PAGES , DIR_PAGES } from './DiagnosticsPages' ;
3535//@ts -ignore
3636import { enableAutorefresh , disableAutorefresh } from '../../../store/reducers/schema' ;
37+ import { setTopLevelTab , setDiagnosticsTab } from '../../../store/reducers/tenant' ;
3738
3839import './Diagnostics.scss' ;
40+
3941interface DiagnosticsProps {
4042 type : string ;
4143 additionalTenantInfo ?: any ;
@@ -51,16 +53,17 @@ function Diagnostics(props: DiagnosticsProps) {
5153 currentSchema : currentItem = { } ,
5254 autorefresh,
5355 } = useSelector ( ( state : any ) => state . schema ) ;
56+ const {
57+ diagnosticsTab = GeneralPagesIds . overview ,
58+ } = useSelector ( ( state : any ) => state . tenant ) ;
5459
5560 const location = useLocation ( ) ;
5661
57- const history = useHistory ( ) ;
58-
5962 const queryParams = qs . parse ( location . search , {
6063 ignoreQueryPrefix : true ,
6164 } ) ;
6265
63- const { name : tenantName , generalTab = GeneralPagesIds . overview } = queryParams ;
66+ const { name : tenantName } = queryParams ;
6467
6568 const isDatabase = currentSchemaPath === tenantName ;
6669
@@ -79,22 +82,17 @@ function Diagnostics(props: DiagnosticsProps) {
7982 } , [ props . type ] ) ;
8083
8184 const forwardToDiagnosticTab = ( tab : GeneralPagesIds ) => {
82- history . push (
83- createHref ( routes . tenant , undefined , {
84- ...queryParams ,
85- [ TenantTabsGroups . generalTab ] : tab ,
86- } ) ,
87- ) ;
85+ dispatch ( setDiagnosticsTab ( tab ) ) ;
8886 } ;
8987 const activeTab = useMemo ( ( ) => {
90- if ( pages . find ( ( el ) => el . id === generalTab ) ) {
91- return generalTab ;
88+ if ( pages . find ( ( el ) => el . id === diagnosticsTab ) ) {
89+ return diagnosticsTab ;
9290 } else {
9391 const newPage = pages [ 0 ] . id ;
9492 forwardToDiagnosticTab ( newPage ) ;
9593 return newPage ;
9694 }
97- } , [ pages , generalTab ] ) ;
95+ } , [ pages , diagnosticsTab ] ) ;
9896
9997 const onAutorefreshToggle = ( value : boolean ) => {
10098 if ( value ) {
@@ -105,20 +103,15 @@ function Diagnostics(props: DiagnosticsProps) {
105103 } ;
106104
107105 const forwardToGeneralTab = ( tab : TenantGeneralTabsIds ) => {
108- history . push (
109- createHref ( routes . tenant , undefined , {
110- ...queryParams ,
111- [ TenantTabsGroups . general ] : tab ,
112- } ) ,
113- ) ;
106+ dispatch ( setTopLevelTab ( tab ) ) ;
114107 } ;
115108
116109 const renderTabContent = ( ) => {
117110 const { type} = props ;
118111
119112 const tenantNameString = tenantName as string ;
120113
121- switch ( generalTab ) {
114+ switch ( diagnosticsTab ) {
122115 case GeneralPagesIds . overview : {
123116 return (
124117 < DetailedOverview
0 commit comments