11import React , { ReactNode , useEffect , useReducer } from 'react' ;
22import { useDispatch } from 'react-redux' ;
3- import { useHistory , useLocation } from 'react-router' ;
3+ import { useLocation } from 'react-router' ;
44import { Link } from 'react-router-dom' ;
55import qs from 'qs' ;
66import cn from 'bem-cn-lite' ;
@@ -31,19 +31,18 @@ import {
3131 DEFAULT_SIZE_TENANT_SUMMARY_KEY ,
3232} from '../../../utils/constants' ;
3333import { setShowPreview } from '../../../store/reducers/schema/schema' ;
34- import { setQueryTab , setTenantPage } from '../../../store/reducers/tenant/tenant' ;
35- import { TENANT_PAGES_IDS , TENANT_QUERY_TABS_ID } from '../../../store/reducers/tenant/constants' ;
34+ import { setQueryTab , setSummaryTab , setTenantPage } from '../../../store/reducers/tenant/tenant' ;
35+ import {
36+ TENANT_PAGES_IDS ,
37+ TENANT_QUERY_TABS_ID ,
38+ TENANT_SUMMARY_TABS_IDS ,
39+ } from '../../../store/reducers/tenant/constants' ;
3640
3741import { SchemaTree } from '../Schema/SchemaTree/SchemaTree' ;
3842import { SchemaViewer } from '../Schema/SchemaViewer/SchemaViewer' ;
3943import { Acl } from '../Acl/Acl' ;
4044
41- import {
42- TenantInfoTabsIds ,
43- TenantTabsGroups ,
44- TENANT_INFO_TABS ,
45- TENANT_SCHEMA_TAB ,
46- } from '../TenantPages' ;
45+ import { TenantTabsGroups , TENANT_INFO_TABS , TENANT_SCHEMA_TAB } from '../TenantPages' ;
4746import {
4847 PaneVisibilityActionTypes ,
4948 paneVisibilityToggleReducerCreator ,
@@ -115,16 +114,17 @@ export function ObjectSummary({
115114 currentSchema : currentItem = { } ,
116115 loading : loadingSchema ,
117116 } = useTypedSelector ( ( state ) => state . schema ) ;
117+ const { summaryTab = TENANT_SUMMARY_TABS_IDS . overview } = useTypedSelector (
118+ ( state ) => state . tenant ,
119+ ) ;
118120
119121 const location = useLocation ( ) ;
120122
121- const history = useHistory ( ) ;
122-
123123 const queryParams = qs . parse ( location . search , {
124124 ignoreQueryPrefix : true ,
125125 } ) ;
126126
127- const { name : tenantName , info : infoTab } = queryParams ;
127+ const { name : tenantName } = queryParams ;
128128
129129 const pathData = tenantName ? data [ tenantName . toString ( ) ] ?. PathDescription ?. Self : undefined ;
130130 const currentObjectData = currentSchemaPath ? data [ currentSchemaPath ] : undefined ;
@@ -143,13 +143,10 @@ export function ObjectSummary({
143143 useEffect ( ( ) => {
144144 const isTable = isTableType ( type ) ;
145145
146- if ( type && ! isTable && ! TENANT_INFO_TABS . find ( ( el ) => el . id === infoTab ) ) {
147- history . push ( {
148- pathname : location . pathname ,
149- search : qs . stringify ( { ...queryParams , info : TenantInfoTabsIds . overview } ) ,
150- } ) ;
146+ if ( type && ! isTable && ! TENANT_INFO_TABS . find ( ( el ) => el . id === summaryTab ) ) {
147+ dispatch ( setSummaryTab ( TENANT_SUMMARY_TABS_IDS . overview ) ) ;
151148 }
152- } , [ type , history , infoTab , location , queryParams ] ) ;
149+ } , [ dispatch , type , summaryTab ] ) ;
153150
154151 const renderTabs = ( ) => {
155152 const isTable = isTableType ( type ) ;
@@ -160,12 +157,12 @@ export function ObjectSummary({
160157 < Tabs
161158 size = "l"
162159 items = { tabsItems }
163- activeTab = { infoTab as string }
160+ activeTab = { summaryTab }
164161 wrapTo = { ( { id} , node ) => {
165162 const path = createHref ( routes . tenant , undefined , {
166163 ...queryParams ,
167164 name : tenantName as string ,
168- [ TenantTabsGroups . info ] : id ,
165+ [ TenantTabsGroups . summaryTab ] : id ,
169166 } ) ;
170167 return (
171168 < Link to = { path } key = { id } className = { b ( 'tab' ) } >
@@ -218,11 +215,11 @@ export function ObjectSummary({
218215 } ;
219216
220217 const renderTabContent = ( ) => {
221- switch ( infoTab ) {
222- case TenantInfoTabsIds . acl : {
218+ switch ( summaryTab ) {
219+ case TENANT_SUMMARY_TABS_IDS . acl : {
223220 return < Acl /> ;
224221 }
225- case TenantInfoTabsIds . schema : {
222+ case TENANT_SUMMARY_TABS_IDS . schema : {
226223 return loadingSchema ? (
227224 renderLoader ( )
228225 ) : (
0 commit comments