From dce24fdb9a1587ea85b21403e9b979970632dfc6 Mon Sep 17 00:00:00 2001 From: Manoj Vivek Date: Thu, 13 Feb 2025 23:19:28 +0530 Subject: [PATCH] Mini variant for the UtilizationGraph --- .../src/Skeletons/MetricsGraphSkeleton.tsx | 9 +++---- .../MetricsGraph/UtilizationMetrics/index.tsx | 6 ++--- .../MetricsGraph/useMetricsGraphDimensions.ts | 11 ++++++--- .../profile/src/MetricsGraphStrips/index.tsx | 2 +- .../ProfileSelector/MetricsGraphSection.tsx | 24 ++++++++++--------- .../profile/src/ProfileSelector/index.tsx | 4 ++-- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/ui/packages/shared/components/src/Skeletons/MetricsGraphSkeleton.tsx b/ui/packages/shared/components/src/Skeletons/MetricsGraphSkeleton.tsx index f14cc4d3c09..48a0191bd85 100644 --- a/ui/packages/shared/components/src/Skeletons/MetricsGraphSkeleton.tsx +++ b/ui/packages/shared/components/src/Skeletons/MetricsGraphSkeleton.tsx @@ -15,9 +15,10 @@ import cx from 'classnames'; interface Props { heightStyle?: string; isDarkMode: boolean; + isMini?: boolean; } -const MetricsGraphSkeleton = ({heightStyle, isDarkMode}: Props): JSX.Element => { +const MetricsGraphSkeleton = ({heightStyle, isDarkMode, isMini = false}: Props): JSX.Element => { return (
@@ -120,10 +121,10 @@ const MetricsGraphSkeleton = ({heightStyle, isDarkMode}: Props): JSX.Element => - - + {!isMini ? : null} + {!isMini ? : null} - + {!isMini ? : null} diff --git a/ui/packages/shared/profile/src/MetricsGraph/UtilizationMetrics/index.tsx b/ui/packages/shared/profile/src/MetricsGraph/UtilizationMetrics/index.tsx index ddae717c800..655dc9d5e80 100644 --- a/ui/packages/shared/profile/src/MetricsGraph/UtilizationMetrics/index.tsx +++ b/ui/packages/shared/profile/src/MetricsGraph/UtilizationMetrics/index.tsx @@ -485,19 +485,19 @@ const UtilizationMetrics = ({ utilizationMetricsLoading, }: Props): JSX.Element => { const {isDarkMode} = useParcaContext(); - const {width, height, margin, heightStyle} = useMetricsGraphDimensions(false); + const {width, height, margin, heightStyle} = useMetricsGraphDimensions(false, true); return ( {utilizationMetricsLoading === true ? ( - + ) : ( { +export const useMetricsGraphDimensions = ( + comparing: boolean, + isMini = false +): MetricsGraphDimensions => { + const maxHeight = isMini ? MINI_VARIANT_HEIGHT : MAX_HEIGHT; let {width} = useWindowSize(); const {profileExplorer} = useParcaContext(); if (profileExplorer == null) { @@ -40,7 +45,7 @@ export const useMetricsGraphDimensions = (comparing: boolean): MetricsGraphDimen if (comparing) { width = width / 2 - 32; } - const height = Math.min(width / 2.5, maxHeight); + const height = isMini ? MINI_VARIANT_HEIGHT : Math.min(width / 2.5, maxHeight); const heightStyle = `min(${maxHeight + margin}px, ${ comparing ? profileExplorer.metricsGraph.maxHeightStyle.compareMode diff --git a/ui/packages/shared/profile/src/MetricsGraphStrips/index.tsx b/ui/packages/shared/profile/src/MetricsGraphStrips/index.tsx index 22ed02a625b..4c659ec4788 100644 --- a/ui/packages/shared/profile/src/MetricsGraphStrips/index.tsx +++ b/ui/packages/shared/profile/src/MetricsGraphStrips/index.tsx @@ -107,7 +107,7 @@ export const MetricsGraphStrips = ({ {!isCollapsed ? ( void; + setDisplayHideMetricsGraphButton?: (show: boolean) => void; heightStyle: string; querySelection: QuerySelection; profileSelection: ProfileSelection | null; @@ -135,16 +135,18 @@ export function MetricsGraphSection({ return (
- + {setDisplayHideMetricsGraphButton != null ? ( + + ) : null} {showMetricsGraph && ( <>
diff --git a/ui/packages/shared/profile/src/ProfileSelector/index.tsx b/ui/packages/shared/profile/src/ProfileSelector/index.tsx index ff6ec5ff458..5f9ddd2108f 100644 --- a/ui/packages/shared/profile/src/ProfileSelector/index.tsx +++ b/ui/packages/shared/profile/src/ProfileSelector/index.tsx @@ -81,7 +81,7 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures { profileSelection: ProfileSelection | null; comparing: boolean; navigateTo: NavigateFunction; - setDisplayHideMetricsGraphButton: Dispatch>; + setDisplayHideMetricsGraphButton?: Dispatch>; suffix?: string; utilizationMetrics?: UtilizationMetrics[]; utilizationMetricsLoading?: boolean; @@ -138,7 +138,7 @@ const ProfileSelector = ({ data: profileTypesData, error, } = useProfileTypes(queryClient); - const {heightStyle} = useMetricsGraphDimensions(comparing); + const {heightStyle} = useMetricsGraphDimensions(comparing, utilizationMetrics != null); const {viewComponent} = useParcaContext(); const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');