: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 { IconInfo } from '@posthog/icons'
import { LemonButton, Tooltip } from '@posthog/lemon-ui'
import { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'
import { FileSystemHomeFolderApi } from '~/generated/core/api.schemas'
import { splitPath } from './utils'
export function isHomeFolder(item: TreeDataItem, homeFolder: FileSystemHomeFolderApi | null): boolean {
return !!(
homeFolder?.id &&
item.record?.type === 'folder' &&
(item.record.id === homeFolder.id ||
(item.id.startsWith('shortcuts://') && item.record.ref === homeFolder.path))
)
}
export function withHomeFolderEmptyState(
items: TreeDataItem[],
homeFolder: FileSystemHomeFolderApi | null
): TreeDataItem[] {
if (!homeFolder?.id) {
return items
}
return items.map((item) => {
if (!item.children) {
return item
}
return {
...item,
children: isHomeFolder(item, homeFolder)
? item.children.map((child) =>
child.type === 'empty-folder'
? {
...child,
displayName: (
<span className="flex items-center gap-1">
<span>Empty home folder</span>
<Tooltip
title={
<>
<p className="mb-2">
This folder is public, not private. Everyone in this project can
see what you put here. Find it at{' '}
<strong>{splitPath(homeFolder.path).join(' / ')}</strong>.
</p>
<p className="mb-0">
To add an object to your home folder, right-click the folder or
open its … menu. Choose <strong>New</strong>, then select an
object type.
</p>
</>
}
placement="right"
openOnClick
>
<LemonButton
size="xsmall"
noPadding
icon={<IconInfo />}
aria-label="About your home folder"
data-attr="home-folder-info"
onClick={(event) => {
event.preventDefault()
event.stopPropagation()
}}
/>
</Tooltip>
</span>
),
}
: child
)
: withHomeFolderEmptyState(item.children, homeFolder),
}
})
}