1+ import { useCallback } from 'react' ;
2+ import { useSearchParams } from 'react-router-dom' ;
13import styled from '@emotion/styled' ;
24
35import { Alert } from '@sentry/scraps/alert' ;
@@ -13,6 +15,7 @@ import {t} from 'sentry/locale';
1315import type { UseApiQueryResult } from 'sentry/utils/queryClient' ;
1416import type RequestError from 'sentry/utils/requestError/requestError' ;
1517import { useQueryParamState } from 'sentry/utils/url/useQueryParamState' ;
18+ import { BuildDetailsMetricCards } from 'sentry/views/preprod/buildDetails/main/buildDetailsMetricCards' ;
1619import { AppSizeInsights } from 'sentry/views/preprod/buildDetails/main/insights/appSizeInsights' ;
1720import { BuildError } from 'sentry/views/preprod/components/buildError' ;
1821import { BuildProcessing } from 'sentry/views/preprod/components/buildProcessing' ;
@@ -52,6 +55,12 @@ export function BuildDetailsMainContent(props: BuildDetailsMainContentProps) {
5255 isError : isAppSizeError ,
5356 error : appSizeError ,
5457 } = appSizeQuery ;
58+ const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
59+ const openInsightsSidebar = useCallback ( ( ) => {
60+ const next = new URLSearchParams ( searchParams ) ;
61+ next . set ( 'insights' , 'open' ) ;
62+ setSearchParams ( next ) ;
63+ } , [ searchParams , setSearchParams ] ) ;
5564
5665 // If the main data fetch fails, this component will not be rendered
5766 // so we don't handle 'isBuildDetailsError'.
@@ -107,13 +116,21 @@ export function BuildDetailsMainContent(props: BuildDetailsMainContentProps) {
107116
108117 if ( isLoadingRequests ) {
109118 return (
110- < Stack gap = "lg" width = "100%" >
111- < Flex width = "100%" justify = "between" align = "center" gap = "md" >
112- < Placeholder width = "92px" height = "40px" />
113- < Placeholder style = { { flex : 1 } } height = "40px" />
119+ < Stack gap = "xl" minHeight = "700px" width = "100%" >
120+ < Flex gap = "lg" wrap = "wrap" >
121+ < Placeholder style = { { flex : 1 } } height = "100px" />
122+ < Placeholder style = { { flex : 1 } } height = "100px" />
123+ < Placeholder style = { { flex : 1 } } height = "100px" />
114124 </ Flex >
115- < Placeholder width = "100%" height = "540px" />
116- < Placeholder height = "140px" />
125+ < Stack gap = "sm" >
126+ < Flex width = "100%" justify = "between" align = "center" gap = "md" >
127+ < Placeholder width = "92px" height = "40px" />
128+ < Placeholder style = { { flex : 1 } } height = "40px" />
129+ </ Flex >
130+ < Placeholder width = "100%" height = "540px" />
131+ < Placeholder height = "140px" />
132+ </ Stack >
133+ < Placeholder height = "200px" />
117134 </ Stack >
118135 ) ;
119136 }
@@ -204,7 +221,6 @@ export function BuildDetailsMainContent(props: BuildDetailsMainContentProps) {
204221 appSizeData . insights && totalSize > 0
205222 ? processInsights ( appSizeData . insights , totalSize )
206223 : [ ] ;
207-
208224 const categoriesEnabled =
209225 appSizeData . treemap . category_breakdown &&
210226 Object . keys ( appSizeData . treemap . category_breakdown ) . length > 0 ;
@@ -283,55 +299,63 @@ export function BuildDetailsMainContent(props: BuildDetailsMainContentProps) {
283299 }
284300
285301 return (
286- < Flex direction = "column" gap = "sm" minHeight = "700px" width = "100%" >
287- < Flex align = "center" gap = "md" >
288- { categoriesEnabled && (
289- < SegmentedControl value = { selectedContent } onChange = { handleContentChange } >
290- < SegmentedControl . Item key = "treemap" icon = { < IconGrid /> } />
291- < SegmentedControl . Item key = "categories" icon = { < IconGraphCircle /> } />
292- </ SegmentedControl >
293- ) }
294- { selectedContent === 'treemap' && (
295- < InputGroup style = { { flexGrow : 1 } } >
296- < InputGroup . LeadingItems >
297- < IconSearch />
298- </ InputGroup . LeadingItems >
299- < InputGroup . Input
300- placeholder = "Search files"
301- value = { searchQuery || '' }
302- onChange = { e => setSearchQuery ( e . target . value || undefined ) }
303- />
304- { searchQuery && (
305- < InputGroup . TrailingItems >
306- < Button
307- onClick = { ( ) => setSearchQuery ( undefined ) }
308- aria-label = "Clear search"
309- borderless
310- size = "zero"
311- >
312- < IconClose size = "sm" />
313- </ Button >
314- </ InputGroup . TrailingItems >
315- ) }
316- </ InputGroup >
317- ) }
318- </ Flex >
319- < ChartContainer > { visualizationContent } </ ChartContainer >
302+ < Stack gap = "xl" minHeight = "700px" width = "100%" >
303+ < BuildDetailsMetricCards
304+ sizeInfo = { sizeInfo }
305+ processedInsights = { processedInsights }
306+ totalSize = { totalSize }
307+ platform = { buildDetailsData ?. app_info ?. platform ?? null }
308+ onOpenInsightsSidebar = { openInsightsSidebar }
309+ />
320310
321- < Stack gap = "xl" >
311+ < Stack gap = "sm" >
312+ < Flex align = "center" gap = "md" >
313+ { categoriesEnabled && (
314+ < SegmentedControl value = { selectedContent } onChange = { handleContentChange } >
315+ < SegmentedControl . Item key = "treemap" icon = { < IconGrid /> } />
316+ < SegmentedControl . Item key = "categories" icon = { < IconGraphCircle /> } />
317+ </ SegmentedControl >
318+ ) }
319+ { selectedContent === 'treemap' && (
320+ < InputGroup style = { { flexGrow : 1 } } >
321+ < InputGroup . LeadingItems >
322+ < IconSearch />
323+ </ InputGroup . LeadingItems >
324+ < InputGroup . Input
325+ placeholder = "Search files"
326+ value = { searchQuery || '' }
327+ onChange = { e => setSearchQuery ( e . target . value || undefined ) }
328+ />
329+ { searchQuery && (
330+ < InputGroup . TrailingItems >
331+ < Button
332+ onClick = { ( ) => setSearchQuery ( undefined ) }
333+ aria-label = "Clear search"
334+ borderless
335+ size = "zero"
336+ >
337+ < IconClose size = "sm" />
338+ </ Button >
339+ </ InputGroup . TrailingItems >
340+ ) }
341+ </ InputGroup >
342+ ) }
343+ </ Flex >
344+ < ChartContainer > { visualizationContent } </ ChartContainer >
322345 { selectedContent === 'treemap' && appSizeData && (
323346 < AppSizeLegend
324347 root = { appSizeData . treemap . root }
325348 selectedCategories = { selectedCategories }
326349 onToggleCategory = { handleToggleCategory }
327350 />
328351 ) }
329- < AppSizeInsights
330- processedInsights = { processedInsights }
331- platform = { validatedPlatform ( buildDetailsData ?. app_info ?. platform ) }
332- />
333352 </ Stack >
334- </ Flex >
353+
354+ < AppSizeInsights
355+ processedInsights = { processedInsights }
356+ platform = { validatedPlatform ( buildDetailsData ?. app_info ?. platform ) }
357+ />
358+ </ Stack >
335359 ) ;
336360}
337361
0 commit comments