@@ -9,9 +9,12 @@ import {AutoRefreshControl} from '../../components/AutoRefreshControl/AutoRefres
99import { EntityStatus } from '../../components/EntityStatusNew/EntityStatus' ;
1010import { EFlagToDescription } from '../../components/EntityStatusNew/utils' ;
1111import { InternalLink } from '../../components/InternalLink' ;
12+ import { NetworkTable } from '../../components/NetworkTable/NetworkTable' ;
13+ import { useShouldShowClusterNetworkTable } from '../../components/NetworkTable/hooks' ;
1214import routes , { getLocationObjectFromHref } from '../../routes' ;
1315import { useClusterDashboardAvailable } from '../../store/reducers/capabilities/hooks' ;
1416import {
17+ INITIAL_DEFAULT_CLUSTER_TAB ,
1518 clusterApi ,
1619 selectClusterTabletsWithFqdn ,
1720 selectClusterTitle ,
@@ -55,6 +58,8 @@ export function Cluster({
5558 const container = React . useRef < HTMLDivElement > ( null ) ;
5659 const isClusterDashboardAvailable = useClusterDashboardAvailable ( ) ;
5760
61+ const shouldShowNetworkTable = useShouldShowClusterNetworkTable ( ) ;
62+
5863 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
5964
6065 const dispatch = useTypedDispatch ( ) ;
@@ -92,6 +97,14 @@ export function Cluster({
9297 dispatch ( setHeaderBreadcrumbs ( 'cluster' , { } ) ) ;
9398 } , [ dispatch ] ) ;
9499
100+ const actualClusterTabs = React . useMemo ( ( ) => {
101+ if ( shouldShowNetworkTable ) {
102+ return clusterTabs ;
103+ } else {
104+ return clusterTabs . filter ( ( tab ) => tab . id !== clusterTabsIds . network ) ;
105+ }
106+ } , [ shouldShowNetworkTable ] ) ;
107+
95108 const getClusterTitle = ( ) => {
96109 if ( infoLoading ) {
97110 return < Skeleton className = { b ( 'title-skeleton' ) } /> ;
@@ -110,8 +123,8 @@ export function Cluster({
110123 } ;
111124
112125 const activeTab = React . useMemo (
113- ( ) => clusterTabs . find ( ( { id} ) => id === activeTabId ) ,
114- [ activeTabId ] ,
126+ ( ) => actualClusterTabs . find ( ( { id} ) => id === activeTabId ) ,
127+ [ activeTabId , actualClusterTabs ] ,
115128 ) ;
116129
117130 return (
@@ -142,7 +155,7 @@ export function Cluster({
142155 size = "l"
143156 allowNotSelected = { true }
144157 activeTab = { activeTabId }
145- items = { clusterTabs }
158+ items = { actualClusterTabs }
146159 wrapTo = { ( { id} , node ) => {
147160 const path = getClusterPath ( id as ClusterTab , { clusterName, backend} ) ;
148161 return (
@@ -202,6 +215,19 @@ export function Cluster({
202215 >
203216 < PaginatedStorage scrollContainerRef = { container } />
204217 </ Route >
218+ { shouldShowNetworkTable && (
219+ < Route
220+ path = {
221+ getLocationObjectFromHref ( getClusterPath ( clusterTabsIds . network ) )
222+ . pathname
223+ }
224+ >
225+ < NetworkTable
226+ scrollContainerRef = { container }
227+ additionalNodesProps = { additionalNodesProps }
228+ />
229+ </ Route >
230+ ) }
205231 < Route
206232 path = {
207233 getLocationObjectFromHref ( getClusterPath ( clusterTabsIds . versions ) )
@@ -226,11 +252,16 @@ function useClusterTab() {
226252
227253 const defaultTab = useTypedSelector ( ( state ) => state . cluster . defaultClusterTab ) ;
228254
255+ const shouldShowNetworkTable = useShouldShowClusterNetworkTable ( ) ;
256+
229257 const match = useRouteMatch < { activeTab : string } > ( routes . cluster ) ;
230258
231259 const { activeTab : activeTabFromParams } = match ?. params || { } ;
232260 let activeTab : ClusterTab ;
233- if ( isClusterTab ( activeTabFromParams ) ) {
261+
262+ if ( ! shouldShowNetworkTable && activeTabFromParams === clusterTabsIds . network ) {
263+ activeTab = INITIAL_DEFAULT_CLUSTER_TAB ;
264+ } else if ( isClusterTab ( activeTabFromParams ) ) {
234265 activeTab = activeTabFromParams ;
235266 } else {
236267 activeTab = defaultTab ;
0 commit comments