Skip to content

Commit 6068424

Browse files
authored
Merge branch 'main' into add-types-constants-922
2 parents 68dcb08 + dec5b95 commit 6068424

File tree

26 files changed

+205
-90
lines changed

26 files changed

+205
-90
lines changed

.github/workflows/quality.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- name: Upload Playwright artifacts
4949
if: always()
50-
uses: actions/upload-artifact@v3
50+
uses: actions/upload-artifact@v4
5151
with:
5252
name: playwright-artifacts
5353
path: playwright-artifacts
@@ -177,7 +177,7 @@ jobs:
177177
git --work-tree=gh-pages checkout gh-pages -- .
178178
179179
- name: Download Playwright artifacts
180-
uses: actions/download-artifact@v3
180+
uses: actions/download-artifact@v4
181181
with:
182182
name: playwright-artifacts
183183
path: playwright-artifacts
@@ -219,7 +219,7 @@ jobs:
219219
fetch-depth: 0
220220

221221
- name: Download Playwright artifacts
222-
uses: actions/download-artifact@v3
222+
uses: actions/download-artifact@v4
223223
with:
224224
name: playwright-artifacts
225225
path: playwright-artifacts

src/components/BasicNodeViewer/BasicNodeViewer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import React from 'react';
33
import {ArrowUpRightFromSquare} from '@gravity-ui/icons';
44
import {Icon} from '@gravity-ui/uikit';
55

6+
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
67
import type {PreparedNode} from '../../store/reducers/node/types';
78
import type {AdditionalNodesProps} from '../../types/additionalProps';
89
import {cn} from '../../utils/cn';
910
import {
1011
createDeveloperUIInternalPageHref,
1112
createDeveloperUILinkWithNodeId,
1213
} from '../../utils/developerUI/developerUI';
14+
import {useTypedSelector} from '../../utils/hooks';
1315
import {EntityStatus} from '../EntityStatus/EntityStatus';
1416
import {Tags} from '../Tags';
1517

@@ -24,6 +26,8 @@ interface BasicNodeViewerProps {
2426
}
2527

2628
export const BasicNodeViewer = ({node, additionalNodesProps, className}: BasicNodeViewerProps) => {
29+
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
30+
2731
let developerUIInternalHref: string | undefined;
2832

2933
if (additionalNodesProps?.getNodeRef) {
@@ -42,7 +46,7 @@ export const BasicNodeViewer = ({node, additionalNodesProps, className}: BasicNo
4246
<React.Fragment>
4347
<div className={b('title')}>Node</div>
4448
<EntityStatus status={node.SystemState} name={node.Host} />
45-
{developerUIInternalHref && (
49+
{developerUIInternalHref && isUserAllowedToMakeChanges ? (
4650
<a
4751
rel="noopener noreferrer"
4852
className={b('link', {external: true})}
@@ -51,7 +55,7 @@ export const BasicNodeViewer = ({node, additionalNodesProps, className}: BasicNo
5155
>
5256
<Icon data={ArrowUpRightFromSquare} />
5357
</a>
54-
)}
58+
) : null}
5559

5660
<div className={b('id')}>
5761
<label className={b('label')}>NodeID</label>

src/components/PDiskPopup/PDiskPopup.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
4-
import {selectNodeHostsMap} from '../../store/reducers/nodesList';
4+
import {selectNodesMap} from '../../store/reducers/nodesList';
55
import {EFlag} from '../../types/api/enums';
66
import {valueIsDefined} from '../../utils';
77
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
@@ -17,7 +17,7 @@ const errorColors = [EFlag.Orange, EFlag.Red, EFlag.Yellow];
1717

1818
export const preparePDiskData = (
1919
data: PreparedPDisk,
20-
nodeHost?: string,
20+
nodeData?: {Host?: string; DC?: string},
2121
withDeveloperUILink?: boolean,
2222
) => {
2323
const {
@@ -46,8 +46,11 @@ export const preparePDiskData = (
4646
pdiskData.push({label: 'Node Id', value: NodeId});
4747
}
4848

49-
if (nodeHost) {
50-
pdiskData.push({label: 'Host', value: nodeHost});
49+
if (nodeData?.Host) {
50+
pdiskData.push({label: 'Host', value: nodeData.Host});
51+
}
52+
if (nodeData?.DC) {
53+
pdiskData.push({label: 'DC', value: nodeData.DC});
5154
}
5255

5356
if (Path) {
@@ -90,11 +93,11 @@ interface PDiskPopupProps {
9093

9194
export const PDiskPopup = ({data}: PDiskPopupProps) => {
9295
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
93-
const nodeHostsMap = useTypedSelector(selectNodeHostsMap);
94-
const nodeHost = valueIsDefined(data.NodeId) ? nodeHostsMap?.get(data.NodeId) : undefined;
96+
const nodesMap = useTypedSelector(selectNodesMap);
97+
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
9598
const info = React.useMemo(
96-
() => preparePDiskData(data, nodeHost, isUserAllowedToMakeChanges),
97-
[data, nodeHost, isUserAllowedToMakeChanges],
99+
() => preparePDiskData(data, nodeData, isUserAllowedToMakeChanges),
100+
[data, nodeData, isUserAllowedToMakeChanges],
98101
);
99102

100103
return <InfoViewer title="PDisk" info={info} size="s" />;

src/components/VDiskPopup/VDiskPopup.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import {Label} from '@gravity-ui/uikit';
44

55
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
6-
import {selectNodeHostsMap} from '../../store/reducers/nodesList';
6+
import {selectNodesMap} from '../../store/reducers/nodesList';
77
import {EFlag} from '../../types/api/enums';
88
import {valueIsDefined} from '../../utils';
99
import {cn} from '../../utils/cn';
@@ -188,14 +188,14 @@ export const VDiskPopup = ({data}: VDiskPopupProps) => {
188188
[data, isFullData, isUserAllowedToMakeChanges],
189189
);
190190

191-
const nodeHostsMap = useTypedSelector(selectNodeHostsMap);
192-
const nodeHost = valueIsDefined(data.NodeId) ? nodeHostsMap?.get(data.NodeId) : undefined;
191+
const nodesMap = useTypedSelector(selectNodesMap);
192+
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
193193
const pdiskInfo = React.useMemo(
194194
() =>
195195
isFullData &&
196196
data.PDisk &&
197-
preparePDiskData(data.PDisk, nodeHost, isUserAllowedToMakeChanges),
198-
[data, nodeHost, isFullData, isUserAllowedToMakeChanges],
197+
preparePDiskData(data.PDisk, nodeData, isUserAllowedToMakeChanges),
198+
[data, nodeData, isFullData, isUserAllowedToMakeChanges],
199199
);
200200

201201
const donorsInfo: InfoViewerItem[] = [];

src/containers/Header/Header.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Breadcrumbs} from '@gravity-ui/uikit';
44

55
import {InternalLink} from '../../components/InternalLink';
66
import {LinkWithIcon} from '../../components/LinkWithIcon/LinkWithIcon';
7+
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
78
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
89
import {cn} from '../../utils/cn';
910
import {DEVELOPER_UI_TITLE} from '../../utils/constants';
@@ -23,6 +24,7 @@ interface HeaderProps {
2324

2425
function Header({mainPage}: HeaderProps) {
2526
const {page, pageBreadcrumbsOptions} = useTypedSelector((state) => state.header);
27+
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
2628

2729
const clusterInfo = useClusterBaseInfo();
2830

@@ -78,10 +80,12 @@ function Header({mainPage}: HeaderProps) {
7880
}}
7981
/>
8082

81-
<LinkWithIcon
82-
title={DEVELOPER_UI_TITLE}
83-
url={createDeveloperUIInternalPageHref()}
84-
/>
83+
{isUserAllowedToMakeChanges ? (
84+
<LinkWithIcon
85+
title={DEVELOPER_UI_TITLE}
86+
url={createDeveloperUIInternalPageHref()}
87+
/>
88+
) : null}
8589
</header>
8690
);
8791
};

src/containers/Node/NodeStructure/Pdisk.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {PDiskInfo} from '../../../components/PDiskInfo/PDiskInfo';
1010
import {ProgressViewer} from '../../../components/ProgressViewer/ProgressViewer';
1111
import {StatusIcon} from '../../../components/StatusIcon/StatusIcon';
1212
import {VDiskInfo} from '../../../components/VDiskInfo/VDiskInfo';
13+
import {selectIsUserAllowedToMakeChanges} from '../../../store/reducers/authentication/authentication';
1314
import type {
1415
PreparedStructurePDisk,
1516
PreparedStructureVDisk,
@@ -22,6 +23,7 @@ import {cn} from '../../../utils/cn';
2223
import {DEFAULT_TABLE_SETTINGS} from '../../../utils/constants';
2324
import {formatStorageValuesToGb} from '../../../utils/dataFormatters/dataFormatters';
2425
import {createVDiskDeveloperUILink} from '../../../utils/developerUI/developerUI';
26+
import {useTypedSelector} from '../../../utils/hooks';
2527
import i18n from '../i18n';
2628

2729
import {PDiskTitleBadge} from './PDiskTitleBadge';
@@ -56,10 +58,12 @@ function getColumns({
5658
pDiskId,
5759
selectedVdiskId,
5860
nodeId,
61+
withDeveloperUILink,
5962
}: {
6063
pDiskId: number | undefined;
6164
selectedVdiskId?: string;
6265
nodeId?: string | number;
66+
withDeveloperUILink?: boolean;
6367
}) {
6468
const columns: Column<PreparedStructureVDisk>[] = [
6569
{
@@ -85,7 +89,7 @@ function getColumns({
8589
return (
8690
<div className={b('vdisk-id', {selected: row.id === selectedVdiskId})}>
8791
<span>{vDiskSlotId}</span>
88-
{vdiskInternalViewerLink && (
92+
{vdiskInternalViewerLink && withDeveloperUILink ? (
8993
<Button
9094
size="s"
9195
className={b('external-button', {hidden: true})}
@@ -95,7 +99,7 @@ function getColumns({
9599
>
96100
<Icon data={ArrowUpRightFromSquare} />
97101
</Button>
98-
)}
102+
) : null}
99103
</div>
100104
);
101105
},
@@ -167,6 +171,8 @@ export function PDisk({
167171
nodeId,
168172
unfolded: unfoldedFromProps,
169173
}: PDiskProps) {
174+
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
175+
170176
const [unfolded, setUnfolded] = React.useState(unfoldedFromProps ?? false);
171177

172178
const {TotalSize = 0, AvailableSize = 0, Device, PDiskId, Type, vDisks} = data;
@@ -186,7 +192,12 @@ export function PDisk({
186192
<DataTable
187193
theme="yandex-cloud"
188194
data={vDisks}
189-
columns={getColumns({nodeId, pDiskId: PDiskId, selectedVdiskId})}
195+
columns={getColumns({
196+
nodeId,
197+
pDiskId: PDiskId,
198+
selectedVdiskId,
199+
withDeveloperUILink: isUserAllowedToMakeChanges,
200+
})}
190201
settings={{...DEFAULT_TABLE_SETTINGS, dynamicRender: false}}
191202
rowClassName={(row) => {
192203
return row.id === selectedVdiskId ? b('selected-vdisk') : '';

src/containers/Storage/Disks/Disks.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
display: flex;
1111
flex-direction: row;
1212
justify-content: left;
13-
gap: 6px;
1413

1514
width: max-content;
1615
}
@@ -27,6 +26,15 @@
2726

2827
&__pdisk-item {
2928
min-width: 80px;
29+
margin-right: 4px;
30+
31+
&_with-dc-margin {
32+
margin-right: 12px;
33+
}
34+
35+
&:last-child {
36+
margin-right: 0;
37+
}
3038
}
3139
&__pdisk-progress-bar {
3240
--progress-bar-full-height: 20px;

src/containers/Storage/Disks/Disks.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {cn} from '../../../utils/cn';
88
import type {PreparedVDisk} from '../../../utils/disks/types';
99
import {PDisk} from '../PDisk';
1010
import type {StorageViewContext} from '../types';
11-
import {isVdiskActive} from '../utils';
11+
import {isVdiskActive, useVDisksWithDCMargins} from '../utils';
1212

1313
import './Disks.scss';
1414

@@ -24,6 +24,8 @@ interface DisksProps {
2424
export function Disks({vDisks = [], viewContext}: DisksProps) {
2525
const [highlightedVDisk, setHighlightedVDisk] = React.useState<string | undefined>();
2626

27+
const vDisksWithDCMargins = useVDisksWithDCMargins(vDisks);
28+
2729
const {
2830
theme: {spaceBaseSize},
2931
} = useLayoutContext();
@@ -51,12 +53,13 @@ export function Disks({vDisks = [], viewContext}: DisksProps) {
5153
</Flex>
5254

5355
<div className={b('pdisks-wrapper')}>
54-
{vDisks?.map((vDisk) => (
56+
{vDisks?.map((vDisk, index) => (
5557
<PDiskItem
5658
key={vDisk?.PDisk?.StringifiedId}
5759
vDisk={vDisk}
5860
highlightedVDisk={highlightedVDisk}
5961
setHighlightedVDisk={setHighlightedVDisk}
62+
withDCMargin={vDisksWithDCMargins.includes(index)}
6063
/>
6164
))}
6265
</div>
@@ -70,6 +73,7 @@ interface DisksItemProps {
7073
highlightedVDisk: string | undefined;
7174
setHighlightedVDisk: (id: string | undefined) => void;
7275
unavailableVDiskWidth?: number;
76+
withDCMargin?: boolean;
7377
}
7478

7579
function VDiskItem({
@@ -103,7 +107,7 @@ function VDiskItem({
103107
);
104108
}
105109

106-
function PDiskItem({vDisk, highlightedVDisk, setHighlightedVDisk}: DisksItemProps) {
110+
function PDiskItem({vDisk, highlightedVDisk, setHighlightedVDisk, withDCMargin}: DisksItemProps) {
107111
const vDiskId = vDisk.StringifiedId;
108112

109113
if (!vDisk.PDisk) {
@@ -112,7 +116,7 @@ function PDiskItem({vDisk, highlightedVDisk, setHighlightedVDisk}: DisksItemProp
112116

113117
return (
114118
<PDisk
115-
className={b('pdisk-item')}
119+
className={b('pdisk-item', {['with-dc-margin']: withDCMargin})}
116120
progressBarClassName={b('pdisk-progress-bar')}
117121
data={vDisk.PDisk}
118122
showPopup={highlightedVDisk === vDiskId}

src/containers/Storage/StorageGroups/columns/StorageGroupsColumns.scss

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@
44
overflow: visible; // to enable stacked disks overflow the row
55
}
66

7-
&__vdisks-wrapper {
8-
display: flex;
9-
justify-content: center;
10-
gap: 10px;
11-
12-
min-width: 500px;
13-
}
14-
&__vdisks-item {
15-
flex-grow: 1;
16-
17-
max-width: 200px;
18-
19-
.stack__layer {
20-
.data-table__row:hover & {
21-
background: var(--ydb-data-table-color-hover);
22-
}
23-
}
24-
}
25-
267
&__pool-name-wrapper {
278
overflow: hidden;
289

src/containers/Storage/StorageGroups/columns/columns.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {CellWithPopover} from '../../../../components/CellWithPopover/CellWithPo
88
import {InternalLink} from '../../../../components/InternalLink';
99
import {StatusIcon} from '../../../../components/StatusIcon/StatusIcon';
1010
import {UsageLabel} from '../../../../components/UsageLabel/UsageLabel';
11-
import {VDiskWithDonorsStack} from '../../../../components/VDisk/VDiskWithDonorsStack';
1211
import {getStorageGroupPath} from '../../../../routes';
1312
import {valueIsDefined} from '../../../../utils';
1413
import {cn} from '../../../../utils/cn';
@@ -18,7 +17,8 @@ import {getUsageSeverity} from '../../../../utils/generateEvaluator';
1817
import {formatToMs} from '../../../../utils/timeParsers';
1918
import {bytesToGB, bytesToSpeed} from '../../../../utils/utils';
2019
import {Disks} from '../../Disks/Disks';
21-
import {getDegradedSeverity, isVdiskActive} from '../../utils';
20+
import {VDisks} from '../../VDisks/VDisks';
21+
import {getDegradedSeverity} from '../../utils';
2222
import i18n from '../i18n';
2323

2424
import {
@@ -230,18 +230,7 @@ const getVDisksColumn = (data?: GetStorageColumnsData): StorageGroupsColumn => (
230230
name: STORAGE_GROUPS_COLUMNS_IDS.VDisks,
231231
header: STORAGE_GROUPS_COLUMNS_TITLES.VDisks,
232232
className: b('vdisks-column'),
233-
render: ({row}) => (
234-
<div className={b('vdisks-wrapper')}>
235-
{row.VDisks?.map((vDisk) => (
236-
<VDiskWithDonorsStack
237-
key={vDisk.StringifiedId}
238-
data={vDisk}
239-
inactive={!isVdiskActive(vDisk, data?.viewContext)}
240-
className={b('vdisks-item')}
241-
/>
242-
))}
243-
</div>
244-
),
233+
render: ({row}) => <VDisks vDisks={row.VDisks} viewContext={data?.viewContext} />,
245234
align: DataTable.CENTER,
246235
width: 900,
247236
resizeable: false,

0 commit comments

Comments
 (0)