Skip to content

Commit 44d7aa2

Browse files
authored
fix(perf): Re-add onboarding for landing v3 (#30675)
* fix(perf): Re-add onboarding for landing v3 Our existing onboarding component wasn't being shown on the new landing page if you didn't have events.
1 parent 3edae9c commit 44d7aa2

File tree

4 files changed

+88
-39
lines changed

4 files changed

+88
-39
lines changed

static/app/views/performance/content.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ function PerformanceContent({selection, location, demoMode}: Props) {
210210
organization={organization}
211211
location={location}
212212
projects={projects}
213+
selection={selection}
213214
/>
214215
);
215216
}

static/app/views/performance/landing/index.tsx

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {FC, useEffect, useRef} from 'react';
1+
import {FC, Fragment, useEffect, useRef} from 'react';
22
import {browserHistory} from 'react-router';
33
import styled from '@emotion/styled';
44
import {Location} from 'history';
@@ -15,14 +15,15 @@ import {MAX_QUERY_LENGTH} from 'sentry/constants';
1515
import {t} from 'sentry/locale';
1616
import {PageContent} from 'sentry/styles/organization';
1717
import space from 'sentry/styles/space';
18-
import {Organization, Project} from 'sentry/types';
18+
import {GlobalSelection, Organization, Project} from 'sentry/types';
1919
import EventView from 'sentry/utils/discover/eventView';
2020
import {generateAggregateFields} from 'sentry/utils/discover/fields';
2121
import {GenericQueryBatcher} from 'sentry/utils/performance/contexts/genericQueryBatcher';
2222
import useTeams from 'sentry/utils/useTeams';
2323

2424
import MetricsSearchBar from '../metricsSearchBar';
2525
import {MetricsSwitch, useMetricsSwitch} from '../metricsSwitch';
26+
import Onboarding from '../onboarding';
2627
import {getTransactionSearchQuery} from '../utils';
2728

2829
import {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>

tests/js/spec/views/performance/content.spec.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,34 @@ describe('Performance > Content', function () {
316316
wrapper.unmount();
317317
});
318318

319+
it('renders onboarding state for new landing when the selected project has no events', async function () {
320+
const projects = [
321+
TestStubs.Project({id: 1, firstTransactionEvent: false}),
322+
TestStubs.Project({id: 2, firstTransactionEvent: true}),
323+
];
324+
const data = initializeData(projects, {project: [1]}, [
325+
...FEATURES,
326+
'performance-landing-widgets',
327+
]);
328+
329+
const wrapper = mountWithTheme(
330+
<WrappedComponent
331+
organization={data.organization}
332+
location={data.router.location}
333+
/>,
334+
data.routerContext
335+
);
336+
await tick();
337+
338+
// onboarding should show.
339+
expect(wrapper.find('Onboarding')).toHaveLength(1);
340+
341+
// Chart and table should not show.
342+
expect(wrapper.find('ChartFooter')).toHaveLength(0);
343+
expect(wrapper.find('Table')).toHaveLength(0);
344+
wrapper.unmount();
345+
});
346+
319347
it('does not render onboarding for "my projects"', async function () {
320348
const projects = [
321349
TestStubs.Project({id: '1', firstTransactionEvent: false}),

tests/js/spec/views/performance/landing/index.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const WrappedComponent = ({data}) => {
2020
location={data.router.location}
2121
eventView={eventView}
2222
projects={data.projects}
23+
selection={eventView.getGlobalSelection()}
2324
shouldShowOnboarding={false}
2425
handleSearch={() => {}}
2526
handleTrendsClick={() => {}}

0 commit comments

Comments
 (0)