Skip to content

Commit 9032b4d

Browse files
authored
feat(nav): Open feedback in drawer (#85217)
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()`. This does some refactoring to the feedback onboarding (to make the content usable in both) and exports a `useFeedbackOnboarding()` hook that is used for the new nav.
1 parent 42293b0 commit 9032b4d

File tree

2 files changed

+61
-20
lines changed

2 files changed

+61
-20
lines changed

static/app/components/feedback/feedbackOnboarding/sidebar.tsx

+58-20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {CompactSelect} from 'sentry/components/compactSelect';
1010
import {FeedbackOnboardingLayout} from 'sentry/components/feedback/feedbackOnboarding/feedbackOnboardingLayout';
1111
import {CRASH_REPORT_HASH} from 'sentry/components/feedback/useFeedbackOnboarding';
1212
import RadioGroup from 'sentry/components/forms/controls/radioGroup';
13+
import useDrawer from 'sentry/components/globalDrawer';
1314
import IdBadge from 'sentry/components/idBadge';
1415
import LoadingIndicator from 'sentry/components/loadingIndicator';
1516
import {FeedbackOnboardingWebApiBanner} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
@@ -32,6 +33,8 @@ import {
3233
} from 'sentry/data/platformCategories';
3334
import platforms, {otherPlatform} from 'sentry/data/platforms';
3435
import {t, tct} from 'sentry/locale';
36+
import SidebarPanelStore from 'sentry/stores/sidebarPanelStore';
37+
import {useLegacyStore} from 'sentry/stores/useLegacyStore';
3538
import {space} from 'sentry/styles/space';
3639
import type {SelectValue} from 'sentry/types/core';
3740
import type {PlatformKey, Project} from 'sentry/types/project';
@@ -40,20 +43,69 @@ import {useLocation} from 'sentry/utils/useLocation';
4043
import useOrganization from 'sentry/utils/useOrganization';
4144
import useUrlParams from 'sentry/utils/useUrlParams';
4245

43-
function FeedbackOnboardingSidebar(props: CommonSidebarProps) {
46+
export function useFeedbackOnboardingDrawer() {
47+
const organization = useOrganization();
48+
const currentPanel = useLegacyStore(SidebarPanelStore);
49+
const isActive = currentPanel === SidebarPanelKey.FEEDBACK_ONBOARDING;
50+
const hasProjectAccess = organization.access.includes('project:read');
51+
52+
const {openDrawer} = useDrawer();
53+
54+
useEffect(() => {
55+
if (isActive && hasProjectAccess) {
56+
openDrawer(() => <SidebarContent />, {
57+
ariaLabel: t('Getting Started with User Feedback'),
58+
onClose: () => {
59+
SidebarPanelStore.hidePanel();
60+
},
61+
});
62+
}
63+
}, [isActive, hasProjectAccess, openDrawer]);
64+
}
65+
66+
// Used by legacy navigation
67+
function LegacyFeedbackOnboardingSidebar(props: CommonSidebarProps) {
4468
const {currentPanel, collapsed, hidePanel, orientation} = props;
4569
const organization = useOrganization();
4670

4771
const isActive = currentPanel === SidebarPanelKey.FEEDBACK_ONBOARDING;
4872
const hasProjectAccess = organization.access.includes('project:read');
4973

74+
if (!isActive || !hasProjectAccess) {
75+
return null;
76+
}
77+
78+
return (
79+
<TaskSidebarPanel
80+
orientation={orientation}
81+
collapsed={collapsed}
82+
hidePanel={hidePanel}
83+
>
84+
<SidebarContent />
85+
</TaskSidebarPanel>
86+
);
87+
}
88+
89+
function SidebarContent() {
90+
const organization = useOrganization();
91+
5092
const {allProjects, currentProject, setCurrentProject} = useCurrentProjectState({
51-
currentPanel,
93+
currentPanel: SidebarPanelKey.FEEDBACK_ONBOARDING,
5294
targetPanel: SidebarPanelKey.FEEDBACK_ONBOARDING,
5395
onboardingPlatforms: feedbackOnboardingPlatforms,
5496
allPlatforms: feedbackOnboardingPlatforms,
5597
});
5698

99+
useEffect(() => {
100+
// this tracks clicks from any source: feedback index, issue details feedback tab, banner callout, etc
101+
if (currentProject) {
102+
trackAnalytics('feedback.list-view-setup-sidebar', {
103+
organization,
104+
platform: currentProject?.platform ?? 'unknown',
105+
});
106+
}
107+
}, [currentProject, organization, setCurrentProject]);
108+
57109
const projectSelectOptions = useMemo(() => {
58110
const supportedProjectItems: Array<SelectValue<string>> = allProjects
59111
.sort((aProject, bProject) => {
@@ -82,26 +134,12 @@ function FeedbackOnboardingSidebar(props: CommonSidebarProps) {
82134
];
83135
}, [allProjects]);
84136

85-
useEffect(() => {
86-
if (isActive && currentProject && hasProjectAccess) {
87-
// this tracks clicks from any source: feedback index, issue details feedback tab, banner callout, etc
88-
trackAnalytics('feedback.list-view-setup-sidebar', {
89-
organization,
90-
platform: currentProject?.platform ?? 'unknown',
91-
});
92-
}
93-
}, [organization, currentProject, isActive, hasProjectAccess]);
94-
95-
if (!isActive || !hasProjectAccess || !currentProject) {
137+
if (!currentProject) {
96138
return null;
97139
}
98140

99141
return (
100-
<TaskSidebarPanel
101-
orientation={orientation}
102-
collapsed={collapsed}
103-
hidePanel={hidePanel}
104-
>
142+
<Fragment>
105143
<TopRightBackgroundImage src={HighlightTopRightPattern} />
106144
<TaskList>
107145
<Heading>{t('Getting Started with User Feedback')}</Heading>
@@ -140,7 +178,7 @@ function FeedbackOnboardingSidebar(props: CommonSidebarProps) {
140178
</HeaderActions>
141179
<OnboardingContent currentProject={currentProject} />
142180
</TaskList>
143-
</TaskSidebarPanel>
181+
</Fragment>
144182
);
145183
}
146184

@@ -417,4 +455,4 @@ const StyledRadioGroup = styled(RadioGroup)`
417455
padding: ${space(1)} 0;
418456
`;
419457

420-
export default FeedbackOnboardingSidebar;
458+
export default LegacyFeedbackOnboardingSidebar;

static/app/views/organizationLayout/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from '@emotion/styled';
22

3+
import {useFeedbackOnboardingDrawer} from 'sentry/components/feedback/feedbackOnboarding/sidebar';
34
import Footer from 'sentry/components/footer';
45
import HookOrDefault from 'sentry/components/hookOrDefault';
56
import Nav from 'sentry/components/nav';
@@ -56,6 +57,8 @@ interface LayoutProps extends Props {
5657
}
5758

5859
function AppLayout({children, organization}: LayoutProps) {
60+
useFeedbackOnboardingDrawer();
61+
5962
return (
6063
<NavContextProvider>
6164
<AppContainer>

0 commit comments

Comments
 (0)