Skip to content

Commit 9c0355d

Browse files
committed
fix(PDisk): new popup design
1 parent bba5ae8 commit 9c0355d

File tree

2 files changed

+29
-51
lines changed

2 files changed

+29
-51
lines changed

src/containers/Storage/Pdisk/Pdisk.scss

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,8 @@
1111
&:last-child {
1212
margin-right: 0px;
1313
}
14-
&__popup-wrapper {
15-
padding: 5px 10px;
16-
}
17-
&__popup-content {
18-
display: grid;
19-
justify-items: stretch;
20-
column-gap: 5px;
21-
}
22-
&__popup-section-name {
23-
grid-column: 1 / 3;
24-
25-
margin: 5px 0;
2614

27-
font-weight: 500;
28-
text-align: center;
29-
30-
border-bottom: 1px solid var(--yc-color-line-generic);
31-
}
32-
&__property {
33-
text-align: right;
15+
&__popup-wrapper {
16+
padding: 12px;
3417
}
3518
}

src/containers/Storage/Pdisk/Pdisk.tsx

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {useEffect, useState, useRef, useMemo} from 'react';
22
import cn from 'bem-cn-lite';
3-
import _ from 'lodash';
43
import {Popup} from '@yandex-cloud/uikit';
54

65
import type {RequiredField} from '../../../types';
@@ -12,6 +11,7 @@ import routes, {createHref} from '../../../routes';
1211
import {getPDiskId} from '../../../utils';
1312
import {getPDiskType} from '../../../utils/pdisk';
1413
import {TPDiskStateInfo, TPDiskState} from '../../../types/api/storage';
14+
import {InfoViewer} from '../../../components/InfoViewer';
1515
import 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

Comments
 (0)