@@ -5,11 +5,9 @@ import {Helmet} from 'react-helmet-async';
5
5
import { Link } from 'react-router-dom' ;
6
6
import { StringParam , useQueryParams } from 'use-query-params' ;
7
7
8
- import { Loader } from '../../../components/Loader' ;
9
8
import routes , { createHref } from '../../../routes' ;
10
9
import { TENANT_DIAGNOSTICS_TABS_IDS } from '../../../store/reducers/tenant/constants' ;
11
10
import { setDiagnosticsTab } from '../../../store/reducers/tenant/tenant' ;
12
- import type { TenantDiagnosticsTab } from '../../../store/reducers/tenant/types' ;
13
11
import type { AdditionalNodesProps , AdditionalTenantsProps } from '../../../types/additionalProps' ;
14
12
import type { EPathType } from '../../../types/api/schema' ;
15
13
import { cn } from '../../../utils/cn' ;
@@ -37,6 +35,8 @@ import './Diagnostics.scss';
37
35
38
36
interface DiagnosticsProps {
39
37
type ?: EPathType ;
38
+ tenantName : string ;
39
+ path : string ;
40
40
additionalTenantProps ?: AdditionalTenantsProps ;
41
41
additionalNodesProps ?: AdditionalNodesProps ;
42
42
}
@@ -47,115 +47,88 @@ function Diagnostics(props: DiagnosticsProps) {
47
47
const container = React . useRef < HTMLDivElement > ( null ) ;
48
48
49
49
const dispatch = useTypedDispatch ( ) ;
50
- const { currentSchemaPath, wasLoaded} = useTypedSelector ( ( state ) => state . schema ) ;
51
50
const { diagnosticsTab = TENANT_DIAGNOSTICS_TABS_IDS . overview } = useTypedSelector (
52
51
( state ) => state . tenant ,
53
52
) ;
54
53
55
54
const [ queryParams ] = useQueryParams ( {
56
55
name : StringParam ,
56
+ schema : StringParam ,
57
57
backend : StringParam ,
58
58
clusterName : StringParam ,
59
59
} ) ;
60
60
61
- const { name : rootTenantName } = queryParams ;
62
- const tenantName = isDatabaseEntityType ( props . type ) ? currentSchemaPath : rootTenantName ;
63
- const isDatabase = isDatabaseEntityType ( props . type ) || currentSchemaPath === rootTenantName ;
61
+ const tenantName = isDatabaseEntityType ( props . type ) ? props . path : props . tenantName ;
62
+ const isDatabase = isDatabaseEntityType ( props . type ) || props . path === props . tenantName ;
64
63
65
- const pages = React . useMemo ( ( ) => {
66
- if ( isDatabase ) {
67
- return DATABASE_PAGES ;
68
- }
69
-
70
- return getPagesByType ( props . type ) ;
71
- } , [ props . type , isDatabase ] ) ;
64
+ const pages = isDatabase ? DATABASE_PAGES : getPagesByType ( props . type ) ;
65
+ let activeTab = pages . find ( ( el ) => el . id === diagnosticsTab ) ;
66
+ if ( ! activeTab ) {
67
+ activeTab = pages [ 0 ] ;
68
+ }
72
69
73
- const forwardToDiagnosticTab = ( tab : TenantDiagnosticsTab ) => {
74
- dispatch ( setDiagnosticsTab ( tab ) ) ;
75
- } ;
76
- const activeTab = React . useMemo ( ( ) => {
77
- if ( wasLoaded ) {
78
- let page = pages . find ( ( el ) => el . id === diagnosticsTab ) ;
79
- if ( ! page ) {
80
- page = pages [ 0 ] ;
81
- }
82
- if ( page && page . id !== diagnosticsTab ) {
83
- forwardToDiagnosticTab ( page . id ) ;
84
- }
85
- return page ;
70
+ React . useEffect ( ( ) => {
71
+ if ( activeTab && activeTab . id !== diagnosticsTab ) {
72
+ dispatch ( setDiagnosticsTab ( activeTab . id ) ) ;
86
73
}
87
- return undefined ;
88
- } , [ pages , diagnosticsTab , wasLoaded ] ) ;
74
+ } , [ activeTab , diagnosticsTab , dispatch ] ) ;
89
75
90
76
const renderTabContent = ( ) => {
91
- const { type} = props ;
92
-
93
- const tenantNameString = tenantName as string ;
77
+ const { type, path} = props ;
94
78
95
79
switch ( activeTab ?. id ) {
96
80
case TENANT_DIAGNOSTICS_TABS_IDS . overview : {
97
81
return (
98
82
< DetailedOverview
99
83
type = { type }
100
- tenantName = { tenantNameString }
84
+ tenantName = { tenantName }
85
+ path = { path }
101
86
additionalTenantProps = { props . additionalTenantProps }
102
87
additionalNodesProps = { props . additionalNodesProps }
103
88
/>
104
89
) ;
105
90
}
106
91
case TENANT_DIAGNOSTICS_TABS_IDS . schema : {
107
- return (
108
- < SchemaViewer
109
- path = { currentSchemaPath }
110
- tenantName = { tenantName }
111
- type = { type }
112
- extended
113
- />
114
- ) ;
92
+ return < SchemaViewer path = { path } tenantName = { tenantName } type = { type } extended /> ;
115
93
}
116
94
case TENANT_DIAGNOSTICS_TABS_IDS . topQueries : {
117
- return < TopQueries path = { tenantNameString } type = { type } /> ;
95
+ return < TopQueries tenantName = { tenantName } type = { type } /> ;
118
96
}
119
97
case TENANT_DIAGNOSTICS_TABS_IDS . topShards : {
120
- return < TopShards tenantPath = { tenantNameString } type = { type } /> ;
98
+ return < TopShards tenantName = { tenantName } path = { path } type = { type } /> ;
121
99
}
122
100
case TENANT_DIAGNOSTICS_TABS_IDS . nodes : {
123
101
return (
124
102
< NodesWrapper
125
- path = { currentSchemaPath }
103
+ path = { path }
126
104
additionalNodesProps = { props . additionalNodesProps }
127
105
parentContainer = { container . current }
128
106
/>
129
107
) ;
130
108
}
131
109
case TENANT_DIAGNOSTICS_TABS_IDS . tablets : {
132
- return < Tablets path = { currentSchemaPath } /> ;
110
+ return < Tablets path = { path } /> ;
133
111
}
134
112
case TENANT_DIAGNOSTICS_TABS_IDS . storage : {
135
- return (
136
- < StorageWrapper tenant = { tenantNameString } parentContainer = { container . current } />
137
- ) ;
113
+ return < StorageWrapper tenant = { tenantName } parentContainer = { container . current } /> ;
138
114
}
139
115
case TENANT_DIAGNOSTICS_TABS_IDS . network : {
140
- return < Network path = { tenantNameString } /> ;
116
+ return < Network tenantName = { tenantName } /> ;
141
117
}
142
118
case TENANT_DIAGNOSTICS_TABS_IDS . describe : {
143
- return < Describe tenant = { tenantNameString } type = { type } /> ;
119
+ return < Describe path = { path } type = { type } /> ;
144
120
}
145
121
case TENANT_DIAGNOSTICS_TABS_IDS . hotKeys : {
146
- // @ts -expect-error
147
- return < HotKeys path = { currentSchemaPath } /> ;
122
+ return < HotKeys path = { path } /> ;
148
123
}
149
124
case TENANT_DIAGNOSTICS_TABS_IDS . graph : {
150
- // @ts -expect-error
151
- return < Heatmap path = { currentSchemaPath } /> ;
125
+ return < Heatmap path = { path } /> ;
152
126
}
153
127
case TENANT_DIAGNOSTICS_TABS_IDS . consumers : {
154
- // @ts -expect-error
155
- return < Consumers path = { currentSchemaPath } type = { type } /> ;
128
+ return < Consumers path = { path } type = { type } /> ;
156
129
}
157
130
case TENANT_DIAGNOSTICS_TABS_IDS . partitions : {
158
- return < Partitions path = { currentSchemaPath } /> ;
131
+ return < Partitions path = { path } /> ;
159
132
}
160
133
default : {
161
134
return < div > No data...</ div > ;
@@ -169,7 +142,7 @@ function Diagnostics(props: DiagnosticsProps) {
169
142
< Tabs
170
143
size = "l"
171
144
items = { pages }
172
- activeTab = { activeTab ?. id as string }
145
+ activeTab = { activeTab ?. id }
173
146
wrapTo = { ( { id} , node ) => {
174
147
const path = createHref ( routes . tenant , undefined , {
175
148
...queryParams ,
@@ -190,13 +163,6 @@ function Diagnostics(props: DiagnosticsProps) {
190
163
) ;
191
164
} ;
192
165
193
- // Loader prevents incorrect loading of tabs
194
- // After tabs are initially loaded it is no longer needed
195
- // Thus there is no also "loading" check as in other parts of the project
196
- if ( ! wasLoaded ) {
197
- return < Loader size = "l" /> ;
198
- }
199
-
200
166
return (
201
167
< div className = { b ( ) } ref = { container } >
202
168
{ activeTab ? (
0 commit comments