Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ErrorBoundary/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function getBackendVersion() {
// node_id=. returns data about node that fullfills request
// normally this request should be fast (200-300ms with good connection)
// timeout=1000 in order not to wait too much in case everything is broken
const data = await window.api.viewer.getNodeInfo('.', {timeout: 1000});
const data = await window.api.viewer.getNodeInfo({nodeId: '.'}, {timeout: 1000});
return data?.SystemStateInfo?.[0]?.Version;
} catch (error) {
return {error: prepareErrorMessage(error)};
Expand Down
12 changes: 12 additions & 0 deletions src/components/NodeId/NodeId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {getDefaultNodePath} from '../../containers/Node/NodePages';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {InternalLink} from '../InternalLink';

interface NodeIdProps {
id: string | number;
}

export function NodeId({id}: NodeIdProps) {
const database = useDatabaseFromQuery();
return <InternalLink to={getDefaultNodePath(id, {database})}>{id}</InternalLink>;
}
4 changes: 3 additions & 1 deletion src/components/PDiskPopup/PDiskPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
import {createPDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
import type {PreparedPDisk} from '../../utils/disks/types';
import {useTypedSelector} from '../../utils/hooks';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
import {bytesToGB, isNumeric} from '../../utils/utils';
import {InfoViewer} from '../InfoViewer';
Expand Down Expand Up @@ -109,8 +110,9 @@ interface PDiskPopupProps {
}

export const PDiskPopup = ({data}: PDiskPopupProps) => {
const database = useDatabaseFromQuery();
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
const nodesMap = useTypedSelector(selectNodesMap);
const nodesMap = useTypedSelector((state) => selectNodesMap(state, database));
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
const info = React.useMemo(
() => preparePDiskData(data, nodeData, isUserAllowedToMakeChanges),
Expand Down
8 changes: 4 additions & 4 deletions src/components/ShardsTable/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import DataTable from '@gravity-ui/react-data-table';

import {getDefaultNodePath} from '../../containers/Node/NodePages';
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
import {formatNumber, roundToPrecision} from '../../utils/dataFormatters/dataFormatters';
import {getUsageSeverity} from '../../utils/generateEvaluator';
import {InternalLink} from '../InternalLink';
import {LinkToSchemaObject} from '../LinkToSchemaObject/LinkToSchemaObject';
import {NodeId} from '../NodeId/NodeId';
import {TabletNameWrapper} from '../TabletNameWrapper/TabletNameWrapper';
import {UsageLabel} from '../UsageLabel/UsageLabel';

Expand Down Expand Up @@ -39,7 +38,7 @@ export const getDataSizeColumn: GetShardsColumn = () => {
align: DataTable.RIGHT,
};
};
export const getTabletIdColumn: GetShardsColumn = () => {
export const getTabletIdColumn: GetShardsColumn = ({database}) => {
return {
name: TOP_SHARDS_COLUMNS_IDS.TabletId,
header: TOP_SHARDS_COLUMNS_TITLES.TabletId,
Expand All @@ -51,6 +50,7 @@ export const getTabletIdColumn: GetShardsColumn = () => {
<TabletNameWrapper
tabletId={row.TabletId}
followerId={row.FollowerId || undefined}
database={database}
/>
);
},
Expand All @@ -65,7 +65,7 @@ export const getNodeIdColumn: GetShardsColumn = () => {
if (!row.NodeId) {
return EMPTY_DATA_PLACEHOLDER;
}
return <InternalLink to={getDefaultNodePath(row.NodeId)}>{row.NodeId}</InternalLink>;
return <NodeId id={row.NodeId} />;
},
align: DataTable.RIGHT,
};
Expand Down
6 changes: 5 additions & 1 deletion src/components/VDisk/VDisk.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {cn} from '../../utils/cn';
import type {PreparedVDisk} from '../../utils/disks/types';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {DiskStateProgressBar} from '../DiskStateProgressBar/DiskStateProgressBar';
import {HoverPopup} from '../HoverPopup/HoverPopup';
import {InternalLink} from '../InternalLink';
Expand Down Expand Up @@ -34,7 +35,10 @@ export const VDisk = ({
delayClose,
delayOpen,
}: VDiskProps) => {
const vDiskPath = getVDiskLink(data);
const database = useDatabaseFromQuery();
const vDiskPath = getVDiskLink(data, {
database: database,
});

return (
<HoverPopup
Expand Down
27 changes: 6 additions & 21 deletions src/components/VDisk/utils.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import {getVDiskPagePath} from '../../routes';
import {valueIsDefined} from '../../utils';
import type {PreparedVDisk} from '../../utils/disks/types';

export function getVDiskLink(data: PreparedVDisk) {
let vDiskPath: string | undefined;

if (
valueIsDefined(data.VDiskSlotId) &&
valueIsDefined(data.PDiskId) &&
valueIsDefined(data.NodeId)
) {
vDiskPath = getVDiskPagePath({
vDiskSlotId: data.VDiskSlotId,
export function getVDiskLink(data: PreparedVDisk, query: {database: string | undefined}) {
return getVDiskPagePath(
{
pDiskId: data.PDiskId,
nodeId: data.NodeId,
vDiskId: data.StringifiedId,
});
} else if (valueIsDefined(data.StringifiedId)) {
vDiskPath = getVDiskPagePath({
vDiskId: data.StringifiedId,
pDiskId: data.PDiskId,
nodeId: data.NodeId,
});
}

return vDiskPath;
},
query,
);
}
50 changes: 32 additions & 18 deletions src/components/VDiskInfo/VDiskInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {Flex} from '@gravity-ui/uikit';

import {getVDiskPagePath} from '../../routes';
import {getPDiskPagePath, getVDiskPagePath} from '../../routes';
import {EVDiskState} from '../../types/api/vdisk';
import {valueIsDefined} from '../../utils';
import {cn} from '../../utils/cn';
Expand All @@ -13,6 +13,7 @@ import {
import {createVDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
import {getSeverityColor} from '../../utils/disks/helpers';
import type {PreparedVDisk} from '../../utils/disks/types';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
import {bytesToSpeed} from '../../utils/utils';
import {InfoViewer} from '../InfoViewer';
Expand Down Expand Up @@ -44,6 +45,7 @@ export function VDiskInfo<T extends PreparedVDisk>({
wrap,
}: VDiskInfoProps<T>) {
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
const database = useDatabaseFromQuery();

const {
AllocatedSize,
Expand All @@ -66,6 +68,7 @@ export function VDiskInfo<T extends PreparedVDisk>({
ReadThroughput,
WriteThroughput,
PDiskId,
StringifiedId,
NodeId,
} = data || {};

Expand Down Expand Up @@ -166,6 +169,16 @@ export function VDiskInfo<T extends PreparedVDisk>({
if (valueIsDefined(VDiskSlotId)) {
rightColumn.push({label: vDiskInfoKeyset('slot-id'), value: VDiskSlotId});
}
if (valueIsDefined(PDiskId)) {
const pDiskPath = valueIsDefined(NodeId) ? getPDiskPagePath(PDiskId, NodeId) : undefined;

const value = pDiskPath ? <InternalLink to={pDiskPath}>{PDiskId}</InternalLink> : PDiskId;

rightColumn.push({
label: vDiskInfoKeyset('label_pdisk-id'),
value,
});
}

if (valueIsDefined(Kind)) {
rightColumn.push({label: vDiskInfoKeyset('kind'), value: Kind});
Expand All @@ -189,22 +202,20 @@ export function VDiskInfo<T extends PreparedVDisk>({
// Show donors list when replication is in progress
if (Replicated === false && VDiskState === EVDiskState.OK && Donors?.length) {
const donorLinks = Donors.map((donor, index) => {
const {
StringifiedId: id,
NodeId: dNodeId,
PDiskId: dPDiskId,
VDiskSlotId: dVSlotId,
} = donor;
const {StringifiedId: id, NodeId: dNodeId, PDiskId: dPDiskId} = donor;

if (!id || !dVSlotId || !dNodeId || !dPDiskId) {
if (!id || !dNodeId || !dPDiskId) {
return null;
}

const vDiskPath = getVDiskPagePath({
nodeId: dNodeId,
pDiskId: dPDiskId,
vDiskSlotId: dVSlotId,
});
const vDiskPath = getVDiskPagePath(
{
nodeId: dNodeId,
pDiskId: dPDiskId,
vDiskId: id,
},
{database},
);

return (
<InternalLink key={index} to={vDiskPath}>
Expand Down Expand Up @@ -232,11 +243,14 @@ export function VDiskInfo<T extends PreparedVDisk>({
const links: React.ReactNode[] = [];

if (withVDiskPageLink) {
const vDiskPagePath = getVDiskPagePath({
vDiskSlotId: VDiskSlotId,
pDiskId: PDiskId,
nodeId: NodeId,
});
const vDiskPagePath = getVDiskPagePath(
{
pDiskId: PDiskId,
nodeId: NodeId,
vDiskId: StringifiedId,
},
{database},
);
links.push(
<LinkWithIcon
key={vDiskPagePath}
Expand Down
1 change: 1 addition & 0 deletions src/components/VDiskInfo/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"slot-id": "VDisk Slot Id",
"label_pdisk-id": "PDisk Id",
"pool-name": "Storage Pool Name",
"kind": "Kind",

Expand Down
27 changes: 21 additions & 6 deletions src/components/VDiskPopup/VDiskPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {createVDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
import {isFullVDiskData} from '../../utils/disks/helpers';
import type {PreparedVDisk, UnavailableDonor} from '../../utils/disks/types';
import {useTypedSelector} from '../../utils/hooks';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {
useIsUserAllowedToMakeChanges,
useIsViewerUser,
Expand Down Expand Up @@ -71,7 +72,11 @@ const prepareUnavailableVDiskData = (data: UnavailableDonor, withDeveloperUILink
};

// eslint-disable-next-line complexity
const prepareVDiskData = (data: PreparedVDisk, withDeveloperUILink?: boolean) => {
const prepareVDiskData = (
data: PreparedVDisk,
withDeveloperUILink: boolean | undefined,
query: {database: string | undefined},
) => {
const {
NodeId,
PDiskId,
Expand All @@ -89,6 +94,7 @@ const prepareVDiskData = (data: PreparedVDisk, withDeveloperUILink?: boolean) =>
ReadThroughput,
WriteThroughput,
StoragePoolName,
VDiskId,
} = data;

const vdiskData: InfoViewerItem[] = [
Expand Down Expand Up @@ -201,7 +207,10 @@ const prepareVDiskData = (data: PreparedVDisk, withDeveloperUILink?: boolean) =>
})
: undefined;

const vDiskPagePath = getVDiskLink({VDiskSlotId, PDiskId, NodeId, StringifiedId});
const vDiskPagePath = getVDiskLink(
{VDiskSlotId, PDiskId, NodeId, StringifiedId, VDiskId},
query,
);
if (vDiskPagePath) {
vdiskData.push({
label: vDiskPopupKeyset('label_links'),
Expand Down Expand Up @@ -238,15 +247,17 @@ export const VDiskPopup = ({data}: VDiskPopupProps) => {

const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();

const database = useDatabaseFromQuery();

const vdiskInfo = React.useMemo(
() =>
isFullData
? prepareVDiskData(data, isUserAllowedToMakeChanges)
? prepareVDiskData(data, isUserAllowedToMakeChanges, {database})
: prepareUnavailableVDiskData(data, isUserAllowedToMakeChanges),
[data, isFullData, isUserAllowedToMakeChanges],
[data, isFullData, isUserAllowedToMakeChanges, database],
);

const nodesMap = useTypedSelector(selectNodesMap);
const nodesMap = useTypedSelector((state) => selectNodesMap(state, database));
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
const pdiskInfo = React.useMemo(
() =>
Expand All @@ -262,7 +273,11 @@ export const VDiskPopup = ({data}: VDiskPopupProps) => {
for (const donor of donors) {
donorsInfo.push({
label: vDiskPopupKeyset('label_vdisk'),
value: <InternalLink to={getVDiskLink(donor)}>{donor.StringifiedId}</InternalLink>,
value: (
<InternalLink to={getVDiskLink(donor, {database})}>
{donor.StringifiedId}
</InternalLink>
),
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/containers/App/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ function GetUser({children}: {children: React.ReactNode}) {
}

function GetNodesList() {
nodesListApi.useGetNodesListQuery(undefined);
const database = useDatabaseFromQuery();
nodesListApi.useGetNodesListQuery({database}, undefined);
return null;
}

Expand Down
Loading
Loading