Skip to content

Commit 1868e18

Browse files
fix(Storage): display unavailable vdisks with average size (#1511)
1 parent 57d2092 commit 1868e18

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/containers/Storage/Disks/Disks.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66

77
width: max-content;
88

9-
&__vdisks-wrapper {
10-
display: flex;
11-
flex-grow: 1;
12-
flex-direction: row;
13-
gap: 4px;
14-
15-
width: 300px;
16-
}
17-
189
&__pdisks-wrapper {
1910
display: flex;
2011
flex-direction: row;

src/containers/Storage/Disks/Disks.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22

3+
import {Flex, useLayoutContext} from '@gravity-ui/uikit';
4+
35
import {VDisk} from '../../../components/VDisk/VDisk';
6+
import {valueIsDefined} from '../../../utils';
47
import {cn} from '../../../utils/cn';
58
import {getPDiskId} from '../../../utils/disks/helpers';
69
import type {PreparedVDisk} from '../../../utils/disks/types';
@@ -12,6 +15,8 @@ import './Disks.scss';
1215

1316
const b = cn('ydb-storage-disks');
1417

18+
const VDISKS_CONTAINER_WIDTH = 300;
19+
1520
interface DisksProps {
1621
vDisks?: PreparedVDisk[];
1722
viewContext?: StorageViewContext;
@@ -20,23 +25,31 @@ interface DisksProps {
2025
export function Disks({vDisks = [], viewContext}: DisksProps) {
2126
const [highlightedVDisk, setHighlightedVDisk] = React.useState<string | undefined>();
2227

28+
const {
29+
theme: {spaceBaseSize},
30+
} = useLayoutContext();
31+
2332
if (!vDisks.length) {
2433
return null;
2534
}
2635

36+
const unavailableVDiskWidth =
37+
(VDISKS_CONTAINER_WIDTH - spaceBaseSize * (vDisks.length - 1)) / vDisks.length;
38+
2739
return (
2840
<div className={b(null)}>
29-
<div className={b('vdisks-wrapper')}>
41+
<Flex direction={'row'} gap={1} grow style={{width: VDISKS_CONTAINER_WIDTH}}>
3042
{vDisks?.map((vDisk) => (
3143
<VDiskItem
3244
key={vDisk.StringifiedId}
3345
vDisk={vDisk}
3446
inactive={!isVdiskActive(vDisk, viewContext)}
3547
highlightedVDisk={highlightedVDisk}
3648
setHighlightedVDisk={setHighlightedVDisk}
49+
unavailableVDiskWidth={unavailableVDiskWidth}
3750
/>
3851
))}
39-
</div>
52+
</Flex>
4053

4154
<div className={b('pdisks-wrapper')}>
4255
{vDisks?.map((vDisk) => (
@@ -57,21 +70,27 @@ interface DisksItemProps {
5770
inactive?: boolean;
5871
highlightedVDisk: string | undefined;
5972
setHighlightedVDisk: (id: string | undefined) => void;
73+
unavailableVDiskWidth?: number;
6074
}
6175

62-
function VDiskItem({vDisk, highlightedVDisk, inactive, setHighlightedVDisk}: DisksItemProps) {
76+
function VDiskItem({
77+
vDisk,
78+
highlightedVDisk,
79+
inactive,
80+
setHighlightedVDisk,
81+
unavailableVDiskWidth,
82+
}: DisksItemProps) {
6383
// Do not show PDisk popup for VDisk
6484
const vDiskToShow = {...vDisk, PDisk: undefined};
6585

6686
const vDiskId = vDisk.StringifiedId;
6787

88+
// show vdisks without AllocatedSize as having average width (#1433)
89+
const minWidth = valueIsDefined(vDiskToShow.AllocatedSize) ? undefined : unavailableVDiskWidth;
90+
const flexGrow = Number(vDiskToShow.AllocatedSize) || 1;
91+
6892
return (
69-
<div
70-
style={{
71-
flexGrow: Number(vDisk.AllocatedSize) || 1,
72-
}}
73-
className={b('vdisk-item')}
74-
>
93+
<div style={{flexGrow, minWidth}} className={b('vdisk-item')}>
7594
<VDisk
7695
data={vDiskToShow}
7796
compact

0 commit comments

Comments
 (0)