1
1
import React , { ReactNode , useEffect , useReducer } from 'react' ;
2
2
import { useDispatch } from 'react-redux' ;
3
- import { useHistory , useLocation } from 'react-router' ;
3
+ import { useLocation } from 'react-router' ;
4
4
import { Link } from 'react-router-dom' ;
5
5
import qs from 'qs' ;
6
6
import cn from 'bem-cn-lite' ;
@@ -31,19 +31,18 @@ import {
31
31
DEFAULT_SIZE_TENANT_SUMMARY_KEY ,
32
32
} from '../../../utils/constants' ;
33
33
import { 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' ;
36
40
37
41
import { SchemaTree } from '../Schema/SchemaTree/SchemaTree' ;
38
42
import { SchemaViewer } from '../Schema/SchemaViewer/SchemaViewer' ;
39
43
import { Acl } from '../Acl/Acl' ;
40
44
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' ;
47
46
import {
48
47
PaneVisibilityActionTypes ,
49
48
paneVisibilityToggleReducerCreator ,
@@ -115,16 +114,17 @@ export function ObjectSummary({
115
114
currentSchema : currentItem = { } ,
116
115
loading : loadingSchema ,
117
116
} = useTypedSelector ( ( state ) => state . schema ) ;
117
+ const { summaryTab = TENANT_SUMMARY_TABS_IDS . overview } = useTypedSelector (
118
+ ( state ) => state . tenant ,
119
+ ) ;
118
120
119
121
const location = useLocation ( ) ;
120
122
121
- const history = useHistory ( ) ;
122
-
123
123
const queryParams = qs . parse ( location . search , {
124
124
ignoreQueryPrefix : true ,
125
125
} ) ;
126
126
127
- const { name : tenantName , info : infoTab } = queryParams ;
127
+ const { name : tenantName } = queryParams ;
128
128
129
129
const pathData = tenantName ? data [ tenantName . toString ( ) ] ?. PathDescription ?. Self : undefined ;
130
130
const currentObjectData = currentSchemaPath ? data [ currentSchemaPath ] : undefined ;
@@ -143,13 +143,10 @@ export function ObjectSummary({
143
143
useEffect ( ( ) => {
144
144
const isTable = isTableType ( type ) ;
145
145
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 ) ) ;
151
148
}
152
- } , [ type , history , infoTab , location , queryParams ] ) ;
149
+ } , [ dispatch , type , summaryTab ] ) ;
153
150
154
151
const renderTabs = ( ) => {
155
152
const isTable = isTableType ( type ) ;
@@ -160,12 +157,12 @@ export function ObjectSummary({
160
157
< Tabs
161
158
size = "l"
162
159
items = { tabsItems }
163
- activeTab = { infoTab as string }
160
+ activeTab = { summaryTab }
164
161
wrapTo = { ( { id} , node ) => {
165
162
const path = createHref ( routes . tenant , undefined , {
166
163
...queryParams ,
167
164
name : tenantName as string ,
168
- [ TenantTabsGroups . info ] : id ,
165
+ [ TenantTabsGroups . summaryTab ] : id ,
169
166
} ) ;
170
167
return (
171
168
< Link to = { path } key = { id } className = { b ( 'tab' ) } >
@@ -218,11 +215,11 @@ export function ObjectSummary({
218
215
} ;
219
216
220
217
const renderTabContent = ( ) => {
221
- switch ( infoTab ) {
222
- case TenantInfoTabsIds . acl : {
218
+ switch ( summaryTab ) {
219
+ case TENANT_SUMMARY_TABS_IDS . acl : {
223
220
return < Acl /> ;
224
221
}
225
- case TenantInfoTabsIds . schema : {
222
+ case TENANT_SUMMARY_TABS_IDS . schema : {
226
223
return loadingSchema ? (
227
224
renderLoader ( )
228
225
) : (
0 commit comments