forked from ydb-platform/ydb-embedded-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoolBar.tsx
37 lines (31 loc) · 1021 Bytes
/
PoolBar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type {TPoolStats} from '../../types/api/nodes';
import {cn} from '../../utils/cn';
import {ContentWithPopup} from '../ContentWithPopup/ContentWithPopup';
import {PoolTooltipContent} from '../TooltipsContent';
import './PoolBar.scss';
const b = cn('ydb-pool-bar');
const getBarType = (usage: number) => {
if (usage >= 75) {
return 'danger';
} else if (usage >= 50 && usage < 75) {
return 'warning';
} else {
return 'normal';
}
};
interface PoolBarProps {
data?: TPoolStats;
}
export const PoolBar = ({data = {}}: PoolBarProps) => {
const {Usage: usage = 0} = data;
const usagePercents = Math.min(usage * 100, 100);
const type = getBarType(usagePercents);
return (
<ContentWithPopup
className={b({type})}
content={<PoolTooltipContent data={data} className={b('popup-content')} />}
>
<div style={{height: `${usagePercents}%`}} className={b('value', {type})} />
</ContentWithPopup>
);
};