Repository navigation
feat: add compact pdisk previews to node tables #4348
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
Draft
StekPerepolnen
wants to merge
11
commits into
ydb-platform:main
Choose a base branch
from
StekPerepolnen:fix/nodes-pdisks-summary-expander
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
757f276
feat: add compact pdisks summary for nodes
StekPerepolnen 0ffe02e
feat: finalize compact pdisk previews and add regression tests
StekPerepolnen 5f2580b
fix: isolate pdisk preview rendering and preserve keyboard focus
StekPerepolnen a2b4102
refactor: split nodes row height fix into a separate pr
StekPerepolnen b851c63
refactor: move preview popup scrolling to the shared fix
StekPerepolnen 5348b9c
refactor: extract pdisk column width fix from previews
StekPerepolnen 9dd0a74
fix: retain disk width maxima for pdisk previews
StekPerepolnen 31e5a4d
fix: preserve merged nodes row height after rebase
StekPerepolnen 2de909d
fix: support keyboard navigation in pdisk previews
StekPerepolnen 3e7db1d
fix: size pdisk previews from actual disk contents
StekPerepolnen 95d058d
fix: reset pdisk column width when selection changes
StekPerepolnen 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 |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| @use '../../../styles/mixins'; | ||
|
|
||
| .ydb-storage-pdisks-preview { | ||
| &__color { | ||
| @include mixins.entity-state-colors(&); | ||
| } | ||
|
|
||
| &__control { | ||
| // Match the SVG height and avoid adding padding to the compact disk grid. | ||
| --g-button-height: 41px; | ||
| --g-button-padding: 0; | ||
| --g-button-background-color-hover: transparent; | ||
|
|
||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| &__svg { | ||
| display: block; | ||
| } | ||
|
|
||
| &__pdisk-background, | ||
| &__vdisk-background { | ||
| fill: var(--entity-state-background-color, var(--g-color-base-misc-light)); | ||
| } | ||
|
|
||
| &__pdisk-fill, | ||
| &__vdisk-fill { | ||
| fill: var(--entity-state-fill-color, var(--g-color-base-misc-medium)); | ||
| } | ||
|
|
||
| &__pdisk-border { | ||
| fill: none; | ||
| stroke: var(--entity-state-border-color, var(--g-color-base-misc-heavy)); | ||
| } | ||
|
|
||
| &__vdisk-fill { | ||
| stroke: var( | ||
| --entity-state-shadow-color, | ||
| var(--entity-state-border-color, var(--g-color-base-misc-heavy)) | ||
| ); | ||
| stroke-width: 2px; | ||
| } | ||
| } |
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,110 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {act, fireEvent, render, screen} from '@testing-library/react'; | ||
|
|
||
| import type {PreparedPDisk, PreparedVDisk} from '../../../utils/disks/types'; | ||
| import type {PDisk} from '../PDisk'; | ||
|
|
||
| import {PDisksPreview} from './PDisksPreview'; | ||
|
|
||
| let mockInverted = false; | ||
| const mockDetailsById = new Map<string, React.ComponentProps<typeof PDisk>>(); | ||
| let mockDetailsProps: React.ComponentProps<typeof PDisk>; | ||
|
|
||
| jest.mock('../../../utils/hooks/useSetting', () => ({useSetting: () => [mockInverted]})); | ||
| jest.mock('../../../store', () => ({singleClusterMode: true})); | ||
| jest.mock('../PDisk', () => ({ | ||
| PDisk: (props: React.ComponentProps<typeof PDisk>) => { | ||
| mockDetailsProps = props; | ||
| mockDetailsById.set(props.data?.StringifiedId || '', props); | ||
| return <button>Expanded PDisk</button>; | ||
| }, | ||
| })); | ||
|
|
||
| const pDisk: PreparedPDisk = {NodeId: 1, PDiskId: 1, StringifiedId: '1-1', AllocatedPercent: 25}; | ||
| const vDisks: PreparedVDisk[] = Array.from({length: 12}, (_, index) => ({ | ||
| NodeId: 1, | ||
| PDiskId: 1, | ||
| VDiskSlotId: index, | ||
| Severity: 1, | ||
| })); | ||
|
|
||
| beforeEach(() => { | ||
| mockInverted = false; | ||
| }); | ||
|
|
||
| test('groups identical VDisks and updates the preview on data refresh', () => { | ||
| const {container, rerender} = render(<PDisksPreview pDisks={[pDisk]} vDisks={vDisks} />); | ||
| const svg = container.querySelector('svg'); | ||
| if (!svg) { | ||
| throw new Error('Missing PDisk preview SVG'); | ||
| } | ||
| expect(screen.getByRole('button', {name: 'Show PDisk 1-1 details'})).toBeVisible(); | ||
| expect(svg.querySelectorAll('*')).toHaveLength(5); | ||
| expect(svg.querySelector('path')?.getAttribute('d')?.match(/M/g)).toHaveLength(12); | ||
| expect(svg.querySelector('.ydb-storage-pdisks-preview__pdisk-fill')).toHaveAttribute( | ||
| 'height', | ||
| '10.25', | ||
| ); | ||
|
|
||
| rerender( | ||
| <PDisksPreview | ||
| pDisks={[{...pDisk, AllocatedPercent: 80, Severity: 5}]} | ||
| vDisks={[...vDisks.slice(0, 5), {...vDisks[5], Severity: 5}]} | ||
| />, | ||
| ); | ||
| expect(svg).toHaveAttribute('width', '13'); | ||
| expect(svg.querySelectorAll('path')).toHaveLength(4); | ||
| expect( | ||
| Number( | ||
| svg.querySelector('.ydb-storage-pdisks-preview__pdisk-fill')?.getAttribute('height'), | ||
| ), | ||
| ).toBeCloseTo(32.8); | ||
| expect(svg.querySelector('.ydb-storage-pdisks-preview__pdisk-border')).toHaveClass( | ||
| 'ydb-storage-pdisks-preview__color_red', | ||
| ); | ||
| }); | ||
|
|
||
| test('inverts PDisk allocation and keeps unrelated disks dimmed', () => { | ||
| mockInverted = true; | ||
| const {container} = render( | ||
| <PDisksPreview pDisks={[pDisk]} vDisks={vDisks} viewContext={{nodeId: '2'}} />, | ||
| ); | ||
| expect(container.querySelector('svg g')).toHaveAttribute('opacity', '0.5'); | ||
| expect(container.querySelector('.ydb-storage-pdisks-preview__pdisk-fill')).toHaveAttribute( | ||
| 'height', | ||
| '30.75', | ||
| ); | ||
| expect(container.querySelector('.ydb-storage-pdisks-preview__pdisk-fill')).toHaveAttribute( | ||
| 'y', | ||
| '0', | ||
| ); | ||
| expect(container.querySelector('path')?.parentElement).toHaveAttribute('opacity', '0.5'); | ||
| }); | ||
|
|
||
| test('closing details clears highlight and ignores callbacks from the previous expansion', () => { | ||
| render(<PDisksPreview pDisks={[pDisk]} vDisks={vDisks} />); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Show PDisk 1-1 details'})); | ||
| expect(mockDetailsProps.highlighted).toBe(false); | ||
| const delayedShow = mockDetailsProps.onShowPopup; | ||
| fireEvent.click(screen.getByRole('button', {name: 'Expanded PDisk'})); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Show PDisk 1-1 details'})); | ||
|
|
||
| act(() => delayedShow?.()); | ||
| expect(mockDetailsProps.highlighted).toBe(false); | ||
| act(() => mockDetailsProps.onShowPopup?.()); | ||
| expect(mockDetailsProps.highlighted).toBe(true); | ||
| }); | ||
|
|
||
| test('collapsing another group and its delayed hide callback preserve the highlighted owner', () => { | ||
| const secondDisk = {...pDisk, PDiskId: 2, StringifiedId: '1-2'}; | ||
| render(<PDisksPreview pDisks={[pDisk, secondDisk]} vDisks={vDisks} />); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Show PDisk 1-1 details'})); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Show PDisk 1-2 details'})); | ||
| const firstHide = mockDetailsById.get('1-1')?.onHidePopup; | ||
| act(() => mockDetailsById.get('1-2')?.onShowPopup?.()); | ||
| act(() => firstHide?.()); | ||
| expect(mockDetailsById.get('1-2')?.highlighted).toBe(true); | ||
| fireEvent.click(screen.getAllByRole('button', {name: 'Expanded PDisk'})[0]); | ||
| expect(mockDetailsById.get('1-2')?.highlighted).toBe(true); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.