Skip to content

Commit ea7ea88

Browse files
feat: add VDisk page (#773)
1 parent 4b46f38 commit ea7ea88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1060
-288
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@import '../../styles/mixins.scss';
2+
3+
.ydb-disk-page-title {
4+
display: flex;
5+
flex-flow: row nowrap;
6+
align-items: baseline;
7+
8+
text-wrap: nowrap;
9+
10+
@include header-2-typography();
11+
12+
&__prefix {
13+
margin-right: 6px;
14+
15+
color: var(--g-color-text-secondary);
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type {ReactNode} from 'react';
2+
3+
import type {EFlag} from '../../types/api/enums';
4+
import {cn} from '../../utils/cn';
5+
import {StatusIcon} from '../StatusIcon/StatusIcon';
6+
7+
import './DiskPageTitle.scss';
8+
9+
const b = cn('ydb-disk-page-title');
10+
11+
interface DiskPageTitleProps {
12+
entityName: ReactNode;
13+
status: EFlag;
14+
id: ReactNode;
15+
className?: string;
16+
}
17+
18+
export function DiskPageTitle({entityName, status, id, className}: DiskPageTitleProps) {
19+
return (
20+
<div className={b(null, className)}>
21+
<span className={b('prefix')}>{entityName}</span>
22+
<StatusIcon status={status} size="s" />
23+
{id}
24+
</div>
25+
);
26+
}

src/containers/Storage/DiskStateProgressBar/DiskStateProgressBar.tsx renamed to src/components/DiskStateProgressBar/DiskStateProgressBar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import cn from 'bem-cn-lite';
33

4-
import {INVERTED_DISKS_KEY} from '../../../utils/constants';
5-
import {useSetting} from '../../../utils/hooks';
6-
import {getSeverityColor} from '../../../utils/disks/helpers';
4+
import {INVERTED_DISKS_KEY} from '../../utils/constants';
5+
import {useSetting} from '../../utils/hooks';
6+
import {getSeverityColor} from '../../utils/disks/helpers';
77

88
import './DiskStateProgressBar.scss';
99

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import type {PreparedStorageGroup} from '../../store/reducers/storage/types';
2+
import {valueIsDefined} from '../../utils';
3+
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters';
4+
5+
import type {InfoViewerProps} from '../InfoViewer/InfoViewer';
6+
import {InfoViewer} from '../InfoViewer';
7+
import {ProgressViewer} from '../ProgressViewer/ProgressViewer';
8+
import {groupInfoKeyset} from './i18n';
9+
10+
interface GroupInfoProps<T extends Partial<PreparedStorageGroup>>
11+
extends Omit<InfoViewerProps, 'info'> {
12+
data: T;
13+
}
14+
15+
export function GroupInfo<T extends Partial<PreparedStorageGroup>>({
16+
data,
17+
...infoViewerProps
18+
}: GroupInfoProps<T>) {
19+
const {GroupID, PoolName, Used, Limit, ErasureSpecies} = data;
20+
21+
const groupInfo = [];
22+
23+
if (valueIsDefined(GroupID)) {
24+
groupInfo.push({label: groupInfoKeyset('group-id'), value: GroupID});
25+
}
26+
if (valueIsDefined(PoolName)) {
27+
groupInfo.push({label: groupInfoKeyset('pool-name'), value: PoolName});
28+
}
29+
if (valueIsDefined(ErasureSpecies)) {
30+
groupInfo.push({label: groupInfoKeyset('erasure'), value: ErasureSpecies});
31+
}
32+
if (Number(Used) >= 0 && Number(Limit) >= 0) {
33+
groupInfo.push({
34+
label: groupInfoKeyset('size'),
35+
value: (
36+
<ProgressViewer
37+
value={Used}
38+
capacity={Limit}
39+
formatValues={formatStorageValuesToGb}
40+
colorizeProgress={true}
41+
/>
42+
),
43+
});
44+
}
45+
46+
return <InfoViewer info={groupInfo} {...infoViewerProps} />;
47+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"group-id": "Group ID",
3+
"pool-name": "Storage Pool Name",
4+
"size": "Size",
5+
"erasure": "Erasure"
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-group-info';
6+
7+
export const groupInfoKeyset = registerKeysets(COMPONENT, {en});

src/containers/Storage/PDiskPopup/PDiskPopup.tsx renamed to src/components/PDiskPopup/PDiskPopup.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import cn from 'bem-cn-lite';
33

44
import {Popup, PopupProps} from '@gravity-ui/uikit';
55

6-
import type {NodesMap} from '../../../types/store/nodesList';
6+
import type {NodesMap} from '../../types/store/nodesList';
7+
import {EFlag} from '../../types/api/enums';
8+
import type {PreparedPDisk} from '../../utils/disks/types';
9+
import {getPDiskId} from '../../utils/dataFormatters/dataFormatters';
10+
import {bytesToGB} from '../../utils/utils';
11+
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
712

8-
import {InfoViewer, InfoViewerItem} from '../../../components/InfoViewer';
9-
10-
import {EFlag} from '../../../types/api/enums';
11-
import type {PreparedPDisk} from '../../../utils/disks/types';
12-
import {getPDiskId} from '../../../utils/dataFormatters/dataFormatters';
13-
import {bytesToGB} from '../../../utils/utils';
13+
import {InfoViewer, InfoViewerItem} from '../InfoViewer';
1414

1515
import './PDiskPopup.scss';
1616

@@ -22,7 +22,7 @@ export const preparePDiskData = (data: PreparedPDisk, nodes?: NodesMap) => {
2222
const {AvailableSize, TotalSize, State, PDiskId, NodeId, Path, Realtime, Type, Device} = data;
2323

2424
const pdiskData: InfoViewerItem[] = [
25-
{label: 'PDisk', value: getPDiskId({NodeId, PDiskId}) || '-'},
25+
{label: 'PDisk', value: getPDiskId({NodeId, PDiskId}) || EMPTY_DATA_PLACEHOLDER},
2626
{label: 'State', value: State || 'not available'},
2727
{label: 'Type', value: Type || 'unknown'},
2828
];

src/components/PageMeta/PageMeta.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
display: flex;
55
flex-flow: row nowrap;
66

7+
height: var(--g-text-body-2-line-height);
8+
9+
text-wrap: nowrap;
10+
711
color: var(--g-color-text-primary);
812

913
@include body-2-typography();
14+
15+
&__skeleton {
16+
width: 80%;
17+
height: 80%;
18+
}
1019
}

0 commit comments

Comments
 (0)