@@ -3,7 +3,7 @@ import React from 'react';
33import { Tab , TabList , TabProvider } from '@gravity-ui/uikit' ;
44import { skipToken } from '@reduxjs/toolkit/query' ;
55import { Helmet } from 'react-helmet-async' ;
6- import { useRouteMatch } from 'react-router-dom' ;
6+ import { useHistory , useRouteMatch } from 'react-router-dom' ;
77import { useQueryParams } from 'use-query-params' ;
88
99import { EntityPageTitle } from '../../components/EntityPageTitle/EntityPageTitle' ;
@@ -50,6 +50,7 @@ export function Node() {
5050 const configsAvailable = isViewerUser && hasConfigs ;
5151
5252 const dispatch = useTypedDispatch ( ) ;
53+ const history = useHistory ( ) ;
5354
5455 const match = useRouteMatch < { id : string ; activeTab : string } > ( routes . node ) ;
5556
@@ -71,6 +72,7 @@ export function Node() {
7172
7273 const capabilitiesLoaded = useCapabilitiesLoaded ( ) ;
7374 const isDiskPagesAvailable = useDiskPagesAvailable ( ) ;
75+ const isPeersHandlerAvailable = useViewerPeersHandlerAvailable ( ) ;
7476
7577 const pageLoading = isLoading || ! capabilitiesLoaded ;
7678
@@ -92,13 +94,23 @@ export function Node() {
9294 if ( ! threadsQuantity ) {
9395 skippedTabs . push ( 'threads' ) ;
9496 }
97+ if ( ! isPeersHandlerAvailable ) {
98+ skippedTabs . push ( 'network' ) ;
99+ }
95100 const actualNodeTabs = NODE_TABS . filter ( ( el ) => ! skippedTabs . includes ( el . id ) ) ;
96101
97102 const actualActiveTab =
98103 actualNodeTabs . find ( ( { id} ) => id === activeTabId ) ?? actualNodeTabs [ 0 ] ;
99104
100105 return { activeTab : actualActiveTab , nodeTabs : actualNodeTabs } ;
101- } , [ isStorageNode , isDiskPagesAvailable , activeTabId , threadsQuantity , configsAvailable ] ) ;
106+ } , [
107+ isStorageNode ,
108+ isDiskPagesAvailable ,
109+ isPeersHandlerAvailable ,
110+ activeTabId ,
111+ threadsQuantity ,
112+ configsAvailable ,
113+ ] ) ;
102114
103115 const database = tenantNameFromQuery ?. toString ( ) ;
104116
@@ -118,6 +130,18 @@ export function Node() {
118130 }
119131 } , [ dispatch , database , nodeId , isLoading , isStorageNode , databaseName ] ) ;
120132
133+ React . useEffect ( ( ) => {
134+ if ( ! nodeId || ! activeTab ) {
135+ return ;
136+ }
137+
138+ if ( activeTab . id !== activeTabId ) {
139+ const path = getDefaultNodePath ( { id : nodeId , activeTab : activeTab . id } , { database} ) ;
140+
141+ history . replace ( path ) ;
142+ }
143+ } , [ nodeId , database , activeTab . id , activeTabId , history , activeTab ] ) ;
144+
121145 return (
122146 < div className = { b ( null ) } ref = { container } >
123147 { < NodePageHelmet node = { node } activeTabTitle = { activeTab . title } /> }
@@ -216,8 +240,6 @@ function NodePageContent({
216240 tabs,
217241 parentContainer,
218242} : NodePageContentProps ) {
219- const isPeersHandlerAvailable = useViewerPeersHandlerAvailable ( ) ;
220-
221243 const renderTabs = ( ) => {
222244 return (
223245 < div className = { b ( 'tabs' ) } >
@@ -286,10 +308,6 @@ function NodePageContent({
286308 }
287309
288310 case 'network' : {
289- if ( ! isPeersHandlerAvailable ) {
290- return i18n ( 'alert_no-peers' ) ;
291- }
292-
293311 return < NodeNetwork nodeId = { nodeId } scrollContainerRef = { parentContainer } /> ;
294312 }
295313
0 commit comments