1- import { FC , useEffect , useRef } from 'react' ;
1+ import { FC , Fragment , useEffect , useRef } from 'react' ;
22import { browserHistory } from 'react-router' ;
33import styled from '@emotion/styled' ;
44import { Location } from 'history' ;
@@ -15,14 +15,15 @@ import {MAX_QUERY_LENGTH} from 'sentry/constants';
1515import { t } from 'sentry/locale' ;
1616import { PageContent } from 'sentry/styles/organization' ;
1717import space from 'sentry/styles/space' ;
18- import { Organization , Project } from 'sentry/types' ;
18+ import { GlobalSelection , Organization , Project } from 'sentry/types' ;
1919import EventView from 'sentry/utils/discover/eventView' ;
2020import { generateAggregateFields } from 'sentry/utils/discover/fields' ;
2121import { GenericQueryBatcher } from 'sentry/utils/performance/contexts/genericQueryBatcher' ;
2222import useTeams from 'sentry/utils/useTeams' ;
2323
2424import MetricsSearchBar from '../metricsSearchBar' ;
2525import { MetricsSwitch , useMetricsSwitch } from '../metricsSwitch' ;
26+ import Onboarding from '../onboarding' ;
2627import { getTransactionSearchQuery } from '../utils' ;
2728
2829import { AllTransactionsView } from './views/allTransactionsView' ;
@@ -43,6 +44,7 @@ type Props = {
4344 eventView : EventView ;
4445 location : Location ;
4546 projects : Project [ ] ;
47+ selection : GlobalSelection ;
4648 shouldShowOnboarding : boolean ;
4749 setError : ( msg : string | undefined ) => void ;
4850 handleSearch : ( searchQuery : string ) => void ;
@@ -151,45 +153,62 @@ export function PerformanceLanding(props: Props) {
151153 < Layout . Body >
152154 < Layout . Main fullWidth >
153155 < GlobalSdkUpdateAlert />
154- < SearchContainerWithFilter >
155- { isMetricsData ? (
156- < MetricsSearchBar
157- searchSource = "performance_landing_metrics"
158- orgSlug = { organization . slug }
159- query = { filterString }
160- onSearch = { handleSearch }
161- maxQueryLength = { MAX_QUERY_LENGTH }
162- projectIds = { eventView . project }
163- />
164- ) : (
165- < SearchBar
166- searchSource = "performance_landing"
167- organization = { organization }
168- projectIds = { eventView . project }
169- query = { filterString }
170- fields = { generateAggregateFields (
171- organization ,
172- [ ...eventView . fields , { field : 'tps()' } ] ,
173- [ 'epm()' , 'eps()' ]
174- ) }
175- onSearch = { handleSearch }
176- maxQueryLength = { MAX_QUERY_LENGTH }
177- />
178- ) }
179- </ SearchContainerWithFilter >
180- { initiallyLoaded ? (
181- < TeamKeyTransactionManager . Provider
156+ { showOnboarding ? (
157+ < Onboarding
182158 organization = { organization }
183- teams = { teams }
184- selectedTeams = { [ 'myteams' ] }
185- selectedProjects = { eventView . project . map ( String ) }
186- >
187- < GenericQueryBatcher >
188- < ViewComponent { ...props } />
189- </ GenericQueryBatcher >
190- </ TeamKeyTransactionManager . Provider >
159+ project = {
160+ props . selection . projects . length > 0
161+ ? // If some projects selected, use the first selection
162+ projects . find (
163+ project => props . selection . projects [ 0 ] . toString ( ) === project . id
164+ ) || projects [ 0 ]
165+ : // Otherwise, use the first project in the org
166+ projects [ 0 ]
167+ }
168+ />
191169 ) : (
192- < LoadingIndicator />
170+ < Fragment >
171+ < SearchContainerWithFilter >
172+ { isMetricsData ? (
173+ < MetricsSearchBar
174+ searchSource = "performance_landing_metrics"
175+ orgSlug = { organization . slug }
176+ query = { filterString }
177+ onSearch = { handleSearch }
178+ maxQueryLength = { MAX_QUERY_LENGTH }
179+ projectIds = { eventView . project }
180+ />
181+ ) : (
182+ < SearchBar
183+ searchSource = "performance_landing"
184+ organization = { organization }
185+ projectIds = { eventView . project }
186+ query = { filterString }
187+ fields = { generateAggregateFields (
188+ organization ,
189+ [ ...eventView . fields , { field : 'tps()' } ] ,
190+ [ 'epm()' , 'eps()' ]
191+ ) }
192+ onSearch = { handleSearch }
193+ maxQueryLength = { MAX_QUERY_LENGTH }
194+ />
195+ ) }
196+ </ SearchContainerWithFilter >
197+ { initiallyLoaded ? (
198+ < TeamKeyTransactionManager . Provider
199+ organization = { organization }
200+ teams = { teams }
201+ selectedTeams = { [ 'myteams' ] }
202+ selectedProjects = { eventView . project . map ( String ) }
203+ >
204+ < GenericQueryBatcher >
205+ < ViewComponent { ...props } />
206+ </ GenericQueryBatcher >
207+ </ TeamKeyTransactionManager . Provider >
208+ ) : (
209+ < LoadingIndicator />
210+ ) }
211+ </ Fragment >
193212 ) }
194213 </ Layout . Main >
195214 </ Layout . Body >
0 commit comments