@@ -5,11 +5,9 @@ import {Helmet} from 'react-helmet-async';
55import { Link } from 'react-router-dom' ;
66import { StringParam , useQueryParams } from 'use-query-params' ;
77
8- import { Loader } from '../../../components/Loader' ;
98import routes , { createHref } from '../../../routes' ;
109import { TENANT_DIAGNOSTICS_TABS_IDS } from '../../../store/reducers/tenant/constants' ;
1110import { setDiagnosticsTab } from '../../../store/reducers/tenant/tenant' ;
12- import type { TenantDiagnosticsTab } from '../../../store/reducers/tenant/types' ;
1311import type { AdditionalNodesProps , AdditionalTenantsProps } from '../../../types/additionalProps' ;
1412import type { EPathType } from '../../../types/api/schema' ;
1513import { cn } from '../../../utils/cn' ;
@@ -37,6 +35,8 @@ import './Diagnostics.scss';
3735
3836interface DiagnosticsProps {
3937 type ?: EPathType ;
38+ tenantName : string ;
39+ path : string ;
4040 additionalTenantProps ?: AdditionalTenantsProps ;
4141 additionalNodesProps ?: AdditionalNodesProps ;
4242}
@@ -47,115 +47,88 @@ function Diagnostics(props: DiagnosticsProps) {
4747 const container = React . useRef < HTMLDivElement > ( null ) ;
4848
4949 const dispatch = useTypedDispatch ( ) ;
50- const { currentSchemaPath, wasLoaded} = useTypedSelector ( ( state ) => state . schema ) ;
5150 const { diagnosticsTab = TENANT_DIAGNOSTICS_TABS_IDS . overview } = useTypedSelector (
5251 ( state ) => state . tenant ,
5352 ) ;
5453
5554 const [ queryParams ] = useQueryParams ( {
5655 name : StringParam ,
56+ schema : StringParam ,
5757 backend : StringParam ,
5858 clusterName : StringParam ,
5959 } ) ;
6060
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 ;
6463
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+ }
7269
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 ) ) ;
8673 }
87- return undefined ;
88- } , [ pages , diagnosticsTab , wasLoaded ] ) ;
74+ } , [ activeTab , diagnosticsTab , dispatch ] ) ;
8975
9076 const renderTabContent = ( ) => {
91- const { type} = props ;
92-
93- const tenantNameString = tenantName as string ;
77+ const { type, path} = props ;
9478
9579 switch ( activeTab ?. id ) {
9680 case TENANT_DIAGNOSTICS_TABS_IDS . overview : {
9781 return (
9882 < DetailedOverview
9983 type = { type }
100- tenantName = { tenantNameString }
84+ tenantName = { tenantName }
85+ path = { path }
10186 additionalTenantProps = { props . additionalTenantProps }
10287 additionalNodesProps = { props . additionalNodesProps }
10388 />
10489 ) ;
10590 }
10691 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 /> ;
11593 }
11694 case TENANT_DIAGNOSTICS_TABS_IDS . topQueries : {
117- return < TopQueries path = { tenantNameString } type = { type } /> ;
95+ return < TopQueries tenantName = { tenantName } type = { type } /> ;
11896 }
11997 case TENANT_DIAGNOSTICS_TABS_IDS . topShards : {
120- return < TopShards tenantPath = { tenantNameString } type = { type } /> ;
98+ return < TopShards tenantName = { tenantName } path = { path } type = { type } /> ;
12199 }
122100 case TENANT_DIAGNOSTICS_TABS_IDS . nodes : {
123101 return (
124102 < NodesWrapper
125- path = { currentSchemaPath }
103+ path = { path }
126104 additionalNodesProps = { props . additionalNodesProps }
127105 parentContainer = { container . current }
128106 />
129107 ) ;
130108 }
131109 case TENANT_DIAGNOSTICS_TABS_IDS . tablets : {
132- return < Tablets path = { currentSchemaPath } /> ;
110+ return < Tablets path = { path } /> ;
133111 }
134112 case TENANT_DIAGNOSTICS_TABS_IDS . storage : {
135- return (
136- < StorageWrapper tenant = { tenantNameString } parentContainer = { container . current } />
137- ) ;
113+ return < StorageWrapper tenant = { tenantName } parentContainer = { container . current } /> ;
138114 }
139115 case TENANT_DIAGNOSTICS_TABS_IDS . network : {
140- return < Network path = { tenantNameString } /> ;
116+ return < Network tenantName = { tenantName } /> ;
141117 }
142118 case TENANT_DIAGNOSTICS_TABS_IDS . describe : {
143- return < Describe tenant = { tenantNameString } type = { type } /> ;
119+ return < Describe path = { path } type = { type } /> ;
144120 }
145121 case TENANT_DIAGNOSTICS_TABS_IDS . hotKeys : {
146- // @ts -expect-error
147- return < HotKeys path = { currentSchemaPath } /> ;
122+ return < HotKeys path = { path } /> ;
148123 }
149124 case TENANT_DIAGNOSTICS_TABS_IDS . graph : {
150- // @ts -expect-error
151- return < Heatmap path = { currentSchemaPath } /> ;
125+ return < Heatmap path = { path } /> ;
152126 }
153127 case TENANT_DIAGNOSTICS_TABS_IDS . consumers : {
154- // @ts -expect-error
155- return < Consumers path = { currentSchemaPath } type = { type } /> ;
128+ return < Consumers path = { path } type = { type } /> ;
156129 }
157130 case TENANT_DIAGNOSTICS_TABS_IDS . partitions : {
158- return < Partitions path = { currentSchemaPath } /> ;
131+ return < Partitions path = { path } /> ;
159132 }
160133 default : {
161134 return < div > No data...</ div > ;
@@ -169,7 +142,7 @@ function Diagnostics(props: DiagnosticsProps) {
169142 < Tabs
170143 size = "l"
171144 items = { pages }
172- activeTab = { activeTab ?. id as string }
145+ activeTab = { activeTab ?. id }
173146 wrapTo = { ( { id} , node ) => {
174147 const path = createHref ( routes . tenant , undefined , {
175148 ...queryParams ,
@@ -190,13 +163,6 @@ function Diagnostics(props: DiagnosticsProps) {
190163 ) ;
191164 } ;
192165
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-
200166 return (
201167 < div className = { b ( ) } ref = { container } >
202168 { activeTab ? (
0 commit comments