-
Notifications
You must be signed in to change notification settings - Fork 17
feat: redesign Memory section #2627
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
081fa1b
feat: redesign Memory section
astandrik 6fe384a
fix: remove unused code
astandrik adc0850
fix: better code
astandrik 6b6a680
fix: better code
astandrik b0795fd
fix: nanofix
astandrik f457e90
fix: review fixes
astandrik eb542d5
fix: selfreview
astandrik 94e1cc5
fix: selfreview
astandrik d0a83e2
fix: review fixes
astandrik cddbcc6
fix: fallback
astandrik 31fcee6
fix: remove unused classes
astandrik c00fe9f
fix: memory fixes
astandrik 12f80b0
fix: chartkit tooltip fix
astandrik 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,25 @@ | ||
| import {Flex, Text} from '@gravity-ui/uikit'; | ||
|
|
||
| import {getProgressStyle} from './progressUtils'; | ||
| import type {ProgressContainerProps} from './types'; | ||
|
|
||
| export function ProgressContainer({ | ||
| children, | ||
| displayText, | ||
| withCapacityUsage = false, | ||
| className, | ||
| width, | ||
| }: ProgressContainerProps) { | ||
| const progressStyle = getProgressStyle(width); | ||
|
|
||
| return ( | ||
| <Flex alignItems="center" gap="2" className={className}> | ||
| <div style={progressStyle}>{children}</div> | ||
| {withCapacityUsage && displayText && ( | ||
| <Text variant="body-1" color="secondary"> | ||
| {displayText} | ||
| </Text> | ||
| )} | ||
| </Flex> | ||
| ); | ||
| } |
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,10 @@ | ||
| import {SingleProgress} from './SingleProgress'; | ||
| import {StackProgress} from './StackProgress'; | ||
| import type {ProgressWrapperProps} from './types'; | ||
|
|
||
| export function ProgressWrapper(props: ProgressWrapperProps) { | ||
| if ('stack' in props && props.stack) { | ||
| return <StackProgress {...props} />; | ||
| } | ||
| return <SingleProgress {...props} />; | ||
| } | ||
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,54 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {Progress} from '@gravity-ui/uikit'; | ||
|
|
||
| import {defaultFormatProgressValues} from '../../utils/progress'; | ||
| import {safeParseNumber} from '../../utils/utils'; | ||
|
|
||
| import {ProgressContainer} from './ProgressContainer'; | ||
| import i18n from './i18n'; | ||
| import { | ||
| PROGRESS_SIZE, | ||
| calculateProgressWidth, | ||
| formatDisplayValues, | ||
| formatProgressText, | ||
| isValidValue, | ||
| } from './progressUtils'; | ||
| import type {ProgressWrapperSingleProps} from './types'; | ||
|
|
||
| export function SingleProgress({ | ||
| value, | ||
| capacity, | ||
| formatValues = defaultFormatProgressValues, | ||
| className, | ||
| width, | ||
| size = PROGRESS_SIZE, | ||
| withCapacityUsage = false, | ||
| }: ProgressWrapperSingleProps) { | ||
| if (!isValidValue(value)) { | ||
| return <div className={className}>{i18n('alert_no-data')}</div>; | ||
| } | ||
|
|
||
| const numericValue = safeParseNumber(value); | ||
| const numericCapacity = safeParseNumber(capacity); | ||
| const clampedFillWidth = calculateProgressWidth(numericValue, numericCapacity); | ||
|
|
||
| const [valueText, capacityText] = React.useMemo(() => { | ||
| return formatDisplayValues(value, capacity, formatValues); | ||
| }, [formatValues, value, capacity]); | ||
|
|
||
| const displayText = React.useMemo(() => { | ||
| return formatProgressText(valueText, capacityText, numericCapacity); | ||
| }, [valueText, capacityText, numericCapacity]); | ||
|
|
||
| return ( | ||
| <ProgressContainer | ||
| displayText={displayText} | ||
| withCapacityUsage={withCapacityUsage} | ||
| className={className} | ||
| width={width} | ||
| > | ||
| <Progress value={clampedFillWidth} theme="success" size={size} /> | ||
| </ProgressContainer> | ||
| ); | ||
| } |
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,72 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {Progress} from '@gravity-ui/uikit'; | ||
|
|
||
| import {defaultFormatProgressValues} from '../../utils/progress'; | ||
| import {safeParseNumber} from '../../utils/utils'; | ||
| import {getMemorySegmentColor} from '../MemoryViewer/utils'; | ||
|
|
||
| import {ProgressContainer} from './ProgressContainer'; | ||
| import i18n from './i18n'; | ||
| import { | ||
| MAX_PERCENTAGE, | ||
| PROGRESS_SIZE, | ||
| formatDisplayValues, | ||
| formatProgressText, | ||
| } from './progressUtils'; | ||
| import type {ProgressWrapperStackProps} from './types'; | ||
|
|
||
| export function StackProgress({ | ||
| stack, | ||
| totalCapacity, | ||
| formatValues = defaultFormatProgressValues, | ||
| className, | ||
| width, | ||
| size = PROGRESS_SIZE, | ||
| withCapacityUsage = false, | ||
| }: ProgressWrapperStackProps) { | ||
| const displaySegments = React.useMemo(() => { | ||
| return stack.filter((segment) => !segment.isInfo && segment.value > 0); | ||
| }, [stack]); | ||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (displaySegments.length === 0) { | ||
| return <div className={className}>{i18n('alert_no-data')}</div>; | ||
| } | ||
|
|
||
| const totalValue = React.useMemo(() => { | ||
| return displaySegments.reduce((sum, segment) => sum + segment.value, 0); | ||
| }, [displaySegments]); | ||
|
|
||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const numericTotalCapacity = React.useMemo(() => { | ||
| return safeParseNumber(totalCapacity); | ||
| }, [totalCapacity]); | ||
|
|
||
| const maxValue = numericTotalCapacity || totalValue; | ||
|
|
||
| const stackElements = React.useMemo(() => { | ||
| return displaySegments.map((segment) => ({ | ||
| value: maxValue > 0 ? (segment.value / maxValue) * MAX_PERCENTAGE : 0, | ||
| color: getMemorySegmentColor(segment.key), | ||
| title: segment.label, | ||
| })); | ||
| }, [displaySegments, maxValue]); | ||
|
|
||
| const [totalValueText, totalCapacityText] = React.useMemo(() => { | ||
| return formatDisplayValues(totalValue, numericTotalCapacity || totalValue, formatValues); | ||
| }, [formatValues, totalValue, numericTotalCapacity]); | ||
|
|
||
| const displayText = React.useMemo(() => { | ||
| return formatProgressText(totalValueText, totalCapacityText, numericTotalCapacity || 0); | ||
| }, [totalValueText, totalCapacityText, numericTotalCapacity]); | ||
|
|
||
| return ( | ||
| <ProgressContainer | ||
| displayText={displayText} | ||
| withCapacityUsage={withCapacityUsage} | ||
| className={className} | ||
| width={width} | ||
| > | ||
| <Progress value={MAX_PERCENTAGE} stack={stackElements} size={size} /> | ||
| </ProgressContainer> | ||
| ); | ||
| } | ||
File renamed without changes.
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,11 @@ | ||
| import {registerKeysets} from '../../../utils/i18n'; | ||
|
|
||
| import en from './en.json'; | ||
|
|
||
| const COMPONENT = 'progress-wrapper'; | ||
|
|
||
| const keysets = { | ||
| en, | ||
| }; | ||
|
|
||
| export default registerKeysets(COMPONENT, keysets); |
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,18 @@ | ||
| // Main component - public API | ||
| export {ProgressWrapper} from './ProgressWrapper'; | ||
|
|
||
| // Individual components - for direct usage if needed | ||
| export {SingleProgress} from './SingleProgress'; | ||
| export {StackProgress} from './StackProgress'; | ||
| export {ProgressContainer} from './ProgressContainer'; | ||
|
|
||
| // Types - for consumers | ||
| export type { | ||
| ProgressWrapperProps, | ||
| ProgressWrapperSingleProps, | ||
| ProgressWrapperStackProps, | ||
| ProgressContainerProps, | ||
| } from './types'; | ||
|
|
||
| // Utils - for advanced usage | ||
| export * from './progressUtils'; |
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.