Skip to content

: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.

feat(today): use one slim account row in the sidebar footer (#109757)

Shy Alterbd31a3157689
diff --git a/frontend/src/layout/today/TodayRail.tsx b/frontend/src/layout/today/TodayRail.tsx
index 83ee381b584b..11d6895ba9c6 100644
--- a/frontend/src/layout/today/TodayRail.tsx
+++ b/frontend/src/layout/today/TodayRail.tsx
@@ -12,9 +12,13 @@ import {
} from '@posthog/icons'
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 { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { cn } from 'lib/utils/css-classes'
+import { organizationLogic } from 'scenes/organizationLogic'
import { TODAY_RAIL_WIDTH, TodayRailPane, todayShellLogic } from './todayShellLogic'
@@ -29,6 +33,8 @@ export function TodayRail(): JSX.Element {
const { activePane, sidebarVisible } = useValues(todayShellLogic)
const { pickPane, toggleSidebar } = useActions(todayShellLogic)
const { toggleCommand } = useActions(commandLogic)
+ const { currentOrganization } = useValues(organizationLogic)
+ const { pendingInvites } = useValues(pendingInvitesLogic)
return (
<nav
@@ -61,6 +67,34 @@ export function TodayRail(): JSX.Element {
)
})}
<div className="mt-auto flex flex-col items-center gap-1">
+ {!sidebarVisible && (
+ <NewAccountMenu
+ side="right"
+ align="end"
+ renderTrigger={(props) => (
+ <ButtonPrimitive
+ {...props}
+ iconOnly
+ size="lg"
+ aria-label="Account menu"
+ tooltip="Account menu"
+ tooltipPlacement="right"
+ data-attr="new-account-menu-button"
+ className="relative"
+ >
+ <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" />
+ )}
+ </ButtonPrimitive>
+ )}
+ />
+ )}
<ButtonPrimitive
iconOnly
size="lg"
@@ -85,7 +119,6 @@ export function TodayRail(): JSX.Element {
>
{sidebarVisible ? <IconSidebarClose /> : <IconSidebarOpen />}
</ButtonPrimitive>
- <NewAccountMenu isLayoutNavCollapsed />
</div>
</nav>
)
diff --git a/frontend/src/layout/today/TodaySidebarFooter.tsx b/frontend/src/layout/today/TodaySidebarFooter.tsx
index 7cfa4757ee29..f7addb8a5435 100644
--- a/frontend/src/layout/today/TodaySidebarFooter.tsx
+++ b/frontend/src/layout/today/TodaySidebarFooter.tsx
@@ -1,49 +1,69 @@
import { useValues } from 'kea'
+import { ComponentProps } from 'react'
-import { IconChevronDown, IconGear } from '@posthog/icons'
+import { IconGear } from '@posthog/icons'
+import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
-import { ProjectCombobox } from 'lib/components/Account/ProjectCombobox'
-import { Link } from 'lib/lemon-ui/Link'
-import {
- PopoverPrimitive,
- PopoverPrimitiveContent,
- PopoverPrimitiveTrigger,
-} from 'lib/ui/PopoverPrimitive/PopoverPrimitive'
+import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'
+import { pendingInvitesLogic } from 'lib/components/Account/pendingInvitesLogic'
+import { PendingInviteDot } from 'lib/components/Account/ProjectMenu'
+import { LinkPrimitive } from 'lib/lemon-ui/Link'
+import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'
+import { organizationLogic } from 'scenes/organizationLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
+import { todayShellLogic } from './todayShellLogic'
+
export function TodaySidebarFooter(): JSX.Element {
const { currentTeam } = useValues(teamLogic)
- const projectName = currentTeam?.name ?? 'Project'
+ const { currentOrganization } = useValues(organizationLogic)
+ const { pendingInvites } = useValues(pendingInvitesLogic)
+ const { sidebarVisible } = useValues(todayShellLogic)
+
+ const renderTrigger = (props: ComponentProps<'button'>): JSX.Element => (
+ <Button
+ {...props}
+ size="lg"
+ className="TodaySidebarFooter__account justify-start"
+ data-attr="today-project-menu"
+ >
+ <UploadedLogo
+ name={currentOrganization?.name ?? '?'}
+ entityId={currentOrganization?.id ?? ''}
+ mediaId={currentOrganization?.logo_media_id ?? ''}
+ size="small"
+ />
+ <span className="TodaySidebarFooter__name">{currentTeam?.name ?? 'Project'}</span>
+ {pendingInvites.length > 0 && <PendingInviteDot className="ml-auto" />}
+ </Button>
+ )
return (
<div className="TodaySidebarFooter">
- <PopoverPrimitive>
- <PopoverPrimitiveTrigger asChild>
- <button type="button" className="TodaySidebarFooter__project" data-attr="today-project-menu">
- <span className="TodaySidebarFooter__avatar" aria-hidden>
- {String.fromCodePoint(projectName.codePointAt(0) ?? 80).toLocaleUpperCase()}
- </span>
- <span className="TodaySidebarFooter__projectText">
- <small>Project</small>
- <strong>{projectName}</strong>
- </span>
- <IconChevronDown />
- </button>
- </PopoverPrimitiveTrigger>
- <PopoverPrimitiveContent align="start" side="top" className="min-w-[280px] max-w-fit">
- <ProjectCombobox />
- </PopoverPrimitiveContent>
- </PopoverPrimitive>
- <Link
- to={urls.settings('project')}
- className="TodaySidebarFooter__settings"
- data-attr="today-settings"
- subtle
- >
- <IconGear />
- <span>Settings</span>
- </Link>
+ {sidebarVisible ? (
+ <NewAccountMenu side="top" align="start" sideOffset={12} renderTrigger={renderTrigger} />
+ ) : (
+ renderTrigger({})
+ )}
+ <Tooltip>
+ <TooltipTrigger
+ delay={0}
+ render={
+ <Button
+ size="icon-lg"
+ className="TodaySidebarFooter__settings"
+ aria-label="Settings"
+ nativeButton={false}
+ render={<LinkPrimitive to={urls.settings('project')} />}
+ data-attr="today-settings"
+ />
+ }
+ >
+ <IconGear className="size-4.5" />
+ </TooltipTrigger>
+ <TooltipContent>Settings</TooltipContent>
+ </Tooltip>
</div>
)
}
diff --git a/frontend/src/lib/components/Account/NewAccountMenu.tsx b/frontend/src/lib/components/Account/NewAccountMenu.tsx
index c7b3e89a22da..35967e6efc8c 100644
--- a/frontend/src/lib/components/Account/NewAccountMenu.tsx
+++ b/frontend/src/lib/components/Account/NewAccountMenu.tsx
@@ -1,5 +1,6 @@
import { Menu } from '@base-ui/react/menu'
import { useActions, useValues } from 'kea'
+import { ComponentProps } from 'react'
import {
IconDatabase,
@@ -47,10 +48,20 @@ import { ProjectModal } from './ProjectModal'
import { ProjectSwitcher } from './ProjectSwitcher'
interface AccountMenuProps {
- isLayoutNavCollapsed: boolean
+ isLayoutNavCollapsed?: boolean
+ renderTrigger?: ComponentProps<typeof Menu.Trigger>['render']
+ side?: ComponentProps<typeof Menu.Positioner>['side']
+ align?: ComponentProps<typeof Menu.Positioner>['align']
+ sideOffset?: number
}
-export function NewAccountMenu({ isLayoutNavCollapsed }: AccountMenuProps): JSX.Element {
+export function NewAccountMenu({
+ isLayoutNavCollapsed = false,
+ renderTrigger,
+ side,
+ align,
+ sideOffset = 4,
+}: AccountMenuProps): JSX.Element {
const { user } = useValues(userLogic)
const { isCloudOrDev } = useValues(preflightLogic)
const { showInviteModal } = useActions(inviteLogic)
@@ -79,59 +90,62 @@ export function NewAccountMenu({ isLayoutNavCollapsed }: AccountMenuProps): JSX.
<>
<Menu.Root open={isAccountMenuOpen} onOpenChange={setAccountMenuOpen}>
<Menu.Trigger
- render={(props) => (
- <ButtonPrimitive
- {...props}
- iconOnly={isLayoutNavCollapsed}
- className={cn('relative flex-1 py-1 min-w-0 group', {
- 'pl-[3px] pr-1 gap-[2px]': !isLayoutNavCollapsed,
- })}
- data-attr="new-account-menu-button"
- tooltip={
- <div className="flex flex-col gap-1">
- <div>
- Account menu
- <RenderKeybind keybind={[keyBinds.newAccountMenu]} className="ml-1" />
+ render={
+ renderTrigger ??
+ ((props) => (
+ <ButtonPrimitive
+ {...props}
+ iconOnly={isLayoutNavCollapsed}
+ className={cn('relative flex-1 py-1 min-w-0 group', {
+ 'pl-[3px] pr-1 gap-[2px]': !isLayoutNavCollapsed,
+ })}
+ data-attr="new-account-menu-button"
+ tooltip={
+ <div className="flex flex-col gap-1">
+ <div>
+ Account menu
+ <RenderKeybind keybind={[keyBinds.newAccountMenu]} className="ml-1" />
+ </div>
+ <div>
+ Organization:{' '}
+ {currentOrganization ? currentOrganization.name : 'Select organization'}
+ </div>
+ <div>Project: {currentTeam ? currentTeam.name : 'Select project'}</div>
+ {hasPendingInvites && <div>You have a pending invitation</div>}
</div>
- <div>
- Organization:{' '}
- {currentOrganization ? currentOrganization.name : 'Select organization'}
- </div>
- <div>Project: {currentTeam ? currentTeam.name : 'Select project'}</div>
- {hasPendingInvites && <div>You have a pending invitation</div>}
- </div>
- }
- >
- {currentOrganization ? (
- <UploadedLogo
- name={currentOrganization.name}
- entityId={currentOrganization.id}
- mediaId={currentOrganization.logo_media_id}
- size="small"
- />
- ) : (
- <UploadedLogo name="?" entityId="" mediaId="" size="xsmall" />
- )}
- {!isLayoutNavCollapsed && (
- <span className="truncate text-secondary group-hover:text-primary">
- {isAuthenticatedTeam(currentTeam)
- ? (projectNameWithoutFirstEmoji ?? 'Project')
- : 'Account menu'}
- </span>
- )}
- {hasPendingInvites && (
- <PendingInviteDot
- className={isLayoutNavCollapsed ? 'absolute top-0.5 right-0.5' : 'mr-0.5'}
- />
- )}
- </ButtonPrimitive>
- )}
+ }
+ >
+ {currentOrganization ? (
+ <UploadedLogo
+ name={currentOrganization.name}
+ entityId={currentOrganization.id}
+ mediaId={currentOrganization.logo_media_id}
+ size="small"
+ />
+ ) : (
+ <UploadedLogo name="?" entityId="" mediaId="" size="xsmall" />
+ )}
+ {!isLayoutNavCollapsed && (
+ <span className="truncate text-secondary group-hover:text-primary">
+ {isAuthenticatedTeam(currentTeam)
+ ? (projectNameWithoutFirstEmoji ?? 'Project')
+ : 'Account menu'}
+ </span>
+ )}
+ {hasPendingInvites && (
+ <PendingInviteDot
+ className={isLayoutNavCollapsed ? 'absolute top-0.5 right-0.5' : 'mr-0.5'}
+ />
+ )}
+ </ButtonPrimitive>
+ ))
+ }
/>
<Menu.Portal>
<Menu.Backdrop className="fixed inset-0 z-[var(--z-modal)]" />
- <Menu.Positioner className="z-[var(--z-popover)]" sideOffset={4}>
+ <Menu.Positioner className="z-[var(--z-popover)]" side={side} align={align} sideOffset={sideOffset}>
<Menu.Popup className="primitive-menu-content max-h-[calc(var(--available-height)-4px)] min-w-[250px] w-full">
<ScrollableShadows
direction="vertical"
diff --git a/frontend/src/scenes/project-homepage/today/Today.scss b/frontend/src/scenes/project-homepage/today/Today.scss
index 4318865fcd03..6b093e744c15 100644
--- a/frontend/src/scenes/project-homepage/today/Today.scss
+++ b/frontend/src/scenes/project-homepage/today/Today.scss
@@ -190,99 +190,35 @@
.TodaySidebarFooter {
display: grid;
+ flex: none;
grid-template-columns: minmax(0, 1fr) auto;
- gap: 7px;
- padding: 12px 4px 14px;
- margin: 0 4px;
+ gap: 4px;
+ align-items: center;
+ padding: 7px 0 16px;
+ margin: 0 12px;
border-top: 1px solid var(--today-line);
}
-.TodaySidebarFooter__project,
+.TodaySidebarFooter__account,
.TodaySidebarFooter__settings {
- min-height: 48px;
- color: var(--today-body-text);
- background: var(--today-soft-2);
- border: 1px solid var(--today-line);
- border-radius: 10px;
+ color: var(--today-secondary-text);
- @media (hover: hover) and (pointer: fine) {
- &:hover {
- color: var(--today-ink);
- background: var(--today-soft);
- }
+ &:hover,
+ &[data-popup-open] {
+ color: var(--today-ink);
}
}
-.TodaySidebarFooter__project {
- display: flex;
- gap: 9px;
- align-items: center;
+.TodaySidebarFooter__account {
min-width: 0;
- padding: 6px 9px;
- text-align: left;
-
- > svg {
- flex: 0 0 14px;
- width: 14px;
- height: 14px;
- margin-left: auto;
- color: #969690;
- }
-}
-
-.TodaySidebarFooter__avatar {
- display: flex;
- flex: 0 0 32px;
- align-items: center;
- justify-content: center;
- width: 32px;
- height: 32px;
- font-family: var(--font-mono);
- font-size: 10px;
- font-weight: 700;
- color: #b84413;
- background: #ffe7da;
- border: 1px solid #ffd4bf;
- border-radius: 8px;
+ padding-inline: 6px 8px;
}
-.TodaySidebarFooter__projectText {
- display: flex;
- flex-direction: column;
- gap: 2px;
+.TodaySidebarFooter__name {
min-width: 0;
-
- small {
- font-family: var(--font-mono);
- font-size: 8px;
- color: var(--today-faint);
- text-transform: uppercase;
- letter-spacing: 0.06em;
- }
-
- strong {
- overflow: hidden;
- font-size: 11.5px;
- font-weight: 560;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-}
-
-.TodaySidebarFooter__settings {
- display: flex;
- flex-direction: column;
- gap: 2px;
- align-items: center;
- justify-content: center;
- width: 66px;
- padding: 4px;
- font-size: 9px;
-
- svg {
- width: 17px;
- height: 17px;
- }
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
// Home