123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966 |
- import {Fragment, useCallback, useContext, useEffect} from 'react';
- import {css} from '@emotion/react';
- import styled from '@emotion/styled';
- import {hideSidebar, showSidebar} from 'sentry/actionCreators/preferences';
- import Feature from 'sentry/components/acl/feature';
- import GuideAnchor from 'sentry/components/assistant/guideAnchor';
- import {Chevron} from 'sentry/components/chevron';
- import FeedbackOnboardingSidebar from 'sentry/components/feedback/feedbackOnboarding/sidebar';
- import Hook from 'sentry/components/hook';
- import {OnboardingContext} from 'sentry/components/onboarding/onboardingContext';
- import {getMergedTasks} from 'sentry/components/onboardingWizard/taskConfig';
- import PerformanceOnboardingSidebar from 'sentry/components/performanceOnboarding/sidebar';
- import ReplaysOnboardingSidebar from 'sentry/components/replaysOnboarding/sidebar';
- import {
- ExpandedContext,
- ExpandedContextProvider,
- } from 'sentry/components/sidebar/expandedContextProvider';
- import {isDone} from 'sentry/components/sidebar/utils';
- import {
- IconDashboard,
- IconGraph,
- IconIssues,
- IconLightning,
- IconMegaphone,
- IconPlay,
- IconProfiling,
- IconProject,
- IconReleases,
- IconSearch,
- IconSettings,
- IconSiren,
- IconStats,
- IconSupport,
- IconTelescope,
- IconTimer,
- } from 'sentry/icons';
- import {IconRobot} from 'sentry/icons/iconRobot';
- import {t} from 'sentry/locale';
- import ConfigStore from 'sentry/stores/configStore';
- import DemoWalkthroughStore from 'sentry/stores/demoWalkthroughStore';
- import HookStore from 'sentry/stores/hookStore';
- import PreferencesStore from 'sentry/stores/preferencesStore';
- import SidebarPanelStore from 'sentry/stores/sidebarPanelStore';
- import {useLegacyStore} from 'sentry/stores/useLegacyStore';
- import {space} from 'sentry/styles/space';
- import type {Organization} from 'sentry/types/organization';
- import {isDemoWalkthrough} from 'sentry/utils/demoMode';
- import {getDiscoverLandingUrl} from 'sentry/utils/discover/urls';
- import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
- import {hasCustomMetrics} from 'sentry/utils/metrics/features';
- import theme from 'sentry/utils/theme';
- import {useLocation} from 'sentry/utils/useLocation';
- import useMedia from 'sentry/utils/useMedia';
- import useOrganization from 'sentry/utils/useOrganization';
- import useProjects from 'sentry/utils/useProjects';
- import {normalizeUrl} from 'sentry/utils/withDomainRequired';
- import {releaseLevelAsBadgeProps as LLMModuleBadgeProps} from 'sentry/views/llmMonitoring/settings';
- import MetricsOnboardingSidebar from 'sentry/views/metrics/ddmOnboarding/sidebar';
- import {releaseLevelAsBadgeProps as CacheModuleBadgeProps} from 'sentry/views/performance/cache/settings';
- import {releaseLevelAsBadgeProps as QueuesModuleBadgeProps} from 'sentry/views/performance/queues/settings';
- import {
- MODULE_TITLES,
- useModuleTitle,
- } from 'sentry/views/performance/utils/useModuleTitle';
- import {useModuleURLBuilder} from 'sentry/views/performance/utils/useModuleURL';
- import {ModuleName} from 'sentry/views/starfish/types';
- import {ProfilingOnboardingSidebar} from '../profiling/ProfilingOnboarding/profilingOnboardingSidebar';
- import Broadcasts from './broadcasts';
- import SidebarHelp from './help';
- import OnboardingStatus from './onboardingStatus';
- import ServiceIncidents from './serviceIncidents';
- import {SidebarAccordion} from './sidebarAccordion';
- import SidebarDropdown from './sidebarDropdown';
- import SidebarItem from './sidebarItem';
- import type {SidebarOrientation} from './types';
- import {SidebarPanelKey} from './types';
- function activatePanel(panel: SidebarPanelKey) {
- SidebarPanelStore.activatePanel(panel);
- }
- function togglePanel(panel: SidebarPanelKey) {
- SidebarPanelStore.togglePanel(panel);
- }
- function hidePanel(hash?: string) {
- SidebarPanelStore.hidePanel(hash);
- }
- function useOpenOnboardingSidebar(organization?: Organization) {
- const onboardingContext = useContext(OnboardingContext);
- const {projects: project} = useProjects();
- const location = useLocation();
- const openOnboardingSidebar = (() => {
- if (location?.hash === '#welcome') {
- if (organization && !ConfigStore.get('demoMode')) {
- const tasks = getMergedTasks({
- organization,
- projects: project,
- onboardingContext,
- });
- const allDisplayedTasks = tasks
- .filter(task => task.display)
- .filter(task => !task.renderCard);
- const doneTasks = allDisplayedTasks.filter(isDone);
- return !(doneTasks.length >= allDisplayedTasks.length);
- }
- return true;
- }
- return false;
- })();
- useEffect(() => {
- if (openOnboardingSidebar) {
- activatePanel(SidebarPanelKey.ONBOARDING_WIZARD);
- }
- }, [openOnboardingSidebar]);
- }
- function Sidebar() {
- const location = useLocation();
- const preferences = useLegacyStore(PreferencesStore);
- const activePanel = useLegacyStore(SidebarPanelStore);
- const organization = useOrganization({allowNull: true});
- const {shouldAccordionFloat} = useContext(ExpandedContext);
- const resourceModuleTitle = useModuleTitle(ModuleName.RESOURCE);
- const isSelfHostedErrorsOnly = ConfigStore.get('isSelfHostedErrorsOnly');
- const collapsed = !!preferences.collapsed;
- const horizontal = useMedia(`(max-width: ${theme.breakpoints.medium})`);
- // Avoid showing superuser UI on self-hosted instances
- const showSuperuserWarning = () => {
- return isActiveSuperuser() && !ConfigStore.get('isSelfHosted');
- };
- // Avoid showing superuser UI on certain organizations
- const isExcludedOrg = () => {
- return HookStore.get('component:superuser-warning-excluded')[0]?.(organization);
- };
- useOpenOnboardingSidebar();
- const toggleCollapse = useCallback(() => {
- if (collapsed) {
- showSidebar();
- } else {
- hideSidebar();
- }
- }, [collapsed]);
- // Close panel on any navigation
- useEffect(() => void hidePanel(), [location?.pathname]);
- // Add classname to body
- useEffect(() => {
- const bcl = document.body.classList;
- bcl.add('body-sidebar');
- return () => bcl.remove('body-sidebar');
- }, []);
- useEffect(() => {
- Object.values(SidebarPanelKey).forEach(key => {
- if (location?.hash === `#sidebar-${key}`) {
- togglePanel(key);
- }
- });
- }, [location?.hash]);
- // Add sidebar collapse classname to body
- useEffect(() => {
- const bcl = document.body.classList;
- if (collapsed) {
- bcl.add('collapsed');
- } else {
- bcl.remove('collapsed');
- }
- return () => bcl.remove('collapsed');
- }, [collapsed]);
- const hasPanel = !!activePanel;
- const hasOrganization = !!organization;
- const orientation: SidebarOrientation = horizontal ? 'top' : 'left';
- const sidebarItemProps = {
- orientation,
- collapsed,
- hasPanel,
- organization,
- };
- // New hierarchy organizes current links into two accordions: "Explore" and "Insights". This means setting up different sidebar groupings, and changing some link icons to small dots, since they now live under an accordion
- const hasNewSidebarHierarchy =
- hasOrganization && organization.features.includes('performance-insights');
- const sidebarAnchor = isDemoWalkthrough() ? (
- <GuideAnchor target="projects" disabled={!DemoWalkthroughStore.get('sidebar')}>
- {t('Projects')}
- </GuideAnchor>
- ) : (
- <GuideAnchor target="projects">{t('Projects')}</GuideAnchor>
- );
- const projects = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- index
- icon={<IconProject />}
- label={sidebarAnchor}
- to={`/organizations/${organization.slug}/projects/`}
- id="projects"
- />
- );
- const issues = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconIssues />}
- label={<GuideAnchor target="issues">{t('Issues')}</GuideAnchor>}
- to={`/organizations/${organization.slug}/issues/`}
- search="?referrer=sidebar"
- id="issues"
- />
- );
- const discover2 = hasOrganization && (
- <Feature
- hookName="feature-disabled:discover2-sidebar-item"
- features="discover-basic"
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- icon={hasNewSidebarHierarchy ? <SubitemDot collapsed /> : <IconTelescope />}
- label={<GuideAnchor target="discover">{t('Discover')}</GuideAnchor>}
- to={getDiscoverLandingUrl(organization)}
- id="discover-v2"
- />
- </Feature>
- );
- const moduleURLBuilder = useModuleURLBuilder(true);
- const queries = hasOrganization && (
- <Feature key="db" features="insights-entry-points" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- label={
- <GuideAnchor target="performance-database">{MODULE_TITLES.db}</GuideAnchor>
- }
- to={`/organizations/${organization.slug}/${moduleURLBuilder('db')}/`}
- id="performance-database"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const requests = hasOrganization && (
- <Feature key="http" features="insights-entry-points" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- label={<GuideAnchor target="performance-http">{MODULE_TITLES.http}</GuideAnchor>}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('http')}/`}
- id="performance-http"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const caches = hasOrganization && (
- <Feature
- key="cache"
- features={['insights-entry-points', 'performance-cache-view']}
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- label={
- <GuideAnchor target="performance-cache">{MODULE_TITLES.cache}</GuideAnchor>
- }
- to={`/organizations/${organization.slug}/${moduleURLBuilder('cache')}/`}
- id="performance-cache"
- icon={<SubitemDot collapsed />}
- {...CacheModuleBadgeProps}
- />
- </Feature>
- );
- const webVitals = hasOrganization && (
- <Feature key="vital" features="insights-entry-points" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- label={
- <GuideAnchor target="performance-webvitals">{MODULE_TITLES.vital}</GuideAnchor>
- }
- to={`/organizations/${organization.slug}/${moduleURLBuilder('vital')}/`}
- id="performance-webvitals"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const queues = hasOrganization && (
- <Feature
- key="queue"
- features={['insights-entry-points', 'performance-queues-view']}
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- label={
- <GuideAnchor target="performance-queues">{MODULE_TITLES.queue}</GuideAnchor>
- }
- {...QueuesModuleBadgeProps}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('queue')}/`}
- id="performance-queues"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const screenLoads = hasOrganization && (
- <Feature
- key="screen_load"
- features="insights-entry-points"
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- label={MODULE_TITLES.screen_load}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('screen_load')}/`}
- id="performance-mobile-screens"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const appStarts = hasOrganization && (
- <Feature key="app_start" features="insights-entry-points" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- label={MODULE_TITLES.app_start}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('app_start')}/`}
- id="performance-mobile-app-startup"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const mobileUI = hasOrganization && (
- <Feature
- key="mobile-ui"
- features={['insights-entry-points', 'starfish-mobile-ui-module']}
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- label={MODULE_TITLES['mobile-ui']}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('mobile-ui')}/`}
- id="performance-mobile-ui"
- icon={<SubitemDot collapsed />}
- isAlpha
- />
- </Feature>
- );
- const resources = hasOrganization && (
- <Feature key="resource" features="insights-entry-points">
- <SidebarItem
- {...sidebarItemProps}
- label={<GuideAnchor target="starfish">{resourceModuleTitle}</GuideAnchor>}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('resource')}/`}
- id="performance-browser-resources"
- icon={<SubitemDot collapsed />}
- />
- </Feature>
- );
- const traces = hasOrganization && (
- <Feature features="performance-trace-explorer">
- <SidebarItem
- {...sidebarItemProps}
- label={<GuideAnchor target="traces">{t('Traces')}</GuideAnchor>}
- to={`/organizations/${organization.slug}/traces/`}
- id="performance-trace-explorer"
- icon={<SubitemDot collapsed />}
- isNew
- />
- </Feature>
- );
- const llmMonitoring = hasOrganization && (
- <Feature
- features={['insights-entry-points', 'ai-analytics']}
- organization={organization}
- >
- <SidebarItem
- {...sidebarItemProps}
- icon={hasNewSidebarHierarchy ? <SubitemDot collapsed /> : <IconRobot />}
- label={MODULE_TITLES.ai}
- {...LLMModuleBadgeProps}
- to={`/organizations/${organization.slug}/${moduleURLBuilder('ai')}/`}
- id="llm-monitoring"
- />
- </Feature>
- );
- const performance = hasOrganization && (
- <Feature
- hookName="feature-disabled:performance-sidebar-item"
- features="performance-view"
- organization={organization}
- >
- {(() => {
- // If the client has the old sidebar hierarchy _and_ something to show inside the Performance dropdown, render an accordion.
- if (
- !hasNewSidebarHierarchy &&
- (organization.features.includes('insights-entry-points') ||
- organization.features.includes('performance-cache-view') ||
- organization.features.includes('performance-queues-view') ||
- organization.features.includes('performance-trace-explorer'))
- ) {
- return (
- <SidebarAccordion
- {...sidebarItemProps}
- icon={<IconLightning />}
- label={<GuideAnchor target="performance">{t('Performance')}</GuideAnchor>}
- to={`/organizations/${organization.slug}/performance/`}
- id="performance"
- exact={!shouldAccordionFloat}
- >
- {queries}
- {requests}
- {caches}
- {webVitals}
- {queues}
- {screenLoads}
- {appStarts}
- {resources}
- {mobileUI}
- {traces}
- </SidebarAccordion>
- );
- }
- // Otherwise, show a regular sidebar link to the Performance landing page
- return (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconLightning />}
- label={<GuideAnchor target="performance">{t('Performance')}</GuideAnchor>}
- to={`/organizations/${organization.slug}/performance/`}
- id="performance"
- />
- );
- })()}
- </Feature>
- );
- const releases = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconReleases />}
- label={<GuideAnchor target="releases">{t('Releases')}</GuideAnchor>}
- to={`/organizations/${organization.slug}/releases/`}
- id="releases"
- />
- );
- const userFeedback = hasOrganization && (
- <Feature features="old-user-feedback" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconSupport />}
- label={t('User Feedback')}
- to={`/organizations/${organization.slug}/user-feedback/`}
- id="user-feedback"
- />
- </Feature>
- );
- const feedback = hasOrganization && (
- <Feature features="user-feedback-ui" organization={organization}>
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconMegaphone />}
- label={t('User Feedback')}
- variant="short"
- to={`/organizations/${organization.slug}/feedback/`}
- id="feedback"
- />
- </Feature>
- );
- const alerts = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconSiren />}
- label={t('Alerts')}
- to={`/organizations/${organization.slug}/alerts/rules/`}
- id="alerts"
- />
- );
- const monitors = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconTimer />}
- label={t('Crons')}
- to={`/organizations/${organization.slug}/crons/`}
- id="crons"
- />
- );
- const replays = hasOrganization && (
- <Feature
- hookName="feature-disabled:replay-sidebar-item"
- features="session-replay-ui"
- organization={organization}
- requireAll={false}
- >
- <SidebarItem
- {...sidebarItemProps}
- icon={hasNewSidebarHierarchy ? <SubitemDot collapsed /> : <IconPlay />}
- label={t('Replays')}
- to={`/organizations/${organization.slug}/replays/`}
- id="replays"
- />
- </Feature>
- );
- const metricsPath = `/organizations/${organization?.slug}/metrics/`;
- const metrics = hasOrganization && hasCustomMetrics(organization) && (
- <SidebarItem
- {...sidebarItemProps}
- icon={hasNewSidebarHierarchy ? <SubitemDot collapsed /> : <IconGraph />}
- label={t('Metrics')}
- to={metricsPath}
- search={location?.pathname === normalizeUrl(metricsPath) ? location.search : ''}
- id="metrics"
- isBeta
- />
- );
- const dashboards = hasOrganization && (
- <Feature
- hookName="feature-disabled:dashboards-sidebar-item"
- features={['discover', 'discover-query', 'dashboards-basic', 'dashboards-edit']}
- organization={organization}
- requireAll={false}
- >
- <SidebarItem
- {...sidebarItemProps}
- index
- icon={<IconDashboard />}
- label={t('Dashboards')}
- to={`/organizations/${organization.slug}/dashboards/`}
- id="customizable-dashboards"
- />
- </Feature>
- );
- const profiling = hasOrganization && (
- <Feature
- hookName="feature-disabled:profiling-sidebar-item"
- features="profiling"
- organization={organization}
- requireAll={false}
- >
- <SidebarItem
- {...sidebarItemProps}
- index
- icon={hasNewSidebarHierarchy ? <SubitemDot collapsed /> : <IconProfiling />}
- label={hasNewSidebarHierarchy ? t('Profiles') : t('Profiling')}
- to={`/organizations/${organization.slug}/profiling/`}
- id="profiling"
- />
- </Feature>
- );
- const stats = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconStats />}
- label={t('Stats')}
- to={`/organizations/${organization.slug}/stats/`}
- id="stats"
- />
- );
- const settings = hasOrganization && (
- <SidebarItem
- {...sidebarItemProps}
- icon={<IconSettings />}
- label={t('Settings')}
- to={`/settings/${organization.slug}/`}
- id="settings"
- />
- );
- const insights = hasOrganization && (
- <Feature key="insights" features="insights-entry-points" organization={organization}>
- <SidebarAccordion
- {...sidebarItemProps}
- icon={<IconGraph />}
- label={<GuideAnchor target="insights">{t('Insights')}</GuideAnchor>}
- id="insights"
- initiallyExpanded={false}
- isNew
- exact={!shouldAccordionFloat}
- >
- {requests}
- {queries}
- {resources}
- {appStarts}
- {screenLoads}
- {webVitals}
- {caches}
- {queues}
- {mobileUI}
- {llmMonitoring}
- </SidebarAccordion>
- </Feature>
- );
- const explore = (
- <SidebarAccordion
- {...sidebarItemProps}
- icon={<IconSearch />}
- label={<GuideAnchor target="explore">{t('Explore')}</GuideAnchor>}
- id="explore"
- exact={!shouldAccordionFloat}
- >
- {traces}
- {metrics}
- {profiling}
- {replays}
- {discover2}
- </SidebarAccordion>
- );
- return (
- <SidebarWrapper aria-label={t('Primary Navigation')} collapsed={collapsed}>
- <ExpandedContextProvider>
- <SidebarSectionGroupPrimary>
- <DropdownSidebarSection
- isSuperuser={showSuperuserWarning() && !isExcludedOrg()}
- >
- <SidebarDropdown orientation={orientation} collapsed={collapsed} />
- {showSuperuserWarning() && !isExcludedOrg() && (
- <Hook name="component:superuser-warning" organization={organization} />
- )}
- </DropdownSidebarSection>
- <PrimaryItems>
- {hasOrganization && (
- <Fragment>
- <SidebarSection>
- {issues}
- {projects}
- </SidebarSection>
- {hasNewSidebarHierarchy && !isSelfHostedErrorsOnly && (
- <Fragment>
- <SidebarSection>
- {explore}
- {insights}
- </SidebarSection>
- <SidebarSection>
- {performance}
- {feedback}
- {monitors}
- {alerts}
- {dashboards}
- {releases}
- </SidebarSection>
- </Fragment>
- )}
- {!hasNewSidebarHierarchy && !isSelfHostedErrorsOnly && (
- <Fragment>
- <SidebarSection>
- {performance}
- {profiling}
- {metrics}
- {replays}
- {llmMonitoring}
- {feedback}
- {monitors}
- {alerts}
- </SidebarSection>
- <SidebarSection>
- {discover2}
- {dashboards}
- {releases}
- {userFeedback}
- </SidebarSection>
- </Fragment>
- )}
- {isSelfHostedErrorsOnly && (
- <Fragment>
- <SidebarSection>
- {alerts}
- {discover2}
- {dashboards}
- {releases}
- {userFeedback}
- </SidebarSection>
- </Fragment>
- )}
- <SidebarSection>
- {stats}
- {settings}
- </SidebarSection>
- </Fragment>
- )}
- </PrimaryItems>
- </SidebarSectionGroupPrimary>
- {hasOrganization && (
- <SidebarSectionGroup>
- <PerformanceOnboardingSidebar
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.PERFORMANCE_ONBOARDING)}
- hidePanel={() => hidePanel('performance-sidequest')}
- {...sidebarItemProps}
- />
- <FeedbackOnboardingSidebar
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.FEEDBACK_ONBOARDING)}
- hidePanel={hidePanel}
- {...sidebarItemProps}
- />
- <ReplaysOnboardingSidebar
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.REPLAYS_ONBOARDING)}
- hidePanel={hidePanel}
- {...sidebarItemProps}
- />
- <ProfilingOnboardingSidebar
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.PROFILING_ONBOARDING)}
- hidePanel={hidePanel}
- {...sidebarItemProps}
- />
- <MetricsOnboardingSidebar
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.METRICS_ONBOARDING)}
- hidePanel={hidePanel}
- {...sidebarItemProps}
- />
- <SidebarSection noMargin noPadding>
- <OnboardingStatus
- org={organization}
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.ONBOARDING_WIZARD)}
- hidePanel={hidePanel}
- {...sidebarItemProps}
- />
- </SidebarSection>
- <SidebarSection>
- {HookStore.get('sidebar:bottom-items').length > 0 &&
- HookStore.get('sidebar:bottom-items')[0]({
- orientation,
- collapsed,
- hasPanel,
- organization,
- })}
- <SidebarHelp
- orientation={orientation}
- collapsed={collapsed}
- hidePanel={hidePanel}
- organization={organization}
- />
- <Broadcasts
- orientation={orientation}
- collapsed={collapsed}
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.BROADCASTS)}
- hidePanel={hidePanel}
- organization={organization}
- />
- <ServiceIncidents
- orientation={orientation}
- collapsed={collapsed}
- currentPanel={activePanel}
- onShowPanel={() => togglePanel(SidebarPanelKey.SERVICE_INCIDENTS)}
- hidePanel={hidePanel}
- />
- </SidebarSection>
- {!horizontal && (
- <SidebarSection>
- <SidebarCollapseItem
- id="collapse"
- data-test-id="sidebar-collapse"
- {...sidebarItemProps}
- icon={<Chevron direction={collapsed ? 'right' : 'left'} />}
- label={collapsed ? t('Expand') : t('Collapse')}
- onClick={toggleCollapse}
- />
- </SidebarSection>
- )}
- </SidebarSectionGroup>
- )}
- </ExpandedContextProvider>
- </SidebarWrapper>
- );
- }
- export default Sidebar;
- const responsiveFlex = css`
- display: flex;
- flex-direction: column;
- @media (max-width: ${theme.breakpoints.medium}) {
- flex-direction: row;
- }
- `;
- export const SidebarWrapper = styled('nav')<{collapsed: boolean}>`
- background: ${p => p.theme.sidebarGradient};
- color: ${p => p.theme.sidebar.color};
- line-height: 1;
- padding: 12px 0 2px; /* Allows for 32px avatars */
- width: ${p => p.theme.sidebar[p.collapsed ? 'collapsedWidth' : 'expandedWidth']};
- position: fixed;
- top: ${p => (ConfigStore.get('demoMode') ? p.theme.demo.headerSize : 0)};
- left: 0;
- bottom: 0;
- justify-content: space-between;
- z-index: ${p => p.theme.zIndex.sidebar};
- border-right: solid 1px ${p => p.theme.sidebarBorder};
- ${responsiveFlex};
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- top: 0;
- left: 0;
- right: 0;
- height: ${p => p.theme.sidebar.mobileHeight};
- bottom: auto;
- width: auto;
- padding: 0 ${space(1)};
- align-items: center;
- border-right: none;
- border-bottom: solid 1px ${p => p.theme.sidebarBorder};
- }
- `;
- const SidebarSectionGroup = styled('div')`
- ${responsiveFlex};
- flex-shrink: 0; /* prevents shrinking on Safari */
- gap: 1px;
- `;
- const SidebarSectionGroupPrimary = styled('div')`
- ${responsiveFlex};
- /* necessary for child flexing on msedge and ff */
- min-height: 0;
- min-width: 0;
- flex: 1;
- /* expand to fill the entire height on mobile */
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- height: 100%;
- align-items: center;
- }
- `;
- const PrimaryItems = styled('div')`
- overflow: auto;
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 1px;
- -ms-overflow-style: -ms-autohiding-scrollbar;
- @media (max-height: 675px) and (min-width: ${p => p.theme.breakpoints.medium}) {
- border-bottom: 1px solid ${p => p.theme.sidebarBorder};
- padding-bottom: ${space(1)};
- box-shadow: rgba(0, 0, 0, 0.15) 0px -10px 10px inset;
- }
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- overflow-y: visible;
- flex-direction: row;
- height: 100%;
- align-items: center;
- border-right: 1px solid ${p => p.theme.sidebarBorder};
- padding-right: ${space(1)};
- margin-right: ${space(0.5)};
- box-shadow: rgba(0, 0, 0, 0.15) -10px 0px 10px inset;
- ::-webkit-scrollbar {
- display: none;
- }
- }
- `;
- const SubitemDot = styled('div')<{collapsed: boolean}>`
- width: 3px;
- height: 3px;
- background: currentcolor;
- border-radius: 50%;
- opacity: ${p => (p.collapsed ? 1 : 0)};
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- opacity: 1;
- }
- `;
- const SidebarSection = styled(SidebarSectionGroup)<{
- noMargin?: boolean;
- noPadding?: boolean;
- }>`
- ${p => !p.noMargin && `margin: ${space(1)} 0`};
- ${p => !p.noPadding && `padding: 0 ${space(2)}`};
- @media (max-width: ${p => p.theme.breakpoints.small}) {
- margin: 0;
- padding: 0;
- }
- &:empty {
- display: none;
- }
- `;
- const DropdownSidebarSection = styled(SidebarSection)<{
- isSuperuser?: boolean;
- }>`
- position: relative;
- margin: 0;
- padding: ${space(1)} ${space(2)};
- ${p =>
- p.isSuperuser &&
- css`
- &:before {
- content: '';
- position: absolute;
- inset: 0 ${space(1)};
- border-radius: ${p.theme.borderRadius};
- background: ${p.theme.superuserSidebar};
- }
- `}
- `;
- const SidebarCollapseItem = styled(SidebarItem)`
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- display: none;
- }
- `;
|