11import { ArrowToggle , Disclosure , Flex , Icon , Text } from '@gravity-ui/uikit' ;
22
33import { ResponseError } from '../../../components/Errors/ResponseError' ;
4- import { useClusterDashboardAvailable } from '../../../store/reducers/capabilities/hooks' ;
4+ import {
5+ useBridgeMockEnabled ,
6+ useBridgeModeEnabled ,
7+ useClusterDashboardAvailable ,
8+ } from '../../../store/reducers/capabilities/hooks' ;
59import type { ClusterGroupsStats } from '../../../store/reducers/cluster/types' ;
610import type { AdditionalClusterProps } from '../../../types/additionalProps' ;
711import { isClusterInfoV2 , isClusterInfoV5 } from '../../../types/api/cluster' ;
8- import type { TClusterInfo } from '../../../types/api/cluster' ;
12+ import type { TBridgePile , TClusterInfo } from '../../../types/api/cluster' ;
913import type { IResponseError } from '../../../types/api/error' ;
1014import { valueIsDefined } from '../../../utils' ;
1115import { EXPAND_CLUSTER_DASHBOARD } from '../../../utils/constants' ;
@@ -36,6 +40,18 @@ interface ClusterOverviewProps {
3640
3741export function ClusterOverview ( props : ClusterOverviewProps ) {
3842 const [ expandDashboard , setExpandDashboard ] = useSetting < boolean > ( EXPAND_CLUSTER_DASHBOARD ) ;
43+ const bridgeModeEnabled = useBridgeModeEnabled ( ) ;
44+ const bridgeMockEnabled = useBridgeMockEnabled ( ) ;
45+ let bridgePiles : TBridgePile [ ] | undefined ;
46+ if ( isClusterInfoV5 ( props . cluster ) ) {
47+ const { BridgeInfo} = props . cluster ;
48+ const shouldShowBridge =
49+ ( bridgeModeEnabled || bridgeMockEnabled ) &&
50+ ( Boolean ( BridgeInfo ?. Piles ?. length ) || bridgeMockEnabled ) ;
51+ if ( shouldShowBridge ) {
52+ bridgePiles = BridgeInfo ?. Piles ?? getMockBridgePiles ( ) ;
53+ }
54+ }
3955 if ( props . error ) {
4056 return < ResponseError error = { props . error } className = { b ( 'error' ) } /> ;
4157 }
@@ -67,7 +83,7 @@ export function ClusterOverview(props: ClusterOverviewProps) {
6783 ) }
6884 </ Disclosure . Summary >
6985 < ClusterDashboard { ...props } />
70- < ClusterInfo { ...props } />
86+ < ClusterInfo { ...props } bridgePiles = { bridgePiles } />
7187 </ Disclosure >
7288 </ Flex >
7389 ) ;
@@ -93,7 +109,7 @@ function ClusterDoughnuts({cluster, groupStats = {}, loading, collapsed}: Cluste
93109 if ( loading ) {
94110 return < ClusterDashboardSkeleton collapsed = { collapsed } /> ;
95111 }
96- const metricsCards = [ ] ;
112+ const metricsCards = [ ] as React . ReactNode [ ] ;
97113 if ( isClusterInfoV2 ( cluster ) ) {
98114 const { CoresUsed, NumberOfCpus, CoresTotal} = cluster ;
99115 const total = CoresTotal ?? NumberOfCpus ;
@@ -148,3 +164,10 @@ function ClusterDoughnuts({cluster, groupStats = {}, loading, collapsed}: Cluste
148164
149165 return metricsCards ;
150166}
167+
168+ function getMockBridgePiles ( ) : TBridgePile [ ] {
169+ return [
170+ { PileId : 1 , Name : 'r1' , State : 'SYNCHRONIZED' , IsPrimary : true , Nodes : 16 } ,
171+ { PileId : 2 , Name : 'r2' , State : 'SYNCHRONIZED' , IsPrimary : false , Nodes : 16 } ,
172+ ] ;
173+ }
0 commit comments