-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add developer ui links to disks popups #1512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication'; | ||
import {selectNodeHostsMap} from '../../store/reducers/nodesList'; | ||
import {EFlag} from '../../types/api/enums'; | ||
import {valueIsDefined} from '../../utils'; | ||
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants'; | ||
import {createPDiskDeveloperUILink} from '../../utils/developerUI/developerUI'; | ||
import {getPDiskId} from '../../utils/disks/helpers'; | ||
import type {PreparedPDisk} from '../../utils/disks/types'; | ||
import {useTypedSelector} from '../../utils/hooks'; | ||
import {bytesToGB} from '../../utils/utils'; | ||
import {InfoViewer} from '../InfoViewer'; | ||
import type {InfoViewerItem} from '../InfoViewer'; | ||
import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon'; | ||
|
||
const errorColors = [EFlag.Orange, EFlag.Red, EFlag.Yellow]; | ||
|
||
export const preparePDiskData = (data: PreparedPDisk, nodeHost?: string) => { | ||
export const preparePDiskData = ( | ||
data: PreparedPDisk, | ||
nodeHost?: string, | ||
withDeveloperUILink?: boolean, | ||
) => { | ||
const {AvailableSize, TotalSize, State, PDiskId, NodeId, Path, Realtime, Type, Device} = data; | ||
|
||
const pdiskData: InfoViewerItem[] = [ | ||
|
@@ -50,6 +57,18 @@ export const preparePDiskData = (data: PreparedPDisk, nodeHost?: string) => { | |
pdiskData.push({label: 'Device', value: Device}); | ||
} | ||
|
||
if (withDeveloperUILink && valueIsDefined(NodeId) && valueIsDefined(PDiskId)) { | ||
const pDiskInternalViewerPath = createPDiskDeveloperUILink({ | ||
nodeId: NodeId, | ||
pDiskId: PDiskId, | ||
}); | ||
|
||
pdiskData.push({ | ||
label: 'Links', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no |
||
value: <LinkWithIcon title={'Developer UI'} url={pDiskInternalViewerPath} />, | ||
}); | ||
} | ||
|
||
return pdiskData; | ||
}; | ||
|
||
|
@@ -58,9 +77,13 @@ interface PDiskPopupProps { | |
} | ||
|
||
export const PDiskPopup = ({data}: PDiskPopupProps) => { | ||
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges); | ||
const nodeHostsMap = useTypedSelector(selectNodeHostsMap); | ||
const nodeHost = valueIsDefined(data.NodeId) ? nodeHostsMap?.get(data.NodeId) : undefined; | ||
const info = React.useMemo(() => preparePDiskData(data, nodeHost), [data, nodeHost]); | ||
const info = React.useMemo( | ||
() => preparePDiskData(data, nodeHost, isUserAllowedToMakeChanges), | ||
[data, nodeHost, isUserAllowedToMakeChanges], | ||
); | ||
|
||
return <InfoViewer title="PDisk" info={info} size="s" />; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,18 @@ export function preparePDiskDataResponse([pdiskResponse = {}, nodeResponse]: [ | |
TPDiskInfoResponse, | ||
TEvSystemStateResponse, | ||
]): PDiskData { | ||
const rawNode = nodeResponse.SystemStateInfo?.[0]; | ||
const preparedNode = prepareNodeSystemState(rawNode); | ||
|
||
const {BSC = {}, Whiteboard = {}} = pdiskResponse || {}; | ||
|
||
const {PDisk: WhiteboardPDiskData = {}, VDisks: WhiteboardVDisksData = []} = Whiteboard; | ||
const {PDisk: BSCPDiskData = {}} = BSC; | ||
|
||
const preparedPDisk = preparePDiskData(WhiteboardPDiskData, BSCPDiskData); | ||
|
||
const NodeId = preparedPDisk.NodeId ?? preparedNode.NodeId; | ||
|
||
const { | ||
LogUsedSize, | ||
LogTotalSize, | ||
|
@@ -43,9 +48,8 @@ export function preparePDiskDataResponse([pdiskResponse = {}, nodeResponse]: [ | |
}; | ||
} | ||
|
||
const preparedVDisks = WhiteboardVDisksData.map(prepareVDiskData).sort( | ||
(disk1, disk2) => Number(disk2.VDiskSlotId) - Number(disk1.VDiskSlotId), | ||
); | ||
const preparedVDisks = WhiteboardVDisksData.map((disk) => prepareVDiskData({...disk, NodeId})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no |
||
preparedVDisks.sort((disk1, disk2) => Number(disk2.VDiskSlotId) - Number(disk1.VDiskSlotId)); | ||
|
||
const vdisksSlots: SlotItem<'vDisk'>[] = preparedVDisks.map((preparedVDisk) => { | ||
return { | ||
|
@@ -94,12 +98,9 @@ export function preparePDiskDataResponse([pdiskResponse = {}, nodeResponse]: [ | |
diskSlots.unshift(logSlot); | ||
} | ||
|
||
const rawNode = nodeResponse.SystemStateInfo?.[0]; | ||
const preparedNode = prepareNodeSystemState(rawNode); | ||
|
||
return { | ||
...preparedPDisk, | ||
NodeId: preparedPDisk.NodeId ?? preparedNode.NodeId, | ||
NodeId, | ||
NodeHost: preparedNode.Host, | ||
NodeType: preparedNode.Roles?.[0], | ||
NodeDC: preparedNode.DC, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
div
without additional styling doesn't work well forPDiskSpaceDistribution