:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(today): top bar with project menu, search, quick start and side panel button (#116206)
Adam Leith1d522d5ac811
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsxindex 32ab47b93858..08975b2ed780 100644--- a/frontend/src/layout/navigation-3000/Navigation.tsx+++ b/frontend/src/layout/navigation-3000/Navigation.tsx@@ -15,7 +15,8 @@ import { PanelLayout } from '~/layout/panel-layout/PanelLayout'import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { ProjectDragAndDropProvider } from '~/layout/panel-layout/ProjectTree/ProjectDragAndDropContext'import { TodayShell } from '~/layout/today/TodayShell'-import { todayShellLogic } from '~/layout/today/todayShellLogic'+import { TODAY_RAIL_WIDTH, todayShellLogic } from '~/layout/today/todayShellLogic'+import { TodayTopBar } from '~/layout/today/TodayTopBar'import { navigationLogic } from '../navigation/navigationLogic'import { ProjectNotice } from '../navigation/ProjectNotice'@@ -167,6 +168,7 @@ export function Navigation({'TodayAppLayout scrollbar-thin scrollbar-track-transparent scrollbar-thumb-[var(--color-bg-fill-scroll-thumb)]':todayRail,'TodayAppLayout--phone': todayPhone,+ 'TodayAppLayout--top-bar': todayFramed,'TodayAppLayout--no-phone-header': todayPhoneHeaderHidden,})}style={@@ -187,6 +189,7 @@ export function Navigation({// --project-navbar-width. Collapsed/mobile fall back to the base default.'--project-navbar-width':!mobileLayout && !isLayoutNavCollapsed ? `${navbarWidth}px` : undefined,+ '--today-rail-width': todayRail ? `${TODAY_RAIL_WIDTH}px` : undefined,'--left-nav-width': todayRail? `${todayLeftNavWidth}px`: isLayoutNavCollapsed@@ -196,7 +199,9 @@ export function Navigation({}><ProjectDragAndDropProvider>+ {todayFramed && <TodayTopBar />}{todayRail ? <TodayShell className="left-nav" /> : <PanelLayout className="left-nav" />}+ {todayFramed && <div aria-hidden className="TodayAppLayout__shadow" />}{todayFramed && (// The chrome token exists only inside a quill scope, so the backdrop that fills the gap above the frame carries data-quill.<div data-quill aria-hidden className="TodayAppLayout__backdrop bg-[var(--chrome)]" />diff --git a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsxindex 040f9f9af573..006ec5915aa7 100644--- a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx+++ b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx@@ -4,7 +4,6 @@ import { useMemo, useState } from 'react'import { IconCollapse, IconExpand } from '@posthog/icons'import { Button, cn } from '@posthog/quill'-import { ProductSetupButton } from 'lib/components/ProductSetup'import { releaseStageProductForScene } from 'lib/components/ReleaseStageTag/releaseStage'import { ReleaseStageTag } from 'lib/components/ReleaseStageTag/ReleaseStageTag'import { sceneLogic } from 'scenes/sceneLogic'@@ -20,7 +19,6 @@ import { QuillSceneTrail } from './QuillSceneTrail'import { SceneDescription } from './SceneDescription'import { useRegisterSceneMenuBarSlot, useSceneMenuBarSlotFilled } from './SceneMenuBarSlotProvider'import { sceneResourceIcon } from './sceneResourceIcon'-import { SceneTitlePanelButton } from './SceneTitlePanelButton'import type { SceneMainTitleProps } from './SceneTitleSection'import { SceneTitleSettingsButton } from './SceneTitleSettingsButton'@@ -40,13 +38,10 @@ export function QuillSceneTitleSection({saveOnBlur = false,noPadding = false,actions,- hideProductSetupButton = false,forceBackTo,className,onGenerateMetadata,isGeneratingMetadata,- maxToolProps,- maxButtonLabel,descriptionMaxLength,sceneId,}: SceneMainTitleProps): JSX.Element {@@ -148,10 +143,8 @@ export function QuillSceneTitleSection({}actions={<>- {!hideProductSetupButton && <ProductSetupButton />}{actions}{!menuBarShown && <SceneTitleSettingsButton />}- <SceneTitlePanelButton maxToolProps={maxToolProps} maxButtonLabel={maxButtonLabel} /></>}/>diff --git a/frontend/src/layout/today/TodayProjectMenu.tsx b/frontend/src/layout/today/TodayProjectMenu.tsxnew file mode 100644index 000000000000..799ca654c49c--- /dev/null+++ b/frontend/src/layout/today/TodayProjectMenu.tsx@@ -0,0 +1,176 @@+import { useActions, useValues } from 'kea'+import { useMemo, useRef } from 'react'++import { IconChevronDown, IconGear, IconPlusSmall, IconSearch } from '@posthog/icons'+import {+ Button,+ Combobox,+ ComboboxCollection,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxGroup,+ ComboboxInput,+ ComboboxItem,+ ComboboxLabel,+ ComboboxList,+ ComboboxListFooter,+ ComboboxTrigger,+ InputGroupAddon,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@posthog/quill'++import { newAccountMenuLogic } from 'lib/components/Account/newAccountMenuLogic'+import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'+import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { preflightLogic } from 'lib/logic/preflightLogic'+import { getProjectSwitchTargetUrl } from 'lib/utils/kea-router'+import { organizationLogic } from 'scenes/organizationLogic'+import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { globalModalsLogic } from '~/layout/globalModalsLogic'+import { AvailableFeature } from '~/types'++interface ProjectGroup {+ value: string+ items: string[]+}++/** The project switcher shortcut opens this menu too. */+export function TodayProjectMenu(): JSX.Element {+ const { currentTeam } = useValues(teamLogic)+ const { currentOrganizationProjectCount, projectCreationForbiddenReason } = useValues(organizationLogic)+ const { preflight } = useValues(preflightLogic)+ const { guardAvailableFeature } = useValues(upgradeModalLogic)+ const { showCreateProjectModal } = useActions(globalModalsLogic)+ const { isProjectSwitcherOpen, projectSearchValue, projectGroups } = useValues(newAccountMenuLogic)+ const { openProjectSwitcher, closeProjectSwitcher, setProjectSearchValue } = useActions(newAccountMenuLogic)+ const triggerRef = useRef<HTMLButtonElement>(null)++ const { groups, teamById } = useMemo(() => {+ const teams = new Map(projectGroups.flatMap((group) => group.projects.map((p) => [String(p.id), p.team])))+ return {+ groups: projectGroups.map(+ (group): ProjectGroup => ({+ value: group.name ?? 'Projects',+ items: group.projects.map((p) => String(p.id)),+ })+ ),+ teamById: teams,+ }+ }, [projectGroups])++ const canCreateProject = preflight?.can_create_org !== false && !projectCreationForbiddenReason+ const newProjectButton = (+ <Button+ size="row"+ left+ disabled={!canCreateProject}+ focusableWhenDisabled+ onClick={() =>+ guardAvailableFeature(+ AvailableFeature.ORGANIZATIONS_PROJECTS,+ () => {+ closeProjectSwitcher()+ showCreateProjectModal()+ },+ { currentUsage: currentOrganizationProjectCount }+ )+ }+ data-attr="today-top-bar-new-project"+ >+ <IconPlusSmall />+ New project+ </Button>+ )++ return (+ <Combobox+ items={groups}+ value={currentTeam ? String(currentTeam.id) : null}+ inputValue={projectSearchValue}+ open={isProjectSwitcherOpen}+ autoHighlight+ highlightItemOnHover+ itemToStringLabel={(id: string | null) => (id ? (teamById.get(id)?.name ?? '') : '')}+ onInputValueChange={(value: string) => setProjectSearchValue(value)}+ onOpenChange={(open: boolean) => (open ? openProjectSwitcher() : closeProjectSwitcher())}+ onValueChange={(id: string | null) => {+ const team = id ? teamById.get(id) : null+ if (!team || team.id === currentTeam?.id) {+ return+ }+ closeProjectSwitcher()+ window.location.href = getProjectSwitchTargetUrl(+ location.pathname,+ team.id,+ currentTeam?.project_id,+ team.project_id+ )+ }}+ >+ <ComboboxTrigger+ ref={triggerRef}+ render={+ <Button className="min-w-0 gap-1.5 px-1.5" data-attr="today-top-bar-project-menu">+ <span className="max-w-48 min-w-0 truncate">{currentTeam?.name ?? 'Select project'}</span>+ <IconChevronDown className="size-3 shrink-0 text-muted-foreground" />+ </Button>+ }+ />+ <ComboboxContent+ anchor={triggerRef}+ align="start"+ className="w-64 [&_[data-slot=combobox-input-group-wrapper]]:border-b-0"+ >+ <ComboboxInput placeholder="Search projects" autoFocus showTrigger={false} className="h-7">+ <InputGroupAddon align="inline-start">+ <IconSearch className="size-3" />+ </InputGroupAddon>+ </ComboboxInput>+ <ComboboxEmpty>No projects match your search</ComboboxEmpty>+ <ComboboxList>+ {(group: ProjectGroup) => (+ <ComboboxGroup key={group.value} items={group.items}>+ <ComboboxLabel>{group.value}</ComboboxLabel>+ <ComboboxCollection>+ {(id: string) => (+ <ComboboxItem key={id} value={id} data-attr="today-top-bar-project-item">+ <span className="min-w-0 truncate">{teamById.get(id)?.name}</span>+ </ComboboxItem>+ )}+ </ComboboxCollection>+ </ComboboxGroup>+ )}+ </ComboboxList>+ <ComboboxListFooter className="mx-0 mt-0 flex flex-col gap-0.5 bg-transparent before:hidden">+ {currentTeam && (+ <Button+ size="row"+ left+ render={<LinkPrimitive to={urls.project(currentTeam.id, urls.settings('project'))} />}+ onClick={() => closeProjectSwitcher()}+ data-attr="today-top-bar-project-settings"+ >+ <IconGear />+ Project settings+ </Button>+ )}+ {preflight?.can_create_org &&+ (canCreateProject ? (+ newProjectButton+ ) : (+ <Tooltip>+ <TooltipTrigger render={newProjectButton} />+ <TooltipContent>+ {projectCreationForbiddenReason || "You don't have permission to create a project"}+ </TooltipContent>+ </Tooltip>+ ))}+ </ComboboxListFooter>+ </ComboboxContent>+ </Combobox>+ )+}diff --git a/frontend/src/layout/today/TodayRail.tsx b/frontend/src/layout/today/TodayRail.tsxindex e76c2ca8c991..093c00b655d4 100644--- a/frontend/src/layout/today/TodayRail.tsx+++ b/frontend/src/layout/today/TodayRail.tsx@@ -1,13 +1,11 @@import { useActions, useValues } from 'kea'import { ComponentPropsWithoutRef, forwardRef } from 'react'-import { IconSearch } from '@posthog/icons'import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'import { pendingInvitesLogic } from 'lib/components/Account/pendingInvitesLogic'import { PendingInviteDot } from 'lib/components/Account/ProjectMenu'-import { commandLogic } from 'lib/components/Command/commandLogic'import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'import { organizationLogic } from 'scenes/organizationLogic'@@ -42,16 +40,15 @@ const RailUtility = forwardRef<})export function TodayRail(): JSX.Element {- const { activePane, sidebarVisible } = useValues(todayShellLogic)+ const { activePane } = useValues(todayShellLogic)const { clickRailPane } = useActions(todayShellLogic)- const { toggleCommand } = useActions(commandLogic)const { currentOrganization } = useValues(organizationLogic)const { pendingInvites } = useValues(pendingInvitesLogic)return (<navaria-label="Main"- className="flex shrink-0 flex-col items-center gap-3 pt-2.5 pb-3"+ className="TodayShell__rail flex shrink-0 flex-col items-center gap-3 bg-[var(--chrome)] pt-2.5 pb-3"// eslint-disable-next-line react/forbid-dom-propsstyle={{ width: TODAY_RAIL_WIDTH }}>@@ -67,34 +64,25 @@ export function TodayRail(): JSX.Element {/>))}<div className="mt-auto flex flex-col items-center gap-1">- {!sidebarVisible && (- <NewAccountMenu- side="right"- align="end"- renderTrigger={(props) => (- <RailUtility {...props} label="Account menu" data-attr="new-account-menu-button">- <>- <UploadedLogo- name={currentOrganization?.name ?? '?'}- entityId={currentOrganization?.id ?? ''}- mediaId={currentOrganization?.logo_media_id ?? ''}- size="small"- />- {pendingInvites.length > 0 && (- <PendingInviteDot className="absolute top-1.5 right-1.5" />- )}- </>- </RailUtility>- )}- />- )}- <RailUtility- label="Search"- data-attr="today-rail-search"- onClick={() => toggleCommand('nav-search-button')}- >- <IconSearch />- </RailUtility>+ <NewAccountMenu+ side="right"+ align="end"+ renderTrigger={(props) => (+ <RailUtility {...props} label="Account menu" data-attr="new-account-menu-button">+ <>+ <UploadedLogo+ name={currentOrganization?.name ?? '?'}+ entityId={currentOrganization?.id ?? ''}+ mediaId={currentOrganization?.logo_media_id ?? ''}+ size="small"+ />+ {pendingInvites.length > 0 && (+ <PendingInviteDot className="absolute top-1.5 right-1.5" />+ )}+ </>+ </RailUtility>+ )}+ /></div></nav>)diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scssindex c14c4e030c9c..6e2d16f4f36d 100644--- a/frontend/src/layout/today/TodayShell.scss+++ b/frontend/src/layout/today/TodayShell.scss@@ -7,6 +7,53 @@background: var(--today-paper);}+.TodayAppLayout--top-bar {+ --today-top-bar-height: 40px;++ // The rail runs the full height. The top bar spans the sidebar and the content beside it.+ grid-template:+ 'rail top top' var(--today-top-bar-height)+ 'rail left content' minmax(0, 1fr) / var(--today-rail-width) calc(+ var(--left-nav-width) - var(--today-rail-width)+ ) minmax(0, 1fr);++ // The shell's rail and sidebar take separate grid cells, so the shell itself drops out of the layout.+ .TodayShell {+ display: contents;+ }++ .TodayShell__rail {+ grid-area: rail;+ }++ .TodayShell__sidebar--framed {+ grid-area: left;+ }+}++// Spans the sidebar and the content, so one soft shadow off their shared top-left edge lifts both above the chrome.+// It has no fill, so it draws only the shadow outside its box.+.TodayAppLayout__shadow {+ position: relative;+ grid-row: 2;+ grid-column: 2 / -1;+ pointer-events: none;+ border-top-left-radius: var(--today-frame-radius);+ box-shadow: -20px -20px 18px -24px #00000021;++ [theme='dark'] & {+ box-shadow: -20px -20px 18px -24px #282828;+ }+}++.TodayTopBar {+ // Above the rail, which comes later in the grid and would otherwise paint over focus rings at the bar's left edge.+ position: relative;+ z-index: 1;+ grid-area: top;+ min-width: 0;+}+.TodayShell {display: flex;height: 100%;@@ -26,7 +73,6 @@// corner and the seam against the content. The content frame in Navigation.tsx draws the rest..TodayShell__sidebar--framed {height: auto;- margin-top: var(--today-frame-inset);border-top-left-radius: var(--today-frame-radius);// An overlay, like the content frame, so the border takes no space. The pane header then starts at the same@@ -48,8 +94,6 @@}.TodayAppLayout .TodayAppLayout__content {- margin-top: var(--today-frame-inset);-&.TodayAppLayout__content--corner {border-top-left-radius: var(--today-frame-radius);}@@ -70,7 +114,7 @@.TodayShell__scrim {position: fixed;- inset: 0 0 0 var(--today-rail-width);+ inset: var(--today-top-bar-height, 0) 0 0 var(--today-rail-width);z-index: var(--z-layout-navbar-under);visibility: hidden;background: rgb(21 21 21 / 18%);@@ -91,16 +135,18 @@.TodayShell__drawer {position: fixed;- top: var(--today-frame-inset);+ top: calc(var(--today-top-bar-height, 0px) + var(--today-frame-inset));bottom: var(--today-frame-inset);- left: var(--today-rail-width);++ // A gap off the rail, so the floating sidebar reads as a separate layer.+ left: calc(var(--today-rail-width) + var(--today-frame-inset) * 2);z-index: var(--z-layout-navbar);- max-width: calc(100vw - var(--today-rail-width) - 3rem);+ max-width: calc(100vw - var(--today-rail-width) - var(--today-frame-inset) * 2 - 3rem);height: auto;overflow: hidden;visibility: hidden;background: var(--today-paper);- border-radius: 0 var(--today-frame-radius) var(--today-frame-radius) 0;+ border-radius: var(--today-frame-radius);box-shadow: 24px 0 48px -24px rgb(0 0 0 / 28%);opacity: 0;transition:diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsxindex ad9faa2b7ca6..f35c8bad7f30 100644--- a/frontend/src/layout/today/TodayShell.tsx+++ b/frontend/src/layout/today/TodayShell.tsx@@ -184,21 +184,20 @@ export function TodayShell({ className }: { className?: string }): JSX.Element {style={{ width: sidebarWidth }}>{pane}- <TodaySidebarFooter /></aside></>) : (sidebarVisible && (<asideref={sidebarRef}- className="group/sidebar TodayShell__sidebar TodayShell__sidebar--framed relative"+ className="group/sidebar TodayShell__sidebar TodayShell__sidebar--framed relative bg-[var(--scene-layout-background)]"aria-label={paneTitle}// eslint-disable-next-line react/forbid-dom-propsstyle={{ width: sidebarWidth }}>{pane}- <TodaySidebarFooter />- <Resizer {...resizerLogicProps} className="z-2" offset={0} />+ {/* The frame already draws the seam, so the handle's own line shows only on hover. */}+ <Resizer {...resizerLogicProps} visible={false} className="z-2" offset={0} /></aside>))}diff --git a/frontend/src/layout/today/TodayTopBar.tsx b/frontend/src/layout/today/TodayTopBar.tsxnew file mode 100644index 000000000000..b90efd075069--- /dev/null+++ b/frontend/src/layout/today/TodayTopBar.tsx@@ -0,0 +1,25 @@+import { TodayProjectMenu } from './TodayProjectMenu'+import { TodayTopBarQuickStartButton } from './TodayTopBarQuickStartButton'+import { TodayTopBarSearch } from './TodayTopBarSearch'+import { TodayTopBarSidePanelButton } from './TodayTopBarSidePanelButton'++/** The equal outer columns keep the search centered. */+export function TodayTopBar(): JSX.Element {+ return (+ <header+ data-quill+ className="TodayTopBar grid grid-cols-[minmax(max-content,1fr)_minmax(10rem,36rem)_minmax(max-content,1fr)] items-center gap-2 bg-[var(--chrome)] pe-2"+ >+ <div className="flex min-w-0 items-center gap-0.5">+ <TodayProjectMenu />+ </div>+ <TodayTopBarSearch />+ <div className="flex min-w-0 items-center gap-2">+ <TodayTopBarQuickStartButton />+ <div className="ms-auto">+ <TodayTopBarSidePanelButton />+ </div>+ </div>+ </header>+ )+}diff --git a/frontend/src/layout/today/TodayTopBarQuickStartButton.tsx b/frontend/src/layout/today/TodayTopBarQuickStartButton.tsxnew file mode 100644index 000000000000..9cfdddf3bb99--- /dev/null+++ b/frontend/src/layout/today/TodayTopBarQuickStartButton.tsx@@ -0,0 +1,55 @@+import { IconTarget } from '@posthog/icons'+import { Badge, Button } from '@posthog/quill'++import { ProductSetupPopover } from 'lib/components/ProductSetup'+import { useProductSetupButton } from 'lib/components/ProductSetup/useProductSetupButton'++export function TodayTopBarQuickStartButton(): JSX.Element | null {+ const {+ shouldShowButton,+ selectedProduct,+ isOpen,+ isDismissed,+ remainingCount,+ shouldShowSetup,+ toggle,+ close,+ setSelectedProduct,+ } = useProductSetupButton()++ if (!shouldShowButton) {+ return null+ }++ const minimized = isDismissed && !isOpen+ // The count stays while the guide is open, so the trigger does not change shape under the pointer.+ const showCount = (shouldShowSetup || minimized) && remainingCount > 0++ return (+ <ProductSetupPopover+ visible={isOpen}+ onClickOutside={close}+ selectedProduct={selectedProduct}+ onSelectProduct={setSelectedProduct}+ >+ <Button+ variant="outline"+ size={minimized ? 'icon' : 'default'}+ aria-label={minimized ? 'Quick start' : undefined}+ aria-pressed={isOpen}+ className="shrink-0 aria-pressed:bg-[var(--fill-selected)]"+ onClick={toggle}+ // pinned: autocapture data-attr shared with the title-row trigger+ data-attr={minimized ? 'global-product-setup-button-minimized' : 'global-product-setup-button'}+ >+ <IconTarget />+ {!minimized && 'Quick start'}+ {showCount && (+ <Badge variant="warning" translate="no">+ {remainingCount}+ </Badge>+ )}+ </Button>+ </ProductSetupPopover>+ )+}diff --git a/frontend/src/layout/today/TodayTopBarSearch.tsx b/frontend/src/layout/today/TodayTopBarSearch.tsxnew file mode 100644index 000000000000..9ffe81cf38a8--- /dev/null+++ b/frontend/src/layout/today/TodayTopBarSearch.tsx@@ -0,0 +1,27 @@+import { useActions, useValues } from 'kea'++import { IconSearch } from '@posthog/icons'+import { Button, Kbd } from '@posthog/quill'++import { commandLogic } from 'lib/components/Command/commandLogic'+import { isMac } from 'lib/utils/dom'+import { teamLogic } from 'scenes/teamLogic'++export function TodayTopBarSearch(): JSX.Element {+ const { currentTeam } = useValues(teamLogic)+ const { toggleCommand } = useActions(commandLogic)++ return (+ <Button+ variant="outline"+ left+ className="h-7 w-full justify-start gap-2 bg-[var(--today-paper)] px-2 font-normal text-muted-foreground hover:text-foreground"+ onClick={() => toggleCommand('nav-search-bar')}+ data-attr="today-top-bar-search"+ >+ <IconSearch className="size-3.5 shrink-0" />+ <span className="min-w-0 flex-1 truncate text-start">Search {currentTeam?.name ?? 'PostHog'}</span>+ <Kbd className="shrink-0">{isMac() ? '⌘K' : 'Ctrl+K'}</Kbd>+ </Button>+ )+}diff --git a/frontend/src/layout/today/TodayTopBarSidePanelButton.tsx b/frontend/src/layout/today/TodayTopBarSidePanelButton.tsxnew file mode 100644index 000000000000..e9c4de767a96--- /dev/null+++ b/frontend/src/layout/today/TodayTopBarSidePanelButton.tsx@@ -0,0 +1,38 @@+import { useActions, useValues } from 'kea'++import { IconSidePanel } from '@posthog/icons'+import { Button, Kbd, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import { sidePanelLogic } from '~/layout/navigation-3000/sidepanel/sidePanelLogic'+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'++export function TodayTopBarSidePanelButton(): JSX.Element {+ const { sidePanelOpen } = useValues(sidePanelStateLogic)+ const { defaultTab } = useValues(sidePanelLogic)+ const { openSidePanel, closeSidePanel } = useActions(sidePanelStateLogic)+ const label = sidePanelOpen ? 'Close context panel' : 'Open context panel'++ return (+ <Tooltip disableHoverablePopup>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon"+ aria-label={label}+ aria-pressed={sidePanelOpen}+ className="text-muted-foreground hover:text-foreground aria-pressed:bg-[var(--fill-selected)] aria-pressed:text-foreground"+ onClick={() => (sidePanelOpen ? closeSidePanel() : openSidePanel(defaultTab))}+ data-attr="today-top-bar-side-panel"+ />+ }+ >+ <IconSidePanel />+ </TooltipTrigger>+ <TooltipContent side="bottom" align="end">+ {label}+ <Kbd>]</Kbd>+ </TooltipContent>+ </Tooltip>+ )+}diff --git a/frontend/src/lib/components/ProductSetup/ProductSetupButton.tsx b/frontend/src/lib/components/ProductSetup/ProductSetupButton.tsxindex 3dea38fdecef..aaadd9d99457 100644--- a/frontend/src/lib/components/ProductSetup/ProductSetupButton.tsx+++ b/frontend/src/lib/components/ProductSetup/ProductSetupButton.tsx@@ -1,18 +1,12 @@-import { useActions, useValues } from 'kea'import { forwardRef } from 'react'import { IconTarget } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'-import { keyBinds } from 'lib/components/Shortcuts/shortcuts'-import { useShortcut } from 'lib/components/Shortcuts/useShortcut'-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonBadge } from 'lib/lemon-ui/LemonBadge'-import { organizationLogic } from 'scenes/organizationLogic'-import { globalSetupLogic } from './globalSetupLogic'-import { productSetupLogic } from './productSetupLogic'import { ProductSetupPopover } from './ProductSetupPopover'+import { useProductSetupButton } from './useProductSetupButton'/*** ProductSetupButton - A button that appears in the scene title section@@ -21,38 +15,18 @@ import { ProductSetupPopover } from './ProductSetupPopover'* handled by SceneContent when a productKey is provided.*/export function ProductSetupButton(): JSX.Element | null {- const { selectedProduct, isGlobalModalOpen, sceneHasNoSetup } = useValues(globalSetupLogic)- const { openGlobalSetup, closeGlobalSetup, setSelectedProduct } = useActions(globalSetupLogic)- const { isCurrentOrganizationNew } = useValues(organizationLogic)- const showPulseIndicator = useFeatureFlag('QUICK_START_PULSE_INDICATOR', 'test')-- // Get the setup state for the selected product- const logic = productSetupLogic({ productKey: selectedProduct })- const { remainingCount, shouldShowSetup, isDismissed } = useValues(logic)- const { undismissSetup } = useActions(logic)-- // Show button if there are remaining tasks OR if the modal is currently open (to show completion)- const shouldShowButton = isCurrentOrganizationNew && !sceneHasNoSetup && (remainingCount > 0 || isGlobalModalOpen)-- const handleToggle = (): void => {- if (isGlobalModalOpen) {- closeGlobalSetup()- } else {- if (isDismissed) {- undismissSetup()- }- openGlobalSetup()- }- }-- useShortcut({- name: 'QuickStartGlobal',- keybind: [keyBinds.quickStart],- intent: 'Open quick start guide',- interaction: 'function',- callback: handleToggle,- disabled: !shouldShowButton,- })+ const {+ shouldShowButton,+ selectedProduct,+ isOpen,+ isDismissed,+ remainingCount,+ shouldShowSetup,+ showPulse,+ toggle,+ close,+ setSelectedProduct,+ } = useProductSetupButton()if (!shouldShowButton) {return null@@ -60,20 +34,20 @@ export function ProductSetupButton(): JSX.Element | null {return (<ProductSetupPopover- visible={isGlobalModalOpen}- onClickOutside={closeGlobalSetup}+ visible={isOpen}+ onClickOutside={close}selectedProduct={selectedProduct}onSelectProduct={setSelectedProduct}>- {isDismissed && !isGlobalModalOpen ? (- <MinimizedButton remainingCount={remainingCount} isActive={isGlobalModalOpen} onClick={handleToggle} />+ {isDismissed && !isOpen ? (+ <MinimizedButton remainingCount={remainingCount} isActive={isOpen} onClick={toggle} />) : (<ExpandedButtonremainingCount={remainingCount}showBadge={shouldShowSetup}- isActive={isGlobalModalOpen}- onClick={handleToggle}- showPulse={showPulseIndicator}+ isActive={isOpen}+ onClick={toggle}+ showPulse={showPulse}/>)}</ProductSetupPopover>diff --git a/frontend/src/lib/components/ProductSetup/useProductSetupButton.ts b/frontend/src/lib/components/ProductSetup/useProductSetupButton.tsnew file mode 100644index 000000000000..ea1bd012df14--- /dev/null+++ b/frontend/src/lib/components/ProductSetup/useProductSetupButton.ts@@ -0,0 +1,73 @@+import { useActions, useValues } from 'kea'++import { keyBinds } from 'lib/components/Shortcuts/shortcuts'+import { useShortcut } from 'lib/components/Shortcuts/useShortcut'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { organizationLogic } from 'scenes/organizationLogic'++import { ProductKey } from '~/queries/schema/schema-general'++import { globalSetupLogic } from './globalSetupLogic'+import { productSetupLogic } from './productSetupLogic'++export interface ProductSetupButtonState {+ shouldShowButton: boolean+ selectedProduct: ProductKey+ isOpen: boolean+ isDismissed: boolean+ remainingCount: number+ shouldShowSetup: boolean+ showPulse: boolean+ toggle: () => void+ close: () => void+ setSelectedProduct: (product: ProductKey) => void+}++/** The quick start trigger's state and its keyboard shortcut. Mount it once, in whichever trigger is on screen. */+export function useProductSetupButton(): ProductSetupButtonState {+ const { selectedProduct, isGlobalModalOpen, sceneHasNoSetup } = useValues(globalSetupLogic)+ const { openGlobalSetup, closeGlobalSetup, setSelectedProduct } = useActions(globalSetupLogic)+ const { isCurrentOrganizationNew } = useValues(organizationLogic)+ const showPulse = useFeatureFlag('QUICK_START_PULSE_INDICATOR', 'test')++ // Get the setup state for the selected product+ const logic = productSetupLogic({ productKey: selectedProduct })+ const { remainingCount, shouldShowSetup, isDismissed } = useValues(logic)+ const { undismissSetup } = useActions(logic)++ // Show button if there are remaining tasks OR if the modal is currently open (to show completion)+ const shouldShowButton = isCurrentOrganizationNew && !sceneHasNoSetup && (remainingCount > 0 || isGlobalModalOpen)++ const toggle = (): void => {+ if (isGlobalModalOpen) {+ closeGlobalSetup()+ } else {+ if (isDismissed) {+ undismissSetup()+ }+ openGlobalSetup()+ }+ }++ useShortcut({+ name: 'QuickStartGlobal',+ keybind: [keyBinds.quickStart],+ intent: 'Open quick start guide',+ interaction: 'function',+ callback: toggle,+ disabled: !shouldShowButton,+ })++ return {+ shouldShowButton,+ selectedProduct,+ isOpen: isGlobalModalOpen,+ isDismissed,+ remainingCount,+ shouldShowSetup,+ showPulse,+ toggle,+ close: closeGlobalSetup,+ setSelectedProduct,+ }+}