|
1 | 1 | import React, {useEffect, useState, useRef, useMemo} from 'react'; |
2 | 2 | import PropTypes from 'prop-types'; |
3 | 3 | import cn from 'bem-cn-lite'; |
| 4 | + |
4 | 5 | import {Label, Popup} from '@gravity-ui/uikit'; |
5 | 6 |
|
6 | | -import {bytesToGB, bytesToSpeed} from '../../../utils/utils'; |
| 7 | +import InternalLink from '../../../components/InternalLink/InternalLink'; |
| 8 | +import {InfoViewer} from '../../../components/InfoViewer'; |
| 9 | + |
7 | 10 | import routes, {createHref} from '../../../routes'; |
8 | 11 | import {stringifyVdiskId, getPDiskId} from '../../../utils'; |
9 | 12 | import {getPDiskType} from '../../../utils/pdisk'; |
10 | | -import {InfoViewer} from '../../../components/InfoViewer'; |
| 13 | +import {bytesToGB, bytesToSpeed} from '../../../utils/utils'; |
| 14 | + |
| 15 | +import {STRUCTURE} from '../../Node/NodePages'; |
| 16 | + |
11 | 17 | import DiskStateProgressBar, { |
12 | 18 | diskProgressColors, |
13 | 19 | } from '../DiskStateProgressBar/DiskStateProgressBar'; |
14 | | -import {STRUCTURE} from '../../Node/NodePages'; |
15 | 20 |
|
16 | 21 | import {colorSeverity, NOT_AVAILABLE_SEVERITY} from '../utils'; |
17 | 22 |
|
@@ -225,33 +230,41 @@ function Vdisk(props) { |
225 | 230 | const available = AvailableSize ? AvailableSize : PDisk?.AvailableSize; |
226 | 231 |
|
227 | 232 | if (!available) { |
228 | | - return; |
| 233 | + return undefined; |
229 | 234 | } |
230 | | - return !isNaN(Number(AllocatedSize)) |
231 | | - ? (Number(AllocatedSize) * 100) / (Number(available) + Number(AllocatedSize)) |
232 | | - : undefined; |
| 235 | + |
| 236 | + return isNaN(Number(AllocatedSize)) |
| 237 | + ? undefined |
| 238 | + : (Number(AllocatedSize) * 100) / (Number(available) + Number(AllocatedSize)); |
233 | 239 | }, [props.AllocatedSize, props.AvailableSize, props.PDisk?.AvailableSize]); |
234 | 240 |
|
235 | 241 | return ( |
236 | 242 | <React.Fragment> |
237 | 243 | {renderPopup()} |
238 | 244 | <div className={b()} ref={anchor} onMouseEnter={showPopup} onMouseLeave={hidePopup}> |
239 | | - <DiskStateProgressBar |
240 | | - diskAllocatedPercent={vdiskAllocatedPercent} |
241 | | - severity={severity} |
242 | | - href={ |
243 | | - props.NodeId |
244 | | - ? createHref( |
245 | | - routes.node, |
246 | | - {id: props.NodeId, activeTab: STRUCTURE}, |
247 | | - { |
248 | | - pdiskId: props.PDisk?.PDiskId, |
249 | | - vdiskId: stringifyVdiskId(props.VDiskId), |
250 | | - }, |
251 | | - ) |
252 | | - : undefined |
253 | | - } |
254 | | - /> |
| 245 | + {props.NodeId ? ( |
| 246 | + <InternalLink |
| 247 | + to={createHref( |
| 248 | + routes.node, |
| 249 | + {id: props.NodeId, activeTab: STRUCTURE}, |
| 250 | + { |
| 251 | + pdiskId: props.PDisk?.PDiskId, |
| 252 | + vdiskId: stringifyVdiskId(props.VDiskId), |
| 253 | + }, |
| 254 | + )} |
| 255 | + className={b('content')} |
| 256 | + > |
| 257 | + <DiskStateProgressBar |
| 258 | + diskAllocatedPercent={vdiskAllocatedPercent} |
| 259 | + severity={severity} |
| 260 | + /> |
| 261 | + </InternalLink> |
| 262 | + ) : ( |
| 263 | + <DiskStateProgressBar |
| 264 | + diskAllocatedPercent={vdiskAllocatedPercent} |
| 265 | + severity={severity} |
| 266 | + /> |
| 267 | + )} |
255 | 268 | </div> |
256 | 269 | </React.Fragment> |
257 | 270 | ); |
|
0 commit comments