@@ -17,13 +17,25 @@ import './VDisk.scss';
1717
1818const b = cn ( 'ydb-vdisk-component' ) ;
1919
20- interface VDiskProps {
20+ export interface VDiskProps {
2121 data ?: PreparedVDisk ;
2222 nodes ?: NodesMap ;
2323 compact ?: boolean ;
24+ showPopup ?: boolean ;
25+ onShowPopup ?: VoidFunction ;
26+ onHidePopup ?: VoidFunction ;
27+ progressBarClassName ?: string ;
2428}
2529
26- export const VDisk = ( { data = { } , nodes, compact} : VDiskProps ) => {
30+ export const VDisk = ( {
31+ data = { } ,
32+ nodes,
33+ compact,
34+ showPopup,
35+ onShowPopup,
36+ onHidePopup,
37+ progressBarClassName,
38+ } : VDiskProps ) => {
2739 const isFullData = isFullVDiskData ( data ) ;
2840
2941 const diskPagesAvailable = useDiskPagesAvailable ( ) ;
@@ -32,12 +44,14 @@ export const VDisk = ({data = {}, nodes, compact}: VDiskProps) => {
3244
3345 const anchor = React . useRef ( null ) ;
3446
35- const showPopup = ( ) => {
47+ const handleShowPopup = ( ) => {
3648 setIsPopupVisible ( true ) ;
49+ onShowPopup ?.( ) ;
3750 } ;
3851
39- const hidePopup = ( ) => {
52+ const handleHidePopup = ( ) => {
4053 setIsPopupVisible ( false ) ;
54+ onHidePopup ?.( ) ;
4155 } ;
4256
4357 let vDiskPath : string | undefined ;
@@ -62,24 +76,27 @@ export const VDisk = ({data = {}, nodes, compact}: VDiskProps) => {
6276
6377 return (
6478 < React . Fragment >
65- < VDiskPopup data = { data } nodes = { nodes } anchorRef = { anchor } open = { isPopupVisible } />
66- < div className = { b ( ) } ref = { anchor } onMouseEnter = { showPopup } onMouseLeave = { hidePopup } >
67- { vDiskPath ? (
68- < InternalLink to = { vDiskPath } className = { b ( 'content' ) } >
69- < DiskStateProgressBar
70- diskAllocatedPercent = { data . AllocatedPercent }
71- severity = { data . Severity }
72- compact = { compact }
73- />
74- </ InternalLink >
75- ) : (
79+ < div
80+ className = { b ( ) }
81+ ref = { anchor }
82+ onMouseEnter = { handleShowPopup }
83+ onMouseLeave = { handleHidePopup }
84+ >
85+ < InternalLink to = { vDiskPath } className = { b ( 'content' ) } >
7686 < DiskStateProgressBar
7787 diskAllocatedPercent = { data . AllocatedPercent }
7888 severity = { data . Severity }
7989 compact = { compact }
90+ className = { progressBarClassName }
8091 />
81- ) }
92+ </ InternalLink >
8293 </ div >
94+ < VDiskPopup
95+ data = { data }
96+ nodes = { nodes }
97+ anchorRef = { anchor }
98+ open = { isPopupVisible || showPopup }
99+ />
83100 </ React . Fragment >
84101 ) ;
85102} ;
0 commit comments