Skip to content

Commit 20f1acc

Browse files
committed
fix: improve usability
1 parent ac4add6 commit 20f1acc

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

src/components/InternalLink/InternalLink.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import PropTypes from 'prop-types';
12
import cn from 'bem-cn-lite';
23

34
import {Link} from 'react-router-dom';
@@ -13,3 +14,10 @@ export default function InternalLink({to, children, onClick, className}) {
1314
children
1415
);
1516
}
17+
18+
InternalLink.propTypes = {
19+
to: PropTypes.string.isRequired,
20+
children: PropTypes.node,
21+
onClick: PropTypes.func,
22+
className: PropTypes.string,
23+
};

src/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@
7474

7575
color: inherit;
7676
}
77+
78+
&__link {
79+
display: flex;
80+
81+
height: 100%;
82+
83+
color: inherit;
84+
}
7785
}

src/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, {useContext} from 'react';
2-
import HistoryContext from '../../../contexts/HistoryContext';
1+
import React from 'react';
2+
import InternalLink from '../../../components/InternalLink/InternalLink';
33
import cn from 'bem-cn-lite';
44

55
import './DiskStateProgressBar.scss';
@@ -26,28 +26,33 @@ function DiskStateProgressBar({
2626
severity,
2727
href,
2828
}: DiskStateProgressBarProps) {
29-
const history = useContext(HistoryContext);
30-
const onDiskClick = () => {
31-
if (href) {
32-
history.push(href);
33-
}
29+
const renderAllocatedPercent = () => {
30+
return (
31+
diskAllocatedPercent >= 0 && (
32+
<React.Fragment>
33+
<div className={b('filled')} style={{width: `${diskAllocatedPercent}%`}} />
34+
<div className={b('filled-title')}>
35+
{`${Math.round(diskAllocatedPercent)}%`}
36+
</div>
37+
</React.Fragment>
38+
)
39+
);
3440
};
41+
3542
return (
3643
<div
3744
className={
3845
severity !== undefined
3946
? b({[diskProgressColors[severity].toLowerCase()]: true})
4047
: undefined
4148
}
42-
onClick={onDiskClick}
4349
>
44-
{diskAllocatedPercent >= 0 && (
45-
<React.Fragment>
46-
<div className={b('filled')} style={{width: `${diskAllocatedPercent}%`}} />
47-
<div className={b('filled-title')}>
48-
{`${Math.round(diskAllocatedPercent)}%`}
49-
</div>
50-
</React.Fragment>
50+
{href ? (
51+
<InternalLink to={href} className={b('link')}>
52+
{renderAllocatedPercent()}
53+
</InternalLink>
54+
) : (
55+
renderAllocatedPercent()
5156
)}
5257
</div>
5358
);

src/containers/VdiskPdiskNode/VdiskPdiskNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function Vdisk({
8484
value: <EntityStatus status={SatisfactionRank.LevelRank.Flag} />,
8585
});
8686
}
87-
vdiskInfo.push({label: 'Replicated', value: Replicated ? '' : ''});
87+
vdiskInfo.push({label: 'Replicated', value: Replicated ? 'Yes' : 'No'});
8888
vdiskInfo.push({label: 'Allocated Size', value: bytesToGB(AllocatedSize)});
8989
vdiskInfo.push({label: 'Available Size', value: bytesToGB(AvailableSize)});
9090
if (Number(AllocatedSize) >= 0 && Number(AvailableSize) >= 0) {

0 commit comments

Comments
 (0)