-
Notifications
You must be signed in to change notification settings - Fork 17
feat(storage): update vdisk donor/replica visuals and tooltips #3110
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
Merged
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e830ca5
feat(storage): update vdisk donor/replica visuals and tooltips
DaryaVorontsova 64ea099
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova 9d03b8d
Fix bugs
DaryaVorontsova 9d7726a
Fix bugs
DaryaVorontsova 37bc21f
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova e2c8a26
Fix bugs
DaryaVorontsova fd5210a
Fix bugs
DaryaVorontsova 9034ded
Fix bugs
DaryaVorontsova 3f88102
Fix bugs
DaryaVorontsova 4ba7f97
Fix bugs
DaryaVorontsova 366d4ea
Fix bugs
DaryaVorontsova 5ddf4c9
Fix bugs
DaryaVorontsova 8852c71
Fix bugs
DaryaVorontsova 6dd85c2
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova e73be32
Fix bugs
DaryaVorontsova c9e20af
Fix bugs
DaryaVorontsova 855fdb6
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova c48cd4e
Fix bugs
DaryaVorontsova 2a2fa8a
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova ab8362e
Fix bugs
DaryaVorontsova e835dbb
Merge branch 'main' into feat/update-vdisk-ui
DaryaVorontsova fafefe3
Fix bugs
DaryaVorontsova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,103 +1,138 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {Flex} from '@gravity-ui/uikit'; | ||
| import {Flex, Label, Progress} from '@gravity-ui/uikit'; | ||
| import {isNil} from 'lodash'; | ||
|
|
||
| import {selectNodesMap} 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 {getStateSeverity} from '../../utils/disks/calculatePDiskSeverity'; | ||
| import {NUMERIC_SEVERITY_TO_LABEL_VIEW} from '../../utils/disks/constants'; | ||
| 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'; | ||
| import type {InfoViewerItem} from '../InfoViewer'; | ||
| import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon'; | ||
| import {pDiskInfoKeyset} from '../PDiskInfo/i18n'; | ||
| import {PDiskPageLink} from '../PDiskPageLink/PDiskPageLink'; | ||
| import {StatusIcon} from '../StatusIcon/StatusIcon'; | ||
| import type { | ||
| YDBDefinitionListHeaderLabel, | ||
| YDBDefinitionListItem, | ||
| } from '../YDBDefinitionList/YDBDefinitionList'; | ||
| import {YDBDefinitionList} from '../YDBDefinitionList/YDBDefinitionList'; | ||
|
|
||
| import {pDiskPopupKeyset} from './i18n'; | ||
|
|
||
| const errorColors = [EFlag.Orange, EFlag.Red, EFlag.Yellow]; | ||
|
|
||
| export const preparePDiskData = ( | ||
| data: PreparedPDisk, | ||
| nodeData?: {Host?: string; DC?: string}, | ||
| withDeveloperUILink?: boolean, | ||
| ) => { | ||
| const { | ||
| AvailableSize, | ||
| TotalSize, | ||
| State, | ||
| PDiskId, | ||
| NodeId, | ||
| StringifiedId, | ||
| Path, | ||
| Realtime, | ||
| Type, | ||
| Device, | ||
| } = data; | ||
|
|
||
| const pdiskData: InfoViewerItem[] = [ | ||
| { | ||
| label: 'PDisk', | ||
| value: StringifiedId ?? EMPTY_DATA_PLACEHOLDER, | ||
| }, | ||
| {label: 'State', value: State || 'not available'}, | ||
| {label: 'Type', value: Type || 'unknown'}, | ||
| export const preparePDiskData = (data: PreparedPDisk, nodeData?: {Host?: string; DC?: string}) => { | ||
| const {AvailableSize, TotalSize, NodeId, Path, Realtime, Type, Device} = data; | ||
|
|
||
| const pdiskData: YDBDefinitionListItem[] = [ | ||
| {name: pDiskPopupKeyset('label_type'), content: Type || pDiskPopupKeyset('value_unknown')}, | ||
| ]; | ||
|
|
||
| if (NodeId) { | ||
| pdiskData.push({label: 'Node Id', value: NodeId}); | ||
| pdiskData.push({name: pDiskPopupKeyset('label_node-id'), content: NodeId}); | ||
| } | ||
|
|
||
| if (nodeData?.Host) { | ||
| pdiskData.push({label: 'Host', value: nodeData.Host}); | ||
| pdiskData.push({name: pDiskPopupKeyset('label_host'), content: nodeData.Host}); | ||
| } | ||
|
|
||
| if (nodeData?.DC) { | ||
| pdiskData.push({label: 'DC', value: nodeData.DC}); | ||
| pdiskData.push({name: pDiskPopupKeyset('label_dc'), content: <Label>{nodeData.DC}</Label>}); | ||
| } | ||
|
|
||
| if (Path) { | ||
| pdiskData.push({label: 'Path', value: Path}); | ||
| pdiskData.push({name: pDiskPopupKeyset('label_path'), content: Path}); | ||
| } | ||
|
|
||
| if (isNumeric(TotalSize)) { | ||
| if (isNumeric(TotalSize) && isNumeric(AvailableSize)) { | ||
| pdiskData.push({ | ||
| label: 'Available', | ||
| value: `${bytesToGB(AvailableSize)} of ${bytesToGB(TotalSize)}`, | ||
| name: pDiskPopupKeyset('label_available'), | ||
| content: ( | ||
| <React.Fragment> | ||
| <Progress | ||
|
||
| theme="success" | ||
| size="s" | ||
| value={Math.min(Math.max((AvailableSize / TotalSize) * 100, 0), 100)} | ||
| /> | ||
| <span>{`${bytesToGB(AvailableSize)} ${pDiskPopupKeyset('value_of')} ${bytesToGB(TotalSize)}`}</span> | ||
| </React.Fragment> | ||
| ), | ||
| }); | ||
| } | ||
|
|
||
| if (Realtime && errorColors.includes(Realtime)) { | ||
| pdiskData.push({label: 'Realtime', value: Realtime}); | ||
| pdiskData.push({ | ||
| name: pDiskPopupKeyset('label_realtime'), | ||
| content: <StatusIcon mode="icons" status={Realtime} />, | ||
| }); | ||
| } | ||
|
|
||
| if (Device && errorColors.includes(Device)) { | ||
| pdiskData.push({label: 'Device', value: Device}); | ||
| pdiskData.push({ | ||
| name: pDiskPopupKeyset('label_device'), | ||
| content: <StatusIcon mode="icons" status={Device} />, | ||
| }); | ||
| } | ||
|
|
||
| if (withDeveloperUILink && valueIsDefined(NodeId) && valueIsDefined(PDiskId)) { | ||
| const pDiskInternalViewerPath = createPDiskDeveloperUILink({ | ||
| nodeId: NodeId, | ||
| pDiskId: PDiskId, | ||
| return pdiskData; | ||
| }; | ||
|
|
||
| export const preparePDiskHeaderLabels = (data: PreparedPDisk): YDBDefinitionListHeaderLabel[] => { | ||
| const labels: YDBDefinitionListHeaderLabel[] = []; | ||
| const {State} = data; | ||
|
|
||
| if (!State) { | ||
| labels.push({ | ||
| id: 'state', | ||
| value: pDiskPopupKeyset('context_not-available'), | ||
| }); | ||
|
|
||
| pdiskData.push({ | ||
| label: 'Links', | ||
| value: ( | ||
| <Flex gap={2} wrap="wrap"> | ||
| <PDiskPageLink pDiskId={PDiskId} nodeId={NodeId} /> | ||
| <LinkWithIcon | ||
| title={pDiskInfoKeyset('developer-ui')} | ||
| url={pDiskInternalViewerPath} | ||
| /> | ||
| </Flex> | ||
| ), | ||
| return labels; | ||
| } | ||
|
|
||
| if (State) { | ||
| const severity = getStateSeverity(State); | ||
| const {theme, icon} = NUMERIC_SEVERITY_TO_LABEL_VIEW[severity]; | ||
|
|
||
| labels.push({ | ||
| id: 'state', | ||
| value: State, | ||
| theme: theme, | ||
| icon: icon, | ||
| }); | ||
| } | ||
|
|
||
| return pdiskData; | ||
| return labels; | ||
| }; | ||
|
|
||
| export const buildPDiskFooter = ( | ||
| data: PreparedPDisk, | ||
| withDeveloperUILink?: boolean, | ||
| ): React.ReactNode | null => { | ||
| const {NodeId, PDiskId} = data; | ||
|
|
||
| if (!withDeveloperUILink || isNil(NodeId) || isNil(PDiskId)) { | ||
| return null; | ||
| } | ||
|
|
||
| const pDiskInternalViewerPath = createPDiskDeveloperUILink({ | ||
| nodeId: NodeId, | ||
| pDiskId: PDiskId, | ||
| }); | ||
|
|
||
| return ( | ||
| <Flex gap={2} wrap="wrap"> | ||
| <PDiskPageLink pDiskId={PDiskId} nodeId={NodeId} /> | ||
| <LinkWithIcon title={pDiskInfoKeyset('developer-ui')} url={pDiskInternalViewerPath} /> | ||
| </Flex> | ||
| ); | ||
| }; | ||
|
|
||
| interface PDiskPopupProps { | ||
|
|
@@ -108,11 +143,31 @@ export const PDiskPopup = ({data}: PDiskPopupProps) => { | |
| const database = useDatabaseFromQuery(); | ||
| const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges(); | ||
| 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), | ||
| [data, nodeData, isUserAllowedToMakeChanges], | ||
| const nodeData = isNil(data.NodeId) ? undefined : nodesMap?.get(data.NodeId); | ||
|
|
||
| const info = React.useMemo(() => preparePDiskData(data, nodeData), [data, nodeData]); | ||
|
|
||
| const headerLabels = React.useMemo<YDBDefinitionListHeaderLabel[]>( | ||
| () => preparePDiskHeaderLabels(data), | ||
| [data], | ||
| ); | ||
|
|
||
| const footer = React.useMemo( | ||
| () => buildPDiskFooter(data, isUserAllowedToMakeChanges), | ||
| [data, isUserAllowedToMakeChanges], | ||
| ); | ||
|
|
||
| return <InfoViewer title="PDisk" info={info} size="s" />; | ||
| const pdiskId = data.StringifiedId; | ||
|
|
||
| return ( | ||
| <YDBDefinitionList | ||
| compact | ||
| title="PDisk" | ||
| titleSuffix={pdiskId ?? EMPTY_DATA_PLACEHOLDER} | ||
| items={info} | ||
| headerLabels={headerLabels} | ||
| footer={footer} | ||
| nameMaxWidth={100} | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "context_not-available": "Not available", | ||
| "label_type": "Type", | ||
| "label_node-id": "Node Id", | ||
| "label_host": "Host", | ||
| "label_dc": "DC", | ||
| "label_path": "Path", | ||
| "label_available": "Available", | ||
| "label_realtime": "Realtime", | ||
| "label_device": "Device", | ||
| "value_unknown": "unknown", | ||
| "value_of": "of" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import {registerKeysets} from '../../../utils/i18n'; | ||
|
|
||
| import en from './en.json'; | ||
|
|
||
| const COMPONENT = 'ydb-pDisk-popup'; | ||
|
|
||
| export const pDiskPopupKeyset = registerKeysets(COMPONENT, {en}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
does we really need this prop?