Skip to content

Commit d4edc94

Browse files
authored
feat(nav): Update replay onboarding to use drawer (#85267)
The old navigation sidebar has been the component responsible for displaying the onboarding panels. Since we are moving to a new nav component, I'm going to be moving all the existing onboarding panels over to our new useDrawer().
1 parent a2e4b5b commit d4edc94

File tree

3 files changed

+73
-15
lines changed

3 files changed

+73
-15
lines changed

Diff for: static/app/components/feedback/feedbackOnboarding/sidebar.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,26 @@ export function useFeedbackOnboardingDrawer() {
5353

5454
useEffect(() => {
5555
if (isActive && hasProjectAccess) {
56-
openDrawer(() => <SidebarContent />, {
56+
openDrawer(() => <DrawerContent />, {
5757
ariaLabel: t('Getting Started with User Feedback'),
58-
onClose: () => {
59-
SidebarPanelStore.hidePanel();
60-
},
58+
// Prevent the drawer from closing when the query params change
59+
shouldCloseOnLocationChange: location =>
60+
location.pathname !== window.location.pathname,
6161
});
6262
}
6363
}, [isActive, hasProjectAccess, openDrawer]);
6464
}
6565

66+
function DrawerContent() {
67+
useEffect(() => {
68+
return () => {
69+
SidebarPanelStore.hidePanel();
70+
};
71+
}, []);
72+
73+
return <SidebarContent />;
74+
}
75+
6676
// Used by legacy navigation
6777
function LegacyFeedbackOnboardingSidebar(props: CommonSidebarProps) {
6878
const {currentPanel, collapsed, hidePanel, orientation} = props;

Diff for: static/app/components/replaysOnboarding/sidebar.tsx

+57-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {ReactNode} from 'react';
2-
import {Fragment, useMemo, useState} from 'react';
2+
import {Fragment, useEffect, useMemo, useState} from 'react';
33
import styled from '@emotion/styled';
44
import {PlatformIcon} from 'platformicons';
55

@@ -8,6 +8,7 @@ import HighlightTopRightPattern from 'sentry-images/pattern/highlight-top-right.
88
import {LinkButton} from 'sentry/components/button';
99
import {CompactSelect} from 'sentry/components/compactSelect';
1010
import RadioGroup from 'sentry/components/forms/controls/radioGroup';
11+
import useDrawer from 'sentry/components/globalDrawer';
1112
import IdBadge from 'sentry/components/idBadge';
1213
import LoadingIndicator from 'sentry/components/loadingIndicator';
1314
import useCurrentProjectState from 'sentry/components/onboarding/gettingStartedDoc/utils/useCurrentProjectState';
@@ -29,19 +30,67 @@ import {
2930
} from 'sentry/data/platformCategories';
3031
import platforms, {otherPlatform} from 'sentry/data/platforms';
3132
import {t, tct} from 'sentry/locale';
33+
import SidebarPanelStore from 'sentry/stores/sidebarPanelStore';
34+
import {useLegacyStore} from 'sentry/stores/useLegacyStore';
3235
import {space} from 'sentry/styles/space';
3336
import type {SelectValue} from 'sentry/types/core';
3437
import type {PlatformKey, Project} from 'sentry/types/project';
3538
import useOrganization from 'sentry/utils/useOrganization';
3639
import useUrlParams from 'sentry/utils/useUrlParams';
3740

38-
function ReplaysOnboardingSidebar(props: CommonSidebarProps) {
41+
export function useReplaysOnboardingDrawer() {
42+
const organization = useOrganization();
43+
const currentPanel = useLegacyStore(SidebarPanelStore);
44+
const isActive = currentPanel === SidebarPanelKey.REPLAYS_ONBOARDING;
45+
const hasProjectAccess = organization.access.includes('project:read');
46+
47+
const {openDrawer} = useDrawer();
48+
49+
useEffect(() => {
50+
if (isActive && hasProjectAccess) {
51+
openDrawer(() => <DrawerContent />, {
52+
ariaLabel: t('Getting Started with Session Replay'),
53+
// Prevent the drawer from closing when the query params change
54+
shouldCloseOnLocationChange: location =>
55+
location.pathname !== window.location.pathname,
56+
});
57+
}
58+
}, [isActive, hasProjectAccess, openDrawer]);
59+
}
60+
61+
function DrawerContent() {
62+
useEffect(() => {
63+
return () => {
64+
SidebarPanelStore.hidePanel();
65+
};
66+
}, []);
67+
68+
return <SidebarContent />;
69+
}
70+
71+
function LegacyReplaysOnboardingSidebar(props: CommonSidebarProps) {
3972
const {currentPanel, collapsed, hidePanel, orientation} = props;
4073
const organization = useOrganization();
4174

4275
const isActive = currentPanel === SidebarPanelKey.REPLAYS_ONBOARDING;
4376
const hasProjectAccess = organization.access.includes('project:read');
4477

78+
if (!isActive || !hasProjectAccess) {
79+
return null;
80+
}
81+
82+
return (
83+
<TaskSidebarPanel
84+
orientation={orientation}
85+
collapsed={collapsed}
86+
hidePanel={hidePanel}
87+
>
88+
<SidebarContent />
89+
</TaskSidebarPanel>
90+
);
91+
}
92+
93+
function SidebarContent() {
4594
const {
4695
hasDocs,
4796
projects,
@@ -51,7 +100,7 @@ function ReplaysOnboardingSidebar(props: CommonSidebarProps) {
51100
supportedProjects,
52101
unsupportedProjects,
53102
} = useCurrentProjectState({
54-
currentPanel,
103+
currentPanel: SidebarPanelKey.REPLAYS_ONBOARDING,
55104
targetPanel: SidebarPanelKey.REPLAYS_ONBOARDING,
56105
onboardingPlatforms: replayOnboardingPlatforms,
57106
allPlatforms: replayPlatforms,
@@ -102,16 +151,13 @@ function ReplaysOnboardingSidebar(props: CommonSidebarProps) {
102151
}, [supportedProjects, unsupportedProjects]);
103152

104153
const selectedProject = currentProject ?? projects[0] ?? allProjects[0];
105-
if (!isActive || !hasProjectAccess || !selectedProject) {
154+
155+
if (!selectedProject) {
106156
return null;
107157
}
108158

109159
return (
110-
<TaskSidebarPanel
111-
orientation={orientation}
112-
collapsed={collapsed}
113-
hidePanel={hidePanel}
114-
>
160+
<Fragment>
115161
<TopRightBackgroundImage src={HighlightTopRightPattern} />
116162
<TaskList>
117163
<Heading>{t('Getting Started with Session Replay')}</Heading>
@@ -150,7 +196,7 @@ function ReplaysOnboardingSidebar(props: CommonSidebarProps) {
150196
</HeaderActions>
151197
<OnboardingContent currentProject={selectedProject} hasDocs={hasDocs} />
152198
</TaskList>
153-
</TaskSidebarPanel>
199+
</Fragment>
154200
);
155201
}
156202

@@ -445,4 +491,4 @@ const StyledRadioGroup = styled(RadioGroup)`
445491
padding: ${space(1)} 0;
446492
`;
447493

448-
export default ReplaysOnboardingSidebar;
494+
export default LegacyReplaysOnboardingSidebar;

Diff for: static/app/views/organizationLayout/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Footer from 'sentry/components/footer';
55
import HookOrDefault from 'sentry/components/hookOrDefault';
66
import Nav from 'sentry/components/nav';
77
import {NavContextProvider} from 'sentry/components/nav/context';
8+
import {useReplaysOnboardingDrawer} from 'sentry/components/replaysOnboarding/sidebar';
89
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
910
import Sidebar from 'sentry/components/sidebar';
1011
import type {Organization} from 'sentry/types/organization';
@@ -58,6 +59,7 @@ interface LayoutProps extends Props {
5859

5960
function AppLayout({children, organization}: LayoutProps) {
6061
useFeedbackOnboardingDrawer();
62+
useReplaysOnboardingDrawer();
6163

6264
return (
6365
<NavContextProvider>

0 commit comments

Comments
 (0)