@@ -28,6 +28,7 @@ import type {
2828 AdditionalTenantsProps ,
2929} from '../../types/additionalProps' ;
3030import { EFlag } from '../../types/api/enums' ;
31+ import { uiFactory } from '../../uiFactory/uiFactory' ;
3132import { cn } from '../../utils/cn' ;
3233import { useAutoRefreshInterval , useTypedDispatch , useTypedSelector } from '../../utils/hooks' ;
3334import { useAppTitle } from '../App/AppTitleContext' ;
@@ -39,7 +40,13 @@ import {VersionsContainer} from '../Versions/Versions';
3940
4041import { ClusterOverview } from './ClusterOverview/ClusterOverview' ;
4142import type { ClusterTab } from './utils' ;
42- import { clusterTabs , clusterTabsIds , getClusterPath , isClusterTab } from './utils' ;
43+ import {
44+ clusterTabs ,
45+ clusterTabsIds ,
46+ getClusterPath ,
47+ isClusterTab ,
48+ useShouldShowEventsTab ,
49+ } from './utils' ;
4350
4451import './Cluster.scss' ;
4552
@@ -60,6 +67,7 @@ export function Cluster({
6067 const isClusterDashboardAvailable = useClusterDashboardAvailable ( ) ;
6168
6269 const shouldShowNetworkTable = useShouldShowClusterNetworkTable ( ) ;
70+ const shouldShowEventsTab = useShouldShowEventsTab ( ) ;
6371
6472 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
6573
@@ -99,12 +107,17 @@ export function Cluster({
99107 } , [ dispatch ] ) ;
100108
101109 const actualClusterTabs = React . useMemo ( ( ) => {
102- if ( shouldShowNetworkTable ) {
103- return clusterTabs ;
104- } else {
105- return clusterTabs . filter ( ( tab ) => tab . id !== clusterTabsIds . network ) ;
110+ let tabs = clusterTabs ;
111+
112+ if ( ! shouldShowNetworkTable ) {
113+ tabs = tabs . filter ( ( tab ) => tab . id !== clusterTabsIds . network ) ;
106114 }
107- } , [ shouldShowNetworkTable ] ) ;
115+ if ( ! shouldShowEventsTab ) {
116+ tabs = tabs . filter ( ( tab ) => tab . id !== clusterTabsIds . events ) ;
117+ }
118+
119+ return tabs ;
120+ } , [ shouldShowEventsTab , shouldShowNetworkTable ] ) ;
108121
109122 const getClusterTitle = ( ) => {
110123 if ( infoLoading ) {
@@ -240,6 +253,17 @@ export function Cluster({
240253 >
241254 < VersionsContainer cluster = { cluster } loading = { infoLoading } />
242255 </ Route >
256+ { shouldShowEventsTab && (
257+ < Route
258+ path = {
259+ getLocationObjectFromHref ( getClusterPath ( clusterTabsIds . events ) )
260+ . pathname
261+ }
262+ >
263+ { uiFactory . renderEvents ?.( ) }
264+ </ Route >
265+ ) }
266+
243267 < Route
244268 render = { ( ) => (
245269 < Redirect to = { getLocationObjectFromHref ( getClusterPath ( activeTabId ) ) } />
@@ -257,13 +281,19 @@ function useClusterTab() {
257281 const defaultTab = useTypedSelector ( ( state ) => state . cluster . defaultClusterTab ) ;
258282
259283 const shouldShowNetworkTable = useShouldShowClusterNetworkTable ( ) ;
284+ const shouldShowEventsTab = useShouldShowEventsTab ( ) ;
260285
261286 const match = useRouteMatch < { activeTab : string } > ( routes . cluster ) ;
262287
263288 const { activeTab : activeTabFromParams } = match ?. params || { } ;
264289 let activeTab : ClusterTab ;
265290
266- if ( ! shouldShowNetworkTable && activeTabFromParams === clusterTabsIds . network ) {
291+ const shouldSwitchFromNetworkToDefault =
292+ ! shouldShowNetworkTable && activeTabFromParams === clusterTabsIds . network ;
293+ const shouldSwitchFromEventsToDefault =
294+ ! shouldShowEventsTab && activeTabFromParams === clusterTabsIds . events ;
295+
296+ if ( shouldSwitchFromNetworkToDefault || shouldSwitchFromEventsToDefault ) {
267297 activeTab = INITIAL_DEFAULT_CLUSTER_TAB ;
268298 } else if ( isClusterTab ( activeTabFromParams ) ) {
269299 activeTab = activeTabFromParams ;
0 commit comments