: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
import { useValues } from 'kea'
import { OrgCombobox } from 'lib/components/Account/OrgCombobox'
import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'
import { ButtonPrimitive, ButtonPrimitiveProps } from 'lib/ui/Button/ButtonPrimitives'
import { MenuOpenIndicator } from 'lib/ui/Menus/Menus'
import {
PopoverPrimitive,
PopoverPrimitiveContent,
PopoverPrimitiveTrigger,
} from 'lib/ui/PopoverPrimitive/PopoverPrimitive'
import { cn } from 'lib/utils/css-classes'
import { organizationLogic } from 'scenes/organizationLogic'
export function OrganizationMenu({
buttonProps = { className: 'font-semibold' },
showName = true,
allowCreate = true,
}: {
showName?: boolean
buttonProps?: ButtonPrimitiveProps
allowCreate?: boolean
}): JSX.Element {
const iconOnly = buttonProps?.iconOnly ?? false
const { currentOrganization } = useValues(organizationLogic)
return (
<>
<PopoverPrimitive>
<PopoverPrimitiveTrigger asChild>
<ButtonPrimitive
iconOnly={iconOnly}
data-attr="tree-navbar-organization-dropdown-button"
size={iconOnly ? 'base' : 'sm'}
{...buttonProps}
className={cn('max-w-[178px]', iconOnly ? 'min-w-auto' : '', buttonProps.className)}
>
{currentOrganization ? (
<UploadedLogo
name={currentOrganization.name}
entityId={currentOrganization.id}
mediaId={currentOrganization.logo_media_id}
size={iconOnly ? 'small' : 'medium'}
/>
) : (
<UploadedLogo name="?" entityId="" mediaId="" size={iconOnly ? 'xsmall' : 'medium'} />
)}
{!iconOnly && showName && (
<>
<span className="truncate font-semibold">
{currentOrganization ? currentOrganization.name : 'Select organization'}
</span>
<MenuOpenIndicator />
</>
)}
</ButtonPrimitive>
</PopoverPrimitiveTrigger>
<PopoverPrimitiveContent
align="start"
className="w-[var(--project-panel-inner-width)] max-w-[var(--project-panel-inner-width)]"
>
<OrgCombobox allowCreate={allowCreate} />
</PopoverPrimitiveContent>
</PopoverPrimitive>
</>
)
}