11import React , { useEffect , useState , useRef , useMemo } from 'react' ;
22import cn from 'bem-cn-lite' ;
3- import _ from 'lodash' ;
43import { Popup } from '@yandex-cloud/uikit' ;
54
65import type { RequiredField } from '../../../types' ;
@@ -12,6 +11,7 @@ import routes, {createHref} from '../../../routes';
1211import { getPDiskId } from '../../../utils' ;
1312import { getPDiskType } from '../../../utils/pdisk' ;
1413import { TPDiskStateInfo , TPDiskState } from '../../../types/api/storage' ;
14+ import { InfoViewer } from '../../../components/InfoViewer' ;
1515import DiskStateProgressBar , {
1616 diskProgressColors ,
1717} from '../DiskStateProgressBar/DiskStateProgressBar' ;
@@ -78,51 +78,46 @@ function Pdisk(props: PDiskProps) {
7878 diskProgressColors [ colorSeverity . Yellow as keyof typeof diskProgressColors ] ,
7979 ] ;
8080
81- const pdiskData : { property : string ; value : string | number } [ ] = [
82- { property : 'PDisk' , value : getPDiskId ( { NodeId, PDiskId} ) } ,
81+ const pdiskData : { label : string ; value : string | number } [ ] = [
82+ { label : 'PDisk' , value : getPDiskId ( { NodeId, PDiskId} ) } ,
8383 ] ;
8484
85- pdiskData . push ( { property : 'State' , value : State || 'not available' } ) ;
86- pdiskData . push ( { property : 'Type' , value : getPDiskType ( props ) || 'unknown' } ) ;
87- NodeId && pdiskData . push ( { property : 'Node Id' , value : NodeId } ) ;
85+ pdiskData . push ( { label : 'State' , value : State || 'not available' } ) ;
86+ pdiskData . push ( { label : 'Type' , value : getPDiskType ( props ) || 'unknown' } ) ;
87+ NodeId && pdiskData . push ( { label : 'Node Id' , value : NodeId } ) ;
8888
89- Path && pdiskData . push ( { property : 'Path' , value : Path } ) ;
89+ Path && pdiskData . push ( { label : 'Path' , value : Path } ) ;
9090 pdiskData . push ( {
91- property : 'Available' ,
91+ label : 'Available' ,
9292 value : `${ bytesToGB ( AvailableSize ) } of ${ bytesToGB ( TotalSize ) } ` ,
9393 } ) ;
9494 Realtime &&
9595 errorColors . includes ( Realtime ) &&
96- pdiskData . push ( { property : 'Realtime' , value : Realtime } ) ;
96+ pdiskData . push ( { label : 'Realtime' , value : Realtime } ) ;
9797 Device &&
9898 errorColors . includes ( Device ) &&
99- pdiskData . push ( { property : 'Device' , value : Device } ) ;
99+ pdiskData . push ( { label : 'Device' , value : Device } ) ;
100100 return pdiskData ;
101101 } ;
102102 /* eslint-enable */
103103
104- const renderPopup = ( ) => {
105- const pdiskData = preparePdiskData ( ) ;
106- return (
107- < Popup
108- className = { b ( 'popup-wrapper' ) }
109- anchorRef = { anchor }
110- open = { isPopupVisible }
111- placement = { [ 'top' , 'bottom' ] }
112- hasArrow
113- >
114- < div className = { b ( 'popup-content' ) } >
115- < div className = { b ( 'popup-section-name' ) } > PDisk</ div >
116- { _ . map ( pdiskData , ( row ) => (
117- < React . Fragment key = { row . property } >
118- < div className = { b ( 'property' ) } > { row . property } </ div >
119- < div className = { b ( 'value' ) } > { row . value } </ div >
120- </ React . Fragment >
121- ) ) }
122- </ div >
123- </ Popup >
124- ) ;
125- } ;
104+ const renderPopup = ( ) => (
105+ < Popup
106+ className = { b ( 'popup-wrapper' ) }
107+ anchorRef = { anchor }
108+ open = { isPopupVisible }
109+ placement = { [ 'top' , 'bottom' ] }
110+ // bigger offset for easier switching to neighbour nodes
111+ // matches the default offset for popup with arrow out of a sense of beauty
112+ offset = { [ 0 , 12 ] }
113+ >
114+ < InfoViewer
115+ title = "PDisk"
116+ info = { preparePdiskData ( ) }
117+ size = "s"
118+ />
119+ </ Popup >
120+ ) ;
126121
127122 const pdiskAllocatedPercent = useMemo ( ( ) => {
128123 const { AvailableSize, TotalSize} = props ;
0 commit comments