-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add partitions progress bar to table info #3206
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
Open
DaryaVorontsova
wants to merge
15
commits into
main
Choose a base branch
from
feat/new-progress-bar
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.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c91b573
feat: add partitions progress bar to table info
DaryaVorontsova 332209b
Merge branch 'main' into feat/new-progress-bar
DaryaVorontsova f121ed5
Fix bugs
DaryaVorontsova ae31b8a
Fix bugs
DaryaVorontsova b3414be
Fix bugs
DaryaVorontsova 9f486b6
Fix bugs
DaryaVorontsova 205afb9
Fix bugs
DaryaVorontsova 5ff0661
Fix bugs
DaryaVorontsova dd87209
Fix bugs
DaryaVorontsova 57bb8c0
Fix window
DaryaVorontsova 75a4945
Merge branch 'main' into feat/new-progress-bar
DaryaVorontsova 7f11e08
Merge branch 'main' into feat/new-progress-bar
DaryaVorontsova 3de084b
Fix tests
DaryaVorontsova 5570424
Merge branch 'main' into feat/new-progress-bar
DaryaVorontsova 9f9c6b1
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
57 changes: 57 additions & 0 deletions
57
...ntainers/Tenant/Diagnostics/Overview/TableInfo/PartitionsProgress/PartitionsProgress.scss
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,57 @@ | ||
| .ydb-partitions-progress { | ||
| &__segment { | ||
| display: flex; | ||
| flex-basis: 0; | ||
|
|
||
| &_additional { | ||
| min-width: 20px; | ||
| } | ||
|
|
||
| &_main { | ||
| min-width: 70px; | ||
| } | ||
| } | ||
|
|
||
| &__segment-bar { | ||
| --segment-filled-bg-color: var(--g-color-base-neutral-heavy); | ||
| --segment-empty-bg-color: var(--g-color-base-neutral-light); | ||
| overflow: hidden; | ||
|
|
||
| height: 10px; | ||
|
|
||
| border-radius: var(--g-border-radius-xs); | ||
| background-color: var(--segment-empty-bg-color); | ||
|
|
||
| &_additional { | ||
| --segment-filled-bg-color: var(--g-color-base-danger-heavy); | ||
| --segment-empty-bg-color: var(--g-color-base-danger-light); | ||
| } | ||
|
|
||
| &_main { | ||
| --segment-filled-bg-color: var(--g-color-base-info-heavy); | ||
| --segment-empty-bg-color: var(--g-color-base-info-light); | ||
| } | ||
| } | ||
|
|
||
| &__segment-fill { | ||
| height: 100%; | ||
|
|
||
| background-color: var(--segment-filled-bg-color); | ||
|
|
||
| transition: | ||
| transform 0.6s ease, | ||
| width 0.6s ease, | ||
| background-color 0.6s ease; | ||
|
|
||
| &_min-fill { | ||
| min-width: 20px; | ||
| } | ||
| } | ||
|
|
||
| &__segment-touched { | ||
| padding: var(--g-spacing-2); | ||
|
|
||
| font-size: var(--g-text-body-2-font-size); | ||
| line-height: var(--g-text-body-2-line-height); | ||
| } | ||
| } |
143 changes: 143 additions & 0 deletions
143
...ontainers/Tenant/Diagnostics/Overview/TableInfo/PartitionsProgress/PartitionsProgress.tsx
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,143 @@ | ||
| import {Flex, Popover, Text} from '@gravity-ui/uikit'; | ||
| import {isNil} from 'lodash'; | ||
|
|
||
| import {cn} from '../../../../../../utils/cn'; | ||
|
|
||
| import {getPartitionsTooltip} from './helpers'; | ||
| import i18n from './i18n'; | ||
| import {FULL_FILL_VALUE, calcPartitionsProgress} from './utils'; | ||
|
|
||
| import './PartitionsProgress.scss'; | ||
|
|
||
| const b = cn('ydb-partitions-progress'); | ||
|
|
||
| interface PartitionsProgressProps { | ||
| minPartitions: number; | ||
| maxPartitions?: number; | ||
| partitionsCount: number; | ||
| className?: string; | ||
| } | ||
|
|
||
| type SegmentPosition = 'main' | 'additional'; | ||
|
|
||
| const SEGMENT_MODS: Record<SegmentPosition, Record<string, boolean>> = { | ||
| additional: {additional: true}, | ||
| main: {main: true}, | ||
| }; | ||
|
|
||
| interface SegmentProgressBarProps { | ||
| position: SegmentPosition; | ||
| value: number; | ||
| withMinFill?: boolean; | ||
| } | ||
|
|
||
| const SegmentProgressBar = ({position, value, withMinFill}: SegmentProgressBarProps) => { | ||
| const width = `${value}%`; | ||
|
|
||
| return ( | ||
| <div | ||
| className={b('segment-bar', SEGMENT_MODS[position])} | ||
| role="progressbar" | ||
| aria-valuemin={0} | ||
| aria-valuemax={FULL_FILL_VALUE} | ||
| aria-valuenow={value} | ||
| > | ||
| <div className={b('segment-fill', {'min-fill': withMinFill})} style={{width}} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export const PartitionsProgress = ({ | ||
| minPartitions, | ||
| maxPartitions, | ||
| partitionsCount, | ||
| className, | ||
| }: PartitionsProgressProps) => { | ||
| const { | ||
| min, | ||
| max, | ||
| partitionsBelowMin, | ||
| partitionsAboveMax, | ||
| isBelowMin, | ||
| isAboveMax, | ||
| leftSegmentUnits, | ||
| mainSegmentUnits, | ||
| rightSegmentUnits, | ||
| mainProgressValue, | ||
| } = calcPartitionsProgress(minPartitions, maxPartitions, partitionsCount); | ||
|
|
||
| const tooltip = getPartitionsTooltip({ | ||
| count: partitionsCount, | ||
| belowMin: partitionsBelowMin, | ||
| aboveMax: partitionsAboveMax, | ||
| isBelowMin: isBelowMin, | ||
| isAboveMax: isAboveMax, | ||
| }); | ||
|
|
||
| const maxLabel = isNil(max) ? i18n('value_no-limit') : max; | ||
|
|
||
| const hasAdditionalSegments = isBelowMin || isAboveMax; | ||
| const withMinFill = !hasAdditionalSegments; | ||
|
|
||
| return ( | ||
| <Popover hasArrow placement="top" content={tooltip} className={b('segment-touched')}> | ||
| <Flex alignItems="center" gap="0.5" className={b(null, className)}> | ||
| {isBelowMin && ( | ||
| <Flex | ||
| style={{flexGrow: leftSegmentUnits}} | ||
| direction="column" | ||
| gap="2" | ||
| className={b('segment', SEGMENT_MODS.additional)} | ||
| > | ||
| <SegmentProgressBar position="additional" value={FULL_FILL_VALUE} /> | ||
|
|
||
| <Flex justifyContent="flex-start"> | ||
| <Text variant="body-2" color="secondary"> | ||
| {partitionsCount} | ||
| </Text> | ||
| </Flex> | ||
| </Flex> | ||
| )} | ||
|
|
||
| <Flex | ||
| direction="column" | ||
| className={b('segment', SEGMENT_MODS.main)} | ||
| style={{flexGrow: mainSegmentUnits}} | ||
| gap="2" | ||
| > | ||
| <SegmentProgressBar | ||
| position="main" | ||
| value={mainProgressValue} | ||
| withMinFill={withMinFill} | ||
| /> | ||
|
|
||
| <Flex justifyContent="space-between"> | ||
| <Text variant="body-2" color="secondary"> | ||
| {min} | ||
| </Text> | ||
| <Text variant="body-2" color="secondary"> | ||
| {maxLabel} | ||
| </Text> | ||
| </Flex> | ||
| </Flex> | ||
|
|
||
| {isAboveMax && ( | ||
| <Flex | ||
| direction="column" | ||
| gap="2" | ||
| className={b('segment', SEGMENT_MODS.additional)} | ||
| style={{flexGrow: rightSegmentUnits}} | ||
| > | ||
| <SegmentProgressBar position="additional" value={FULL_FILL_VALUE} /> | ||
|
|
||
| <Flex justifyContent="flex-end"> | ||
| <Text variant="body-2" color="secondary"> | ||
| {partitionsCount} | ||
| </Text> | ||
| </Flex> | ||
| </Flex> | ||
| )} | ||
| </Flex> | ||
| </Popover> | ||
| ); | ||
| }; | ||
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.
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.
I decided not to use
Progresscomponent, because when we have only main progress bar and if the value of current partitions is quite small, we should fix min-width in 20 px for filling part (designer said).Progresscomponent doesn't allow to do it.