Skip to content

Commit 0818669

Browse files
authored
Merge branch 'main' into astandrik.nodes-list-stops-working-1383
2 parents 83bdaaf + d254ee2 commit 0818669

File tree

28 files changed

+177
-119
lines changed

28 files changed

+177
-119
lines changed

src/components/VDisk/VDisk.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import routes, {createHref, getVDiskPagePath} from '../../routes';
55
import {useDiskPagesAvailable} from '../../store/reducers/capabilities/hooks';
66
import {valueIsDefined} from '../../utils';
77
import {cn} from '../../utils/cn';
8-
import {stringifyVdiskId} from '../../utils/dataFormatters/dataFormatters';
98
import {isFullVDiskData} from '../../utils/disks/helpers';
109
import type {PreparedVDisk} from '../../utils/disks/types';
1110
import {DiskStateProgressBar} from '../DiskStateProgressBar/DiskStateProgressBar';
@@ -68,7 +67,7 @@ export const VDisk = ({
6867
{id: data.NodeId, activeTab: STRUCTURE},
6968
{
7069
pdiskId: data.PDiskId,
71-
vdiskId: stringifyVdiskId(data.VDiskId),
70+
vdiskId: data.StringifiedId,
7271
},
7372
);
7473
}

src/components/VDiskInfo/VDiskInfo.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {getVDiskPagePath} from '../../routes';
44
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
55
import {valueIsDefined} from '../../utils';
66
import {cn} from '../../utils/cn';
7-
import {formatStorageValuesToGb, stringifyVdiskId} from '../../utils/dataFormatters/dataFormatters';
7+
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters';
88
import {createVDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
99
import {getSeverityColor} from '../../utils/disks/helpers';
1010
import type {PreparedVDisk} from '../../utils/disks/types';
@@ -201,10 +201,7 @@ function VDiskTitle<T extends PreparedVDisk>({data}: VDiskTitleProps<T>) {
201201
return (
202202
<div className={b('title')}>
203203
{vDiskInfoKeyset('vdiks-title')}
204-
<EntityStatus
205-
status={getSeverityColor(data.Severity)}
206-
name={stringifyVdiskId(data.VDiskId)}
207-
/>
204+
<EntityStatus status={getSeverityColor(data.Severity)} name={data.StringifiedId} />
208205
</div>
209206
);
210207
}

src/components/VDiskPopup/VDiskPopup.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import {Label, Popup} from '@gravity-ui/uikit';
55

66
import {selectNodeHostsMap} from '../../store/reducers/nodesList';
77
import {EFlag} from '../../types/api/enums';
8-
import type {TVDiskStateInfo} from '../../types/api/vdisk';
98
import {valueIsDefined} from '../../utils';
109
import {cn} from '../../utils/cn';
1110
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
12-
import {stringifyVdiskId} from '../../utils/dataFormatters/dataFormatters';
1311
import {isFullVDiskData} from '../../utils/disks/helpers';
14-
import type {UnavailableDonor} from '../../utils/disks/types';
12+
import type {PreparedVDisk, UnavailableDonor} from '../../utils/disks/types';
1513
import {useTypedSelector} from '../../utils/hooks';
1614
import {bytesToGB, bytesToSpeed} from '../../utils/utils';
1715
import type {InfoViewerItem} from '../InfoViewer';
@@ -40,9 +38,9 @@ const prepareUnavailableVDiskData = (data: UnavailableDonor) => {
4038
return vdiskData;
4139
};
4240

43-
const prepareVDiskData = (data: TVDiskStateInfo) => {
41+
const prepareVDiskData = (data: PreparedVDisk) => {
4442
const {
45-
VDiskId,
43+
StringifiedId,
4644
VDiskState,
4745
SatisfactionRank,
4846
DiskSpace,
@@ -56,7 +54,7 @@ const prepareVDiskData = (data: TVDiskStateInfo) => {
5654
} = data;
5755

5856
const vdiskData: InfoViewerItem[] = [
59-
{label: 'VDisk', value: stringifyVdiskId(VDiskId)},
57+
{label: 'VDisk', value: StringifiedId},
6058
{label: 'State', value: VDiskState ?? 'not available'},
6159
];
6260

@@ -130,7 +128,7 @@ const prepareVDiskData = (data: TVDiskStateInfo) => {
130128
};
131129

132130
interface VDiskPopupProps extends PopupProps {
133-
data: TVDiskStateInfo | UnavailableDonor;
131+
data: PreparedVDisk | UnavailableDonor;
134132
}
135133

136134
export const VDiskPopup = ({data, ...props}: VDiskPopupProps) => {

src/components/nodesColumns/columns.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import DataTable from '@gravity-ui/react-data-table';
33
import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils';
44
import type {TPoolStats} from '../../types/api/nodes';
55
import type {TTabletStateInfo} from '../../types/api/tablet';
6+
import {valueIsDefined} from '../../utils';
67
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
78
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters';
9+
import {getSpaceUsageSeverity} from '../../utils/storage';
810
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
911
import {NodeHostWrapper} from '../NodeHostWrapper/NodeHostWrapper';
1012
import type {NodeHostData} from '../NodeHostWrapper/NodeHostWrapper';
@@ -184,6 +186,25 @@ export function getLoadColumn<T extends {LoadAveragePercents?: number[]}>(): Col
184186
resizeMinWidth: 70,
185187
};
186188
}
189+
export function getDiskSpaceUsageColumn<T extends {DiskSpaceUsage?: number}>(): Column<T> {
190+
return {
191+
name: NODES_COLUMNS_IDS.DiskSpaceUsage,
192+
header: NODES_COLUMNS_TITLES.DiskSpaceUsage,
193+
render: ({row}) => {
194+
return valueIsDefined(row.DiskSpaceUsage) ? (
195+
<UsageLabel
196+
value={Math.floor(row.DiskSpaceUsage)}
197+
theme={getSpaceUsageSeverity(row.DiskSpaceUsage)}
198+
/>
199+
) : (
200+
EMPTY_DATA_PLACEHOLDER
201+
);
202+
},
203+
align: DataTable.LEFT,
204+
width: 115,
205+
resizeMinWidth: 75,
206+
};
207+
}
187208
export function getSessionsColumn<T extends {TotalSessions?: number}>(): Column<T> {
188209
return {
189210
name: NODES_COLUMNS_IDS.TotalSessions,

src/components/nodesColumns/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const NODES_COLUMNS_IDS = {
1616
CPU: 'CPU',
1717
LoadAverage: 'LoadAverage',
1818
Load: 'Load',
19+
DiskSpaceUsage: 'DiskSpaceUsage',
1920
SharedCacheUsage: 'SharedCacheUsage',
2021
TotalSessions: 'TotalSessions',
2122
Missing: 'Missing',
@@ -60,6 +61,9 @@ export const NODES_COLUMNS_TITLES = {
6061
get Load() {
6162
return i18n('load');
6263
},
64+
get DiskSpaceUsage() {
65+
return i18n('disk-usage');
66+
},
6367
get SharedCacheUsage() {
6468
return i18n('caches');
6569
},

src/components/nodesColumns/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"uptime": "Uptime",
99
"memory": "Memory",
1010
"cpu": "CPU",
11+
"disk-usage": "Disk usage",
1112
"tablets": "Tablets",
1213
"load-average": "Load Average",
1314
"load": "Load",

src/containers/Authentication/Authentication.tsx

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Authentication({closable = false}: AuthenticationProps) {
2424
const history = useHistory();
2525
const location = useLocation();
2626

27-
const [authenticate, {error, isLoading}] = authenticationApi.useAuthenticateMutation(undefined);
27+
const [authenticate, {isLoading}] = authenticationApi.useAuthenticateMutation(undefined);
2828

2929
const {returnUrl} = parseQuery(location);
3030

@@ -34,15 +34,6 @@ function Authentication({closable = false}: AuthenticationProps) {
3434
const [passwordError, setPasswordError] = React.useState('');
3535
const [showPassword, setShowPassword] = React.useState(false);
3636

37-
React.useEffect(() => {
38-
if (isUserError(error)) {
39-
setLoginError(error.data.error);
40-
}
41-
if (isPasswordError(error)) {
42-
setPasswordError(error.data.error);
43-
}
44-
}, [error]);
45-
4637
const onLoginUpdate = (value: string) => {
4738
setLogin(value);
4839
setLoginError('');
@@ -54,18 +45,28 @@ function Authentication({closable = false}: AuthenticationProps) {
5445
};
5546

5647
const onLoginClick = () => {
57-
authenticate({user: login, password}).then(() => {
58-
if (returnUrl) {
59-
const decodedUrl = decodeURIComponent(returnUrl.toString());
60-
61-
// to prevent page reload we use router history
62-
// history navigates relative to origin
63-
// so we remove origin to make it work properly
64-
const url = new URL(decodedUrl);
65-
const path = url.pathname + url.search;
66-
history.replace(path);
67-
}
68-
});
48+
authenticate({user: login, password})
49+
.unwrap()
50+
.then(() => {
51+
if (returnUrl) {
52+
const decodedUrl = decodeURIComponent(returnUrl.toString());
53+
54+
// to prevent page reload we use router history
55+
// history navigates relative to origin
56+
// so we remove origin to make it work properly
57+
const url = new URL(decodedUrl);
58+
const path = url.pathname + url.search;
59+
history.replace(path);
60+
}
61+
})
62+
.catch((error) => {
63+
if (isUserError(error)) {
64+
setLoginError(error.data.error);
65+
}
66+
if (isPasswordError(error)) {
67+
setPasswordError(error.data.error);
68+
}
69+
});
6970
};
7071

7172
const onEnterClick = (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {

src/containers/Storage/Disks/Disks.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22

33
import {VDiskWithDonorsStack} from '../../../components/VDisk/VDiskWithDonorsStack';
44
import {cn} from '../../../utils/cn';
5-
import {stringifyVdiskId} from '../../../utils/dataFormatters/dataFormatters';
65
import {getPDiskId} from '../../../utils/disks/helpers';
76
import type {PreparedVDisk} from '../../../utils/disks/types';
87
import {PDisk} from '../PDisk';
@@ -30,7 +29,7 @@ export function Disks({vDisks = [], viewContext}: DisksProps) {
3029
<div className={b('vdisks-wrapper')}>
3130
{vDisks?.map((vDisk) => (
3231
<VDiskItem
33-
key={stringifyVdiskId(vDisk.VDiskId)}
32+
key={vDisk.StringifiedId}
3433
vDisk={vDisk}
3534
inactive={!isVdiskActive(vDisk, viewContext)}
3635
highlightedVDisk={highlightedVDisk}
@@ -64,7 +63,7 @@ function VDiskItem({vDisk, highlightedVDisk, inactive, setHighlightedVDisk}: Dis
6463
// Do not show PDisk popup for VDisk
6564
const vDiskToShow = {...vDisk, PDisk: undefined};
6665

67-
const vDiskId = stringifyVdiskId(vDisk.VDiskId);
66+
const vDiskId = vDisk.StringifiedId;
6867

6968
return (
7069
<div
@@ -87,7 +86,7 @@ function VDiskItem({vDisk, highlightedVDisk, inactive, setHighlightedVDisk}: Dis
8786
}
8887

8988
function PDiskItem({vDisk, highlightedVDisk, setHighlightedVDisk}: DisksItemProps) {
90-
const vDiskId = stringifyVdiskId(vDisk.VDiskId);
89+
const vDiskId = vDisk.StringifiedId;
9190

9291
if (!vDisk.PDisk) {
9392
return null;

src/containers/Storage/PDisk/PDisk.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import routes, {createHref, getPDiskPagePath} from '../../../routes';
88
import {useDiskPagesAvailable} from '../../../store/reducers/capabilities/hooks';
99
import {valueIsDefined} from '../../../utils';
1010
import {cn} from '../../../utils/cn';
11-
import {stringifyVdiskId} from '../../../utils/dataFormatters/dataFormatters';
1211
import type {PreparedPDisk, PreparedVDisk} from '../../../utils/disks/types';
1312
import {STRUCTURE} from '../../Node/NodePages';
1413
import type {StorageViewContext} from '../types';
@@ -68,7 +67,7 @@ export const PDisk = ({
6867
{vDisks.map((vdisk) => {
6968
return (
7069
<div
71-
key={stringifyVdiskId(vdisk.VDiskId)}
70+
key={vdisk.StringifiedId}
7271
className={b('vdisks-item')}
7372
style={{
7473
// 1 is small enough for empty disks to be of the minimum width

src/containers/Storage/StorageControls/StorageControls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function StorageGroupsControls({
8888
<Select
8989
hasClear
9090
placeholder={'-'}
91-
width={170}
91+
width={150}
9292
defaultValue={
9393
storageGroupsGroupByParam ? [storageGroupsGroupByParam] : undefined
9494
}
@@ -168,7 +168,7 @@ export function StorageNodesControls({
168168
<Select
169169
hasClear
170170
placeholder={'-'}
171-
width={170}
171+
width={150}
172172
defaultValue={
173173
storageNodesGroupByParam ? [storageNodesGroupByParam] : undefined
174174
}

0 commit comments

Comments
 (0)