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): match the products pane to the current navigation (#119568)

Adam Leith4803ff80061a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index dcc1d90b4e4d..f9c1a05cd375 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -4561,9 +4561,9 @@ snapshots:
lemon-ui-emoji-picker-related-results--jurassic-park--light:
hash: v1.k794b7964.4e3c7dbde02d15e363896b2dae8bb40315fa6f72b8664153d8956ef41dee7878.GX6fsWjbh_cia5dhpa5NdHEhvA0aly0CGfq0K5GHTfI
lemon-ui-icons1--shelf-a--dark:
- hash: v1.k794b7964.33d2ce502dd6df8bbdf37f60548df665f776f037df5413a35d9d6abc85eb7ac4.KAG_ZVMbEcDz78AYDbTBLLkmk2gBc0SWwZIrEQG86ys
+ hash: v1.k794b7964.f1e359c66776eac229a48ede23044e88e9f9422f5b2658a704060800981b842a.jX8rKIaVAL7B0YYLXvxwvq4R67wVEwSGSAJuXARNCN0
lemon-ui-icons1--shelf-a--light:
- hash: v1.k794b7964.5ac03ce003c333375b716362f03c7692bca611adffe6be6ef9be3b007e3b2595.YDFXw5WBfM-Nw2sTc3wVkST_yw3Ov7ZZshM8qFYuf-M
+ hash: v1.k794b7964.dfd09a4831c7fbb00dc6192201162715b3dcff4852932d685996f7aface959b7.YtBqsuIc0G_5EUnIJod8FqVj-W9kbKnGdKzPYawleQ0
lemon-ui-icons1--shelf-b--dark:
hash: v1.k794b7964.442b513ecaaba24065426e17cea6f5b3e549b46f0a4adec3431c34bda36a6d32.nxKhi1ZQ3TZmrOBs-kMq4Zj4BReQjniC9EMHj9aPJZs
lemon-ui-icons1--shelf-b--light:
@@ -10647,9 +10647,9 @@ snapshots:
scenes-app-errortracking--group-page-releases-stacked--light:
hash: v1.k794b7964.6229ba0294619c7c881929c7375df4700325ee629f842369641e5fe2355c1cd4._sFGlcefvjCQOkjMzoP9-CWeQ054s-pQHQ0vChbYbhE
scenes-app-errortracking--group-page-today-rail-nav--dark:
- hash: v1.k794b7964.0a696b9018fe814439ef41070a904b0bf6d5aafd3fb668cf1858b1f78b0a0783.O5x-0QjnG3NmkLmJhxQt3xJZjCeAB5lWE-M1tqJq3KI
+ hash: v1.k794b7964.45333b8ac34d1969ce924ac944fd203f5f894b77bd648b1ddabd334e358a84a9.idoJ_9mN1DW6iaTAberGn3zMxARWpVZq9OqWE5lDDQU
scenes-app-errortracking--group-page-today-rail-nav--light:
- hash: v1.k794b7964.9c527d3c4158b4d9adfc3f3a28dd18473da4b22bbc1a4eb2777f1f7da62261e5.eDDfQ09EGFBH5OQpxZPRX4ThjCT9wVqrhS49IrKnq7Q
+ hash: v1.k794b7964.16e1cb61689aeecacd7d21e8cf97ff33760cc6b77a140faeec4e67e4acd03440.G88NZldjGRM_wNvECGEPrOTyyyJgpS1p4HJ7gzWR7Fs
scenes-app-errortracking--group-page-with-many-self-driving-reports--dark:
hash: v1.k794b7964.0aa0858442d3e422f4825c4665d289c006c87b1c5a22265e447a1c0fa5e5a544.Hy3i1o_nWpWVqH4WqCEDvZTI4LQxeI2c9B6GW9rHDYA
scenes-app-errortracking--group-page-with-many-self-driving-reports--light:
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts b/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts
index cfc09d69de80..719ce90fd4df 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts
+++ b/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts
@@ -1,13 +1,20 @@
import { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { isFileSystemImportFlagEnabled } from 'lib/utils/fileSystemImportFlags'
import { DEFINITIONS_TABS } from 'scenes/data-management/definitionsSceneTabsLogic'
+import { isWelcomeNavItemShown } from 'scenes/onboarding/welcome/welcomeNavItem'
import { urls } from 'scenes/urls'
import { FileSystemImport } from '~/queries/schema/schema-general'
import { ActivityTab } from '~/types'
import { getDefaultTreeData, getDefaultTreeProducts } from '../../ProjectTree/defaultTree'
-import { POPULAR_CATEGORY, POPULAR_PRODUCT_PATHS } from './productsCatalog'
+import {
+ POPULAR_CATEGORY,
+ POPULAR_PRODUCT_PATHS,
+ ProductsItemGroup,
+ groupProducts,
+ productMatchesSearch,
+} from './productsCatalog'
// These pages are tabs of Event definitions, so the sidebar lists only that entry for them.
const DEFINITIONS_TAB_HREFS = new Set(DEFINITIONS_TABS.filter((tab) => tab.key !== 'events').map((tab) => tab.url))
@@ -24,8 +31,9 @@ export const WELCOME_NAV_ITEM: FileSystemImport = {
visualOrder: -1,
}
-export function getNavProductItems(featureFlags: FeatureFlagsSet): FileSystemImport[] {
- const items: FileSystemImport[] = [
+/** Every page the Products tab can list, before feature flags and the Welcome page apply. */
+export function getNavProductPages(): FileSystemImport[] {
+ return [
{
path: 'Home',
category: PINNED_CATEGORY,
@@ -61,6 +69,14 @@ export function getNavProductItems(featureFlags: FeatureFlagsSet): FileSystemImp
),
...getDefaultTreeData(),
]
+}
+
+/** `projectCreatedAt` decides whether a new project gets the Welcome page. */
+export function getNavProductItems(featureFlags: FeatureFlagsSet, projectCreatedAt?: string): FileSystemImport[] {
+ const items = [
+ ...(isWelcomeNavItemShown(projectCreatedAt, featureFlags) ? [WELCOME_NAV_ITEM] : []),
+ ...getNavProductPages(),
+ ]
const destinations = new Map<string, FileSystemImport>()
for (const item of items) {
if (!item.href || DEFINITIONS_TAB_HREFS.has(item.href) || !isFileSystemImportFlagEnabled(item, featureFlags)) {
@@ -73,3 +89,37 @@ export function getNavProductItems(featureFlags: FeatureFlagsSet): FileSystemImp
POPULAR_PRODUCT_PATHS.includes(item.path) ? { ...item, category: POPULAR_CATEGORY } : item
)
}
+
+export function pinnedNavProducts(items: FileSystemImport[], search: string): FileSystemImport[] {
+ return items
+ .filter((item) => item.category === PINNED_CATEGORY && productMatchesSearch(item, search))
+ .sort((a, b) => (a.visualOrder ?? Infinity) - (b.visualOrder ?? Infinity))
+}
+
+export function groupNavProducts(items: FileSystemImport[], search: string): ProductsItemGroup[] {
+ return groupProducts(
+ items.filter((item) => item.category !== PINNED_CATEGORY),
+ search
+ )
+}
+
+// Session replay opens its home page, but every recording page under /replay/ belongs to it too.
+function navProductMatchPath(item: FileSystemImport): string | null {
+ return item.path === 'Session replay' ? '/replay' : (item.href?.split(/[?#]/)[0] ?? null)
+}
+
+export function navProductHrefForPath(path: string, items: FileSystemImport[]): string | null {
+ let match: { href: string; matchPath: string } | null = null
+ for (const item of items) {
+ const matchPath = navProductMatchPath(item)
+ if (
+ item.href &&
+ matchPath &&
+ (path === matchPath || path.startsWith(`${matchPath}/`)) &&
+ (!match || matchPath.length > match.matchPath.length)
+ ) {
+ match = { href: item.href, matchPath }
+ }
+ }
+ return match?.href ?? null
+}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navProductsTabLogic.ts b/frontend/src/layout/panel-layout/navbar/tabs/navProductsTabLogic.ts
index 24df03cec831..bea20164ec36 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/navProductsTabLogic.ts
+++ b/frontend/src/layout/panel-layout/navbar/tabs/navProductsTabLogic.ts
@@ -11,7 +11,6 @@ import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
import { withTimeout } from 'lib/utils/async'
import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
-import { isWelcomeNavItemShown } from 'scenes/onboarding/welcome/welcomeNavItem'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'
import { teamLogic } from 'scenes/teamLogic'
@@ -27,7 +26,7 @@ import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'
import { findProductShortcut, shortcutFromEntry } from '../../ProjectTree/utils'
import { APP_MATCH_THRESHOLD, AppMatchGroups, buildAppRankingQuestions, readAppRankings } from './appRanking'
-import { PINNED_CATEGORY, WELCOME_NAV_ITEM, getNavProductItems } from './navProductItems'
+import { PINNED_CATEGORY, getNavProductItems, groupNavProducts, pinnedNavProducts } from './navProductItems'
import { ProductsItemGroup, groupProducts, productMatchesSearch, productsItemName } from './productsCatalog'
// projectTreeLogic persists state under its logic key, so renaming this value resets it.
@@ -69,7 +68,6 @@ export interface navProductsTabLogicValues {
pinnedItems: FileSystemImport[]
rankedConfigurableApps: FileSystemImport[]
search: string
- showWelcomeNavItem: boolean
starredProductIds: Record<string, string>
starredProductsSaving: boolean
}
@@ -226,9 +224,8 @@ export interface navProductsTabLogicMeta {
appRecommendationQuery: string,
appRecommendationsEnabled: boolean
) => AppMatchGroups | null
- allItems: (featureFlags: FeatureFlagsSet) => FileSystemImport[]
- showWelcomeNavItem: (currentTeam: TeamPublicType | TeamType | null, featureFlags: FeatureFlagsSet) => boolean
- pinnedItems: (allItems: FileSystemImport[], search: string, showWelcomeNavItem: boolean) => FileSystemImport[]
+ allItems: (featureFlags: FeatureFlagsSet, currentTeam: TeamPublicType | TeamType | null) => FileSystemImport[]
+ pinnedItems: (allItems: FileSystemImport[], search: string) => FileSystemImport[]
groupedItems: (allItems: FileSystemImport[], search: string) => ProductsItemGroup[]
configurableProducts: (allItems: FileSystemImport[]) => FileSystemImport[]
starredProductIds: (allItems: FileSystemImport[], shortcutData: FileSystemEntry[]) => Record<string, string>
@@ -476,28 +473,17 @@ export const navProductsTabLogic = kea<navProductsTabLogicType>([
: null,
],
allItems: [
- (s) => [s.featureFlags],
- (featureFlags: FeatureFlagsSet): FileSystemImport[] => getNavProductItems(featureFlags),
- ],
- showWelcomeNavItem: [
- (s) => [s.currentTeam, s.featureFlags],
- (currentTeam: TeamPublicType | TeamType | null, featureFlags: FeatureFlagsSet): boolean =>
- isWelcomeNavItemShown(currentTeam?.created_at, featureFlags),
+ (s) => [s.featureFlags, s.currentTeam],
+ (featureFlags: FeatureFlagsSet, currentTeam: TeamPublicType | TeamType | null): FileSystemImport[] =>
+ getNavProductItems(featureFlags, currentTeam?.created_at),
],
pinnedItems: [
- (s) => [s.allItems, s.search, s.showWelcomeNavItem],
- (items: FileSystemImport[], search: string, showWelcomeNavItem: boolean): FileSystemImport[] =>
- [...(showWelcomeNavItem ? [WELCOME_NAV_ITEM] : []), ...items]
- .filter((item) => item.category === PINNED_CATEGORY && productMatchesSearch(item, search))
- .sort((a, b) => (a.visualOrder ?? Infinity) - (b.visualOrder ?? Infinity)),
+ (s) => [s.allItems, s.search],
+ (items: FileSystemImport[], search: string): FileSystemImport[] => pinnedNavProducts(items, search),
],
groupedItems: [
(s) => [s.allItems, s.search],
- (items: FileSystemImport[], search: string): ProductsItemGroup[] =>
- groupProducts(
- items.filter((item) => item.category !== PINNED_CATEGORY),
- search
- ),
+ (items: FileSystemImport[], search: string): ProductsItemGroup[] => groupNavProducts(items, search),
],
configurableProducts: [
(s) => [s.allItems],
diff --git a/frontend/src/layout/today/TodayPaneRow.tsx b/frontend/src/layout/today/TodayPaneRow.tsx
index d22a2ddcf47f..ca6383d8e1ba 100644
--- a/frontend/src/layout/today/TodayPaneRow.tsx
+++ b/frontend/src/layout/today/TodayPaneRow.tsx
@@ -12,6 +12,8 @@ interface TodayPaneRowProps {
variant?: 'default' | 'destructive'
/** A control that sits on the row's right edge and shows on hover, outside the row's own link. */
action?: JSX.Element | null
+ /** Keeps the action shown without a hover, for a state the row must always show, like a star. */
+ actionVisible?: boolean
dataAttr?: string
}
@@ -24,6 +26,7 @@ export function TodayPaneRow({
active = false,
variant,
action,
+ actionVisible = false,
dataAttr,
}: TodayPaneRowProps): JSX.Element {
return (
@@ -38,7 +41,11 @@ export function TodayPaneRow({
className={cn(action && 'pr-8')}
>
{icon && (
- <span className="flex size-4 shrink-0 items-center justify-center [&_svg]:size-4" aria-hidden>
+ <span
+ className="flex size-4 shrink-0 items-center justify-center [&_svg]:size-4"
+ data-keep-color
+ aria-hidden
+ >
{icon}
</span>
)}
@@ -56,7 +63,12 @@ export function TodayPaneRow({
)}
</TodayPaneOption>
{action && (
- <span className="absolute right-1 flex items-center opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100">
+ <span
+ className={cn(
+ 'absolute right-1 flex items-center transition-opacity',
+ !actionVisible && 'opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100'
+ )}
+ >
{action}
</span>
)}
diff --git a/frontend/src/layout/today/TodayPaneSection.tsx b/frontend/src/layout/today/TodayPaneSection.tsx
index c99dc603f8bf..d15af2ed98db 100644
--- a/frontend/src/layout/today/TodayPaneSection.tsx
+++ b/frontend/src/layout/today/TodayPaneSection.tsx
@@ -1,6 +1,6 @@
import { ReactNode, RefCallback } from 'react'
-import { IconChevronDown, IconChevronRight } from '@posthog/icons'
+import { IconChevronRight } from '@posthog/icons'
import { MenuLabel, cn } from '@posthog/quill'
import { TodayPaneSectionResizeHandle } from './TodayPaneSectionResizeHandle'
@@ -46,7 +46,6 @@ export function TodayPaneSection({
contentRef,
children,
}: TodayPaneSectionProps): JSX.Element {
- const Caret = open ? IconChevronDown : IconChevronRight
return (
<section aria-label={label} className="flex shrink-0 flex-col">
<div className={cn('relative flex h-7 shrink-0 items-center gap-1', divider && 'border-t border-border')}>
@@ -68,7 +67,7 @@ export function TodayPaneSection({
</span>
)}
<span>{label}</span>
- <Caret className="size-3 shrink-0 opacity-60" />
+ <IconChevronRight className={cn('size-3 shrink-0 opacity-60', open && 'rotate-90')} />
{!open && showCount && count > 0 && (
<span className="ml-0.5 font-normal text-muted-foreground tabular-nums">{count}</span>
)}
diff --git a/frontend/src/layout/today/TodayPreviewCardProvider.tsx b/frontend/src/layout/today/TodayPreviewCardProvider.tsx
index f54810a9b72b..d36dad6176a5 100644
--- a/frontend/src/layout/today/TodayPreviewCardProvider.tsx
+++ b/frontend/src/layout/today/TodayPreviewCardProvider.tsx
@@ -14,6 +14,9 @@ const TodayChatHoverCard = lazyWithRetry(() =>
const TodayObjectHoverCard = lazyWithRetry(() =>
import('./TodayObjectHoverCard').then((m) => ({ default: m.TodayObjectHoverCard }))
)
+const TodayProductHoverCard = lazyWithRetry(() =>
+ import('./TodayProductHoverCard').then((m) => ({ default: m.TodayProductHoverCard }))
+)
const TodaySessionHoverCard = lazyWithRetry(() =>
import('./TodaySessionHoverCard').then((m) => ({ default: m.TodaySessionHoverCard }))
)
@@ -90,6 +93,8 @@ export function TodayPreviewCardProvider({
<TodayChatHoverCard preview={payload} onAction={close} />
) : payload.kind === 'object' ? (
<TodayObjectHoverCard preview={payload} onAction={close} />
+ ) : payload.kind === 'product' ? (
+ <TodayProductHoverCard preview={payload} onAction={close} />
) : (
<TodaySessionHoverCard preview={payload} onAction={close} />
)}
diff --git a/frontend/src/layout/today/TodayProductHoverCard.tsx b/frontend/src/layout/today/TodayProductHoverCard.tsx
new file mode 100644
index 000000000000..27a5561a5832
--- /dev/null
+++ b/frontend/src/layout/today/TodayProductHoverCard.tsx
@@ -0,0 +1,64 @@
+import { IconExternal } from '@posthog/icons'
+import { Button, Item, ItemContent, ItemSeparator, ItemTitle, Text } from '@posthog/quill'
+
+import { LinkPrimitive } from 'lib/lemon-ui/Link'
+
+import { NavProductIcon } from '~/layout/panel-layout/navbar/tabs/NavProductIcon'
+
+import { TodayProductPreview } from './todayPreviewCards'
+
+export function TodayProductHoverCard({
+ preview,
+ onAction,
+}: {
+ preview: TodayProductPreview
+ onAction: () => void
+}): JSX.Element {
+ return (
+ <div className="flex flex-col" data-attr="today-product-hover-card">
+ <Item size="xs" className="items-start">
+ <ItemContent className="min-w-0 gap-2">
+ <ItemTitle className="flex items-center gap-2 wrap-anywhere">
+ <span
+ className="flex size-4 shrink-0 items-center justify-center group/colorful-product-icons colorful-product-icons-true [&_svg]:size-4"
+ aria-hidden
+ >
+ <NavProductIcon item={preview.product} />
+ </span>
+ <span className="min-w-0 flex-1 font-semibold">{preview.label}</span>
+ </ItemTitle>
+ <div className="flex flex-col gap-2 pl-6">
+ {preview.description && <p className="m-0 text-xs">{preview.description}</p>}
+ {preview.example && (
+ <div className="flex flex-col gap-0.5">
+ <Text size="xs" variant="muted" className="font-semibold">
+ For example
+ </Text>
+ <Text size="xs" variant="muted">
+ {preview.example}
+ </Text>
+ </div>
+ )}
+ </div>
+ </ItemContent>
+ </Item>
+ {preview.docsHref && (
+ <>
+ <ItemSeparator className="my-0" />
+ <div className="flex flex-col p-1">
+ <Button
+ left
+ className="w-full"
+ render={<LinkPrimitive to={preview.docsHref} target="_blank" />}
+ onClick={onAction}
+ data-attr="today-product-card-docs"
+ >
+ <IconExternal />
+ Read the docs
+ </Button>
+ </div>
+ </>
+ )}
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodayProductRow.tsx b/frontend/src/layout/today/TodayProductRow.tsx
new file mode 100644
index 000000000000..bc4032901861
--- /dev/null
+++ b/frontend/src/layout/today/TodayProductRow.tsx
@@ -0,0 +1,49 @@
+import { useMemo } from 'react'
+
+import { NavProductIcon } from '~/layout/panel-layout/navbar/tabs/NavProductIcon'
+import { FileSystemImport } from '~/queries/schema/schema-general'
+
+import { TodayPaneRow } from './TodayPaneRow'
+import { productPreview } from './todayPreviewCards'
+import { TodayPreviewTrigger } from './TodayPreviewTrigger'
+import { TodayProductStarButton } from './TodayProductStarButton'
+
+export interface TodayProductRowProps {
+ value: string
+ label: string
+ product: FileSystemImport
+ to: string
+ active: boolean
+ starred: boolean
+ /** Every row in the Starred group has a star, so those rows show it only on hover. */
+ inStarredGroup: boolean
+}
+
+export function TodayProductRow({
+ value,
+ label,
+ product,
+ to,
+ active,
+ starred,
+ inStarredGroup,
+}: TodayProductRowProps): JSX.Element {
+ // The shared card stores the payload, so it must keep its identity between renders.
+ const preview = useMemo(() => productPreview(label, product), [label, product])
+ return (
+ <TodayPreviewTrigger payload={preview}>
+ <TodayPaneRow
+ value={value}
+ label={label}
+ icon={<NavProductIcon item={product} />}
+ to={to}
+ active={active}
+ action={<TodayProductStarButton product={product} starred={starred} />}
+ // Like the current navigation, a starred row keeps its filled star in view.
+ actionVisible={starred && !inStarredGroup}
+ // pinned: tracking API, do not rename.
+ dataAttr={inStarredGroup ? 'today-tool-starred' : 'today-tool'}
+ />
+ </TodayPreviewTrigger>
+ )
+}
diff --git a/frontend/src/layout/today/TodayProductStarButton.tsx b/frontend/src/layout/today/TodayProductStarButton.tsx
new file mode 100644
index 000000000000..76ce444d2ae1
--- /dev/null
+++ b/frontend/src/layout/today/TodayProductStarButton.tsx
@@ -0,0 +1,41 @@
+import { useActions, useValues } from 'kea'
+
+import { IconStar, IconStarFilled } from '@posthog/icons'
+import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'
+import { FileSystemImport } from '~/queries/schema/schema-general'
+
+import { todayProductsLogic } from './todayProductsLogic'
+
+export function TodayProductStarButton({
+ product,
+ starred,
+}: {
+ product: FileSystemImport
+ starred: boolean
+}): JSX.Element {
+ const { shortcutDataLoading } = useValues(projectTreeDataLogic)
+ const { toggleStarred } = useActions(todayProductsLogic)
+ const label = starred ? 'Remove from starred' : 'Add to starred'
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ delay={0}
+ render={
+ <Button
+ size="icon-xs"
+ aria-label={label}
+ aria-pressed={starred}
+ disabled={shortcutDataLoading}
+ onClick={() => toggleStarred(product)}
+ data-attr={starred ? 'today-product-unstar' : 'today-product-star'}
+ />
+ }
+ >
+ {starred ? <IconStarFilled /> : <IconStar />}
+ </TooltipTrigger>
+ <TooltipContent>{shortcutDataLoading ? 'Updating starred products' : label}</TooltipContent>
+ </Tooltip>
+ )
+}
diff --git a/frontend/src/layout/today/TodayProductsPane.tsx b/frontend/src/layout/today/TodayProductsPane.tsx
new file mode 100644
index 000000000000..0f6bfef82d6b
--- /dev/null
+++ b/frontend/src/layout/today/TodayProductsPane.tsx
@@ -0,0 +1,15 @@
+import { useValues } from 'kea'
+
+import { TodayPreviewCardProvider } from './TodayPreviewCardProvider'
+import { TodayProductsSidebar } from './TodayProductsSidebar'
+import { todayShellLogic } from './todayShellLogic'
+
+export function TodayProductsPane(): JSX.Element {
+ const { phoneLayout } = useValues(todayShellLogic)
+
+ return (
+ <TodayPreviewCardProvider disabled={phoneLayout}>
+ <TodayProductsSidebar />
+ </TodayPreviewCardProvider>
+ )
+}
diff --git a/frontend/src/layout/today/TodayProductsSidebar.tsx b/frontend/src/layout/today/TodayProductsSidebar.tsx
index cd9c942fa3b6..ab5bce6d73af 100644
--- a/frontend/src/layout/today/TodayProductsSidebar.tsx
+++ b/frontend/src/layout/today/TodayProductsSidebar.tsx
@@ -1,70 +1,49 @@
import { useActions, useValues } from 'kea'
-import { router } from 'kea-router'
-import { IconFolder } from '@posthog/icons'
import { Text } from '@posthog/quill'
-import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
-import { LibraryCreateButton } from 'scenes/library/LibraryCreateButton'
-import { libraryLogic } from 'scenes/library/libraryLogic'
-import { libraryListHref, libraryTypeForPath } from 'scenes/library/libraryUtils'
-import { libraryRowProductLabels, toolHrefForPath, toolLabel } from 'scenes/tools/toolsUtils'
-import { urls } from 'scenes/urls'
-
-import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
-import { FileSystemIconType, FileSystemImport } from '~/queries/schema/schema-general'
+import { NavProductIcon } from '~/layout/panel-layout/navbar/tabs/NavProductIcon'
+import { productsItemName } from '~/layout/panel-layout/navbar/tabs/productsCatalog'
+import { FileSystemImport } from '~/queries/schema/schema-general'
import { TodayPaneGroupLabel } from './TodayPaneGroupLabel'
import { TodayPaneRow } from './TodayPaneRow'
-import { analyticsTypesForPaneSearch, matchesPaneQuery } from './todayPaneSearch'
+import { analyticsTypesForPaneSearch } from './todayPaneSearch'
import { TodayPaneSearchList } from './TodayPaneSearchList'
+import { TodayPaneSection } from './TodayPaneSection'
+import { TodayProductRow } from './TodayProductRow'
import { TodayProductsAnalyticsHint } from './TodayProductsAnalyticsHint'
-import { todayToolsLogic } from './todayToolsLogic'
+import { todayProductsLogic } from './todayProductsLogic'
-/** The Products sub-nav: recently viewed tools, every saved object type, then the tools by category. */
export function TodayProductsSidebar(): JSX.Element {
- const { tools, toolGroups, recentTools, search } = useValues(todayToolsLogic)
- const { setSearch } = useActions(todayToolsLogic)
- const { objectTypes } = useValues(libraryLogic)
- const { location } = useValues(router)
- const path = removeProjectIdIfPresent(location.pathname)
- const activeHref = toolHrefForPath(path, tools)
- const objectPageType = libraryTypeForPath(path)
-
- const showAllObjects = matchesPaneQuery('All objects', search)
- const libraryTypes = objectTypes.filter((type) =>
- [type.pluralLabel, ...libraryRowProductLabels(type.value)].some((label) => matchesPaneQuery(label, search))
- )
- const showLibrary = showAllObjects || libraryTypes.length > 0
+ const {
+ pinnedProducts,
+ productGroups,
+ productCount,
+ starredProducts,
+ starredHrefs,
+ starredOpen,
+ allProductsOpen,
+ activeHref,
+ search,
+ } = useValues(todayProductsLogic)
+ const { setSearch, setStarredOpen, setAllProductsOpen } = useActions(todayProductsLogic)
+ const searching = !!search.trim()
const searchedAnalyticsTypes = analyticsTypesForPaneSearch(search)
- const recentSection = recentTools.length ? { key: 'recent', label: 'Recently viewed', tools: recentTools } : null
- const categorySections = toolGroups.map((group) => ({
- key: group.category,
- label: group.category,
- tools: group.tools,
- }))
- const hasProducts = !!recentSection || showLibrary || categorySections.length > 0
- // A tool can show in Recently viewed and in its own group, so the group keeps the two rows apart on the keyboard path.
- const optionValue = (groupKey: string, tool: FileSystemImport): string => `${groupKey}:${tool.href ?? ''}`
+ const hasProducts = pinnedProducts.length > 0 || starredProducts.length > 0 || productCount > 0
- const renderToolSection = (section: (typeof categorySections)[number], first: boolean): JSX.Element => (
- <div key={section.key}>
- <TodayPaneGroupLabel first={first}>{section.label}</TodayPaneGroupLabel>
- {section.tools.map((tool) => {
- const href = tool.href ?? ''
- return (
- <TodayPaneRow
- key={href}
- value={optionValue(section.key, tool)}
- label={toolLabel(tool)}
- icon={iconForType((tool.iconType ?? tool.type) as FileSystemIconType, tool.iconColor)}
- to={href}
- active={!!href && href === activeHref}
- dataAttr={section.key === 'recent' ? 'today-tool-recent' : 'today-tool'}
- />
- )
- })}
- </div>
+ // A product can show in Starred and in its category, so the group keeps the rows apart on the keyboard path.
+ const renderProduct = (item: FileSystemImport, group: string): JSX.Element => (
+ <TodayProductRow
+ key={item.href}
+ value={`${group}:${item.href}`}
+ label={productsItemName(item)}
+ product={item}
+ to={item.href ?? ''}
+ active={item.href === activeHref}
+ starred={starredHrefs.has(item.href ?? '')}
+ inStarredGroup={group === 'starred'}
+ />
)
return (
@@ -75,47 +54,55 @@ export function TodayProductsSidebar(): JSX.Element {
searchLabel="Search products"
dataAttr="today-products-search"
>
- {!hasProducts && !searchedAnalyticsTypes.length && (
- <Text size="xs" variant="muted" className="block px-2 py-1">
- No products match that search.
- </Text>
- )}
- {recentSection && renderToolSection(recentSection, true)}
- {showLibrary && (
- <div>
- <TodayPaneGroupLabel first={!recentSection}>Library</TodayPaneGroupLabel>
- {showAllObjects && (
- <TodayPaneRow
- value="library:all"
- label="All objects"
- icon={<IconFolder />}
- to={urls.library()}
- active={path === urls.library()}
- dataAttr="today-library-all"
- />
- )}
- {libraryTypes.map((type) => (
+ {!hasProducts &&
+ (searchedAnalyticsTypes.length > 0 ? (
+ <TodayProductsAnalyticsHint analyticsTypes={searchedAnalyticsTypes} />
+ ) : (
+ <Text size="xs" variant="muted" className="block px-2 py-1">
+ No products match that search.
+ </Text>
+ ))}
+ {pinnedProducts.length > 0 && (
+ <div className="flex flex-col gap-px pb-2">
+ {pinnedProducts.map((item) => (
<TodayPaneRow
- key={type.value}
- value={`library:${type.value}`}
- label={type.pluralLabel}
- icon={iconForType(type.value as FileSystemIconType)}
- to={libraryListHref(type.value) ?? urls.library(type.value)}
- // A product page can share a scene with a Library list. The product's own row then takes the highlight.
- active={
- path === urls.library(type.value) || (objectPageType === type.value && !activeHref)
- }
- action={<LibraryCreateButton objectType={type.value} />}
- dataAttr="today-library-type"
+ key={item.href}
+ value={`pinned:${item.href}`}
+ label={productsItemName(item)}
+ icon={<NavProductIcon item={item} />}
+ to={item.href ?? ''}
+ active={item.href === activeHref}
+ dataAttr="today-tool-pinned"
/>
))}
</div>
)}
- {categorySections.map((section, index) =>
- renderToolSection(section, !recentSection && !showLibrary && index === 0)
+ {starredProducts.length > 0 && (
+ <TodayPaneSection
+ label="Starred"
+ open={starredOpen || searching}
+ count={starredProducts.length}
+ onToggle={() => setStarredOpen(!starredOpen)}
+ dataAttr="today-section-starred"
+ >
+ {starredProducts.map((item) => renderProduct(item, 'starred'))}
+ </TodayPaneSection>
)}
- {searchedAnalyticsTypes.length > 0 && (
- <TodayProductsAnalyticsHint analyticsTypes={searchedAnalyticsTypes} />
+ {productCount > 0 && (
+ <TodayPaneSection
+ label="All products"
+ open={allProductsOpen || searching}
+ count={productCount}
+ onToggle={() => setAllProductsOpen(!allProductsOpen)}
+ dataAttr="today-section-all-products"
+ >
+ {productGroups.map((group, index) => (
+ <div key={group.label}>
+ <TodayPaneGroupLabel first={index === 0}>{group.label}</TodayPaneGroupLabel>
+ {group.items.map((item) => renderProduct(item, group.label))}
+ </div>
+ ))}
+ </TodayPaneSection>
)}
</TodayPaneSearchList>
</div>
diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsx
index c737d48ca742..60923e516a24 100644
--- a/frontend/src/layout/today/TodayShell.tsx
+++ b/frontend/src/layout/today/TodayShell.tsx
@@ -19,7 +19,6 @@ import { todayPanelChatSessionLogic } from './todayPanelChatSessionLogic'
import { TodayPhoneHeader } from './TodayPhoneHeader'
import { TodayRail } from './TodayRail'
import { TODAY_PANES } from './todayRailItems'
-import { todayRecentsLogic } from './todayRecentsLogic'
import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_CLOSE_THRESHOLD, clampSidebarWidth, todayShellLogic } from './todayShellLogic'
import { TodaySidebarCollapseButton } from './TodaySidebarCollapseButton'
import { TodaySidebarFooter } from './TodaySidebarFooter'
@@ -30,8 +29,8 @@ const TodaySpacesPane = lazyWithRetry(() => import('./TodaySpacesPane').then((m)
const TodayAnalyticsSidebar = lazyWithRetry(() =>
import('./TodayAnalyticsSidebar').then((m) => ({ default: m.TodayAnalyticsSidebar }))
)
-const TodayProductsSidebar = lazyWithRetry(() =>
- import('./TodayProductsSidebar').then((m) => ({ default: m.TodayProductsSidebar }))
+const TodayProductsPane = lazyWithRetry(() =>
+ import('./TodayProductsPane').then((m) => ({ default: m.TodayProductsPane }))
)
const TodaySettingsSidebar = lazyWithRetry(() =>
import('./TodaySettingsSidebar').then((m) => ({ default: m.TodaySettingsSidebar }))
@@ -44,8 +43,6 @@ const NewSpaceDialog = lazyWithRetry(() =>
export function TodayShell({ className }: { className?: string }): JSX.Element {
const { activePane, mobileLayout, phoneLayout, sidebarVisible, sidebarWidth, phoneHeaderHidden } =
useValues(todayShellLogic)
- // Records the tools visited while other panes are open, so the Tools pane's Recent group is ready.
- useMountedLogic(todayRecentsLogic)
useMountedLogic(todayPanelChatSessionLogic)
const { setMobileSidebarOpen, setSidebarOpen, setSidebarWidth, toggleSidebar } = useActions(todayShellLogic)
useShortcut({
@@ -101,7 +98,7 @@ export function TodayShell({ className }: { className?: string }): JSX.Element {
) : activePane === 'settings' ? (
<TodaySettingsSidebar />
) : (
- <TodayProductsSidebar />
+ <TodayProductsPane />
)}
</Suspense>
)
diff --git a/frontend/src/layout/today/todayPreviewCards.ts b/frontend/src/layout/today/todayPreviewCards.ts
index 2ca34bdb7eb8..fcebff887a88 100644
--- a/frontend/src/layout/today/todayPreviewCards.ts
+++ b/frontend/src/layout/today/todayPreviewCards.ts
@@ -1,7 +1,8 @@
import { libraryObjectHref, libraryObjectName, libraryTypeLabel } from 'scenes/library/libraryUtils'
import { splitPath } from '~/layout/panel-layout/ProjectTree/utils'
-import { FileSystemEntry } from '~/queries/schema/schema-general'
+import { SidebarProductMeta, sidebarProductMeta } from '~/layout/panel-layout/sidebarProductMeta'
+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'
import { getOriginProductMeta } from 'products/posthog_ai/frontend/api/taskSource'
import { PrStateEnumApi, TaskUserBasicInfoApi } from 'products/tasks/frontend/generated/api.schemas'
@@ -51,7 +52,13 @@ export interface TodayObjectPreview {
lastViewedAt: string | null
}
-export type TodayPreviewPayload = TodaySessionPreview | TodayChatPreview | TodayObjectPreview
+export interface TodayProductPreview extends SidebarProductMeta {
+ kind: 'product'
+ label: string
+ product: FileSystemImport
+}
+
+export type TodayPreviewPayload = TodaySessionPreview | TodayChatPreview | TodayObjectPreview | TodayProductPreview
export function sessionPreview(
item: TodayWorkItem,
@@ -115,3 +122,7 @@ export function chatPreview(item: TodayWorkItem): TodayChatPreview {
timestamp: item.timestamp,
}
}
+
+export function productPreview(label: string, product: FileSystemImport): TodayProductPreview {
+ return { kind: 'product', label, product, ...sidebarProductMeta(product) }
+}
diff --git a/frontend/src/layout/today/todayProductsLogic.test.ts b/frontend/src/layout/today/todayProductsLogic.test.ts
new file mode 100644
index 000000000000..2efd2dac4891
--- /dev/null
+++ b/frontend/src/layout/today/todayProductsLogic.test.ts
@@ -0,0 +1,26 @@
+import { getNavProductItems } from '~/layout/panel-layout/navbar/tabs/navProductItems'
+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'
+
+import { resolveStarredProducts } from './todayProductsLogic'
+
+const productShortcut = (id: string, path: string, href?: string): FileSystemEntry =>
+ ({ id, path, type: 'product', href }) as FileSystemEntry
+
+describe('todayProductsLogic', () => {
+ it('resolves product stars in saved order, by name or by link', () => {
+ const candidates: FileSystemImport[] = getNavProductItems({})
+ const shortcuts = [
+ productShortcut('1', 'Session replay'),
+ // Stars made by the backend have no href, so they match by name.
+ productShortcut('2', 'Product analytics'),
+ { id: '3', path: 'Weekly signups', type: 'insight', ref: 'abc', href: '/insights/abc' } as FileSystemEntry,
+ productShortcut('4', 'Old name', '/replay/home'),
+ productShortcut('5', 'Not a product'),
+ ]
+
+ expect(resolveStarredProducts(shortcuts, candidates).map((item) => item.path)).toEqual([
+ 'Session replay',
+ 'Product analytics',
+ ])
+ })
+})
diff --git a/frontend/src/layout/today/todayProductsLogic.ts b/frontend/src/layout/today/todayProductsLogic.ts
new file mode 100644
index 000000000000..5ec9f973fa6c
--- /dev/null
+++ b/frontend/src/layout/today/todayProductsLogic.ts
@@ -0,0 +1,198 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { router } from 'kea-router'
+
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import {
+ getNavProductItems,
+ groupNavProducts,
+ navProductHrefForPath,
+ pinnedNavProducts,
+} from '~/layout/panel-layout/navbar/tabs/navProductItems'
+import { ProductsItemGroup, productMatchesSearch } from '~/layout/panel-layout/navbar/tabs/productsCatalog'
+import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'
+import { findProductShortcut } from '~/layout/panel-layout/ProjectTree/utils'
+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'
+import { TeamPublicType, TeamType } from '~/types'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayProductsLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ shortcutData: FileSystemEntry[] // projectTreeDataLogic
+ shortcutDataLoading: boolean // projectTreeDataLogic
+ location: {
+ pathname: string
+ search: string
+ hash: string
+ } // router
+ currentTeam: TeamPublicType | TeamType | null // teamLogic
+ activeHref: string | null
+ allProductsOpen: boolean
+ pinnedProducts: FileSystemImport[]
+ productCount: number
+ productGroups: ProductsItemGroup[]
+ products: FileSystemImport[]
+ search: string
+ starredHrefs: Set<string>
+ starredOpen: boolean
+ starredProducts: FileSystemImport[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayProductsLogicActions {
+ addShortcutItem: (item: FileSystemEntry) => {
+ item: FileSystemEntry
+ } // projectTreeDataLogic
+ deleteShortcut: (id: string) => {
+ id: string
+ } // projectTreeDataLogic
+ setAllProductsOpen: (open: boolean) => {
+ open: boolean
+ }
+ setSearch: (search: string) => {
+ search: string
+ }
+ setStarredOpen: (open: boolean) => {
+ open: boolean
+ }
+ toggleStarred: (item: FileSystemImport) => {
+ item: FileSystemImport
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayProductsLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ products: (featureFlags: FeatureFlagsSet, currentTeam: TeamPublicType | TeamType | null) => FileSystemImport[]
+ pinnedProducts: (products: FileSystemImport[], search: string) => FileSystemImport[]
+ productGroups: (products: FileSystemImport[], search: string) => ProductsItemGroup[]
+ productCount: (productGroups: ProductsItemGroup[]) => number
+ activeHref: (
+ location: {
+ hash: string
+ pathname: string
+ search: string
+ },
+ products: FileSystemImport[]
+ ) => string | null
+ starredProducts: (
+ shortcutData: FileSystemEntry[],
+ products: FileSystemImport[],
+ search: string
+ ) => FileSystemImport[]
+ starredHrefs: (shortcutData: FileSystemEntry[], products: FileSystemImport[]) => Set<string>
+ }
+}
+
+export type todayProductsLogicType = MakeLogicType<
+ todayProductsLogicValues,
+ todayProductsLogicActions,
+ Record<string, any>,
+ todayProductsLogicMeta
+>
+
+/** The products behind the product stars, in saved order. A star made before a rename still finds its product by href. */
+export function resolveStarredProducts(
+ shortcuts: FileSystemEntry[],
+ candidates: FileSystemImport[]
+): FileSystemImport[] {
+ const seen = new Set<string>()
+ return shortcuts.flatMap((shortcut) => {
+ const item = candidates.find((candidate) => !!candidate.href && findProductShortcut(candidate, [shortcut]))
+ if (!item?.href || seen.has(item.href)) {
+ return []
+ }
+ seen.add(item.href)
+ return [item]
+ })
+}
+
+export const todayProductsLogic = kea<todayProductsLogicType>([
+ path(['layout', 'today', 'todayProductsLogic']),
+ connect(() => ({
+ values: [
+ projectTreeDataLogic,
+ ['shortcutData', 'shortcutDataLoading'],
+ featureFlagLogic,
+ ['featureFlags'],
+ teamLogic,
+ ['currentTeam'],
+ router,
+ ['location'],
+ ],
+ actions: [projectTreeDataLogic, ['addShortcutItem', 'deleteShortcut']],
+ })),
+ actions({
+ setSearch: (search: string) => ({ search }),
+ setStarredOpen: (open: boolean) => ({ open }),
+ setAllProductsOpen: (open: boolean) => ({ open }),
+ toggleStarred: (item: FileSystemImport) => ({ item }),
+ }),
+ reducers({
+ search: ['', { setSearch: (_, { search }) => search }],
+ // pinned: storage keys for persisted state. Renaming them resets everyone's sections.
+ starredOpen: [true, { persist: true }, { setStarredOpen: (_, { open }) => open }],
+ allProductsOpen: [
+ inStorybook() || inStorybookTestRunner(),
+ { persist: true },
+ { setAllProductsOpen: (_, { open }) => open },
+ ],
+ }),
+ selectors({
+ // The same list as the Products tab of the current navigation. Home has its own rail item.
+ products: [
+ (s) => [s.featureFlags, s.currentTeam],
+ (featureFlags: FeatureFlagsSet, currentTeam: TeamPublicType | TeamType | null): FileSystemImport[] =>
+ getNavProductItems(featureFlags, currentTeam?.created_at).filter(
+ (item) => item.href !== urls.projectRoot() && !getProductAccessDisabledReason(item)
+ ),
+ ],
+ pinnedProducts: [
+ (s) => [s.products, s.search],
+ (products: FileSystemImport[], search: string): FileSystemImport[] => pinnedNavProducts(products, search),
+ ],
+ productGroups: [
+ (s) => [s.products, s.search],
+ (products: FileSystemImport[], search: string): ProductsItemGroup[] => groupNavProducts(products, search),
+ ],
+ productCount: [
+ (s) => [s.productGroups],
+ (groups: ProductsItemGroup[]): number => groups.reduce((count, group) => count + group.items.length, 0),
+ ],
+ // Every row, starred ones too, is in the product list, so the best match there is the only active row.
+ activeHref: [
+ (s) => [s.location, s.products],
+ (location: { pathname: string }, products: FileSystemImport[]): string | null =>
+ navProductHrefForPath(removeProjectIdIfPresent(location.pathname), products),
+ ],
+ starredProducts: [
+ (s) => [s.shortcutData, s.products, s.search],
+ (shortcuts: FileSystemEntry[], products: FileSystemImport[], search: string): FileSystemImport[] =>
+ resolveStarredProducts(shortcuts, products).filter((item) => productMatchesSearch(item, search)),
+ ],
+ starredHrefs: [
+ (s) => [s.shortcutData, s.products],
+ (shortcuts: FileSystemEntry[], products: FileSystemImport[]): Set<string> =>
+ new Set(resolveStarredProducts(shortcuts, products).map((item) => item.href ?? '')),
+ ],
+ }),
+ listeners(({ actions, values }) => ({
+ toggleStarred: ({ item }) => {
+ // The star buttons are disabled while a change saves. This also stops a repeated dispatch.
+ if (values.shortcutDataLoading) {
+ return
+ }
+ const shortcut = findProductShortcut(item, values.shortcutData)
+ if (shortcut?.id) {
+ actions.deleteShortcut(shortcut.id)
+ } else {
+ actions.addShortcutItem(item as FileSystemEntry)
+ }
+ },
+ })),
+])
diff --git a/frontend/src/layout/today/todayRailItems.tsx b/frontend/src/layout/today/todayRailItems.tsx
index 5162329f30b9..752ab8871623 100644
--- a/frontend/src/layout/today/todayRailItems.tsx
+++ b/frontend/src/layout/today/todayRailItems.tsx
@@ -1,5 +1,6 @@
-import { IconApps, IconChat, IconGear, IconHome, IconSidebarClose, IconSidebarOpen, IconTrends } from '@posthog/icons'
+import { IconApps, IconChat, IconGear, IconHome, IconSidebarClose, IconSidebarOpen } from '@posthog/icons'
+import { IconAnalyticsBars } from 'lib/lemon-ui/icons'
import { isMac } from 'lib/utils/dom'
import { urls } from 'scenes/urls'
@@ -27,7 +28,7 @@ export const TODAY_PANES: Record<TodayRailPane, TodayPane> = {
action: TodayNewChatButton,
},
// No home: like Products, a pick only opens the sidebar and the open page stays.
- analytics: { label: 'Analytics', title: 'Analytics', icon: <IconTrends />, action: TodayNewAnalyticsButton },
+ analytics: { label: 'Analytics', title: 'Analytics', icon: <IconAnalyticsBars />, action: TodayNewAnalyticsButton },
products: { label: 'Products', title: 'Products', icon: <IconApps /> },
settings: { label: 'Settings', title: 'Settings', icon: <IconGear />, home: () => urls.settings('project') },
}
diff --git a/frontend/src/layout/today/todayRecentsLogic.ts b/frontend/src/layout/today/todayRecentsLogic.ts
deleted file mode 100644
index 75a5953284d2..000000000000
--- a/frontend/src/layout/today/todayRecentsLogic.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers } from 'kea'
-import { router } from 'kea-router'
-import type { LocationChangedPayload } from 'kea-router/lib/types'
-
-import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
-import { toolHrefForPath } from 'scenes/tools/toolsUtils'
-
-export const TODAY_RECENTS_LIMIT = 5
-
-function pushRecent(list: string[], value: string): string[] {
- return [value, ...list.filter((item) => item !== value)].slice(0, TODAY_RECENTS_LIMIT)
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayRecentsLogicValues {
- recentToolHrefs: string[]
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayRecentsLogicActions {
- recordLocation: (pathname: string) => {
- pathname: string
- }
- recordToolVisit: (href: string) => {
- href: string
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayRecentsLogicMeta {
- __keaTypeGenInternalReducerActions: {
- 'location changed (kea.router)': ({
- method,
- pathname,
- search,
- searchParams,
- hash,
- hashParams,
- initial,
- url,
- routerState,
- }: LocationChangedPayload) => {
- payload: {
- hash: string
- hashParams: Record<string, any>
- initial: boolean
- method: 'POP' | 'PUSH' | 'REPLACE'
- pathname: string
- routerState: Record<string, any>
- search: string
- searchParams: Record<string, any>
- url: string
- }
- type: 'location changed (kea.router)'
- }
- }
-}
-
-export type todayRecentsLogicType = MakeLogicType<
- todayRecentsLogicValues,
- todayRecentsLogicActions,
- Record<string, any>,
- todayRecentsLogicMeta
->
-
-/**
- * What the Tools pane lists as recently viewed.
- * Tools have no server record of views, so this browser keeps one as the user moves between pages.
- */
-export const todayRecentsLogic = kea<todayRecentsLogicType>([
- path(['layout', 'today', 'todayRecentsLogic']),
- actions({
- recordToolVisit: (href: string) => ({ href }),
- recordLocation: (pathname: string) => ({ pathname }),
- }),
- reducers({
- // pinned: storage keys for persisted state. Renaming them clears everyone's recents.
- recentToolHrefs: [
- [] as string[],
- { persist: true },
- { recordToolVisit: (state, { href }) => pushRecent(state, href) },
- ],
- }),
- listeners(({ actions }) => ({
- recordLocation: ({ pathname }) => {
- const path = removeProjectIdIfPresent(pathname)
- const toolHref = toolHrefForPath(path)
- if (toolHref) {
- actions.recordToolVisit(toolHref)
- }
- },
- [router.actionTypes.locationChanged]: ({ pathname }: LocationChangedPayload) => {
- actions.recordLocation(pathname)
- },
- })),
- afterMount(({ actions }) => {
- actions.recordLocation(router.values.location.pathname)
- }),
-])
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
index 4af2c9d1697f..201a596349f7 100644
--- a/frontend/src/layout/today/todayShellLogic.test.ts
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -3,14 +3,9 @@ import { router } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
-import {
- getToolSourceItems,
- isToolItem,
- libraryRowProductLabels,
- toolHrefForPath,
- toolLabel,
-} from 'scenes/tools/toolsUtils'
+import { getToolSourceItems, isToolItem, toolLabel } from 'scenes/tools/toolsUtils'
+import { navProductHrefForPath } from '~/layout/panel-layout/navbar/tabs/navProductItems'
import { initKeaTests } from '~/test/init'
import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_MAX_WIDTH, railPaneForPath, todayShellLogic } from './todayShellLogic'
@@ -62,9 +57,14 @@ describe('todayShellLogic', () => {
['/data-management/destinations/abc', '/data-management/destinations?tab=all'],
['/data-management/events', '/data-management'],
['/data-management-old', null],
- ])('selects the tool for %s', (path, href) => {
- const tools = [{ href: '/data-management' }, { href: '/data-management/destinations?tab=all' }]
- expect(toolHrefForPath(path, tools)).toBe(href)
+ ['/replay/abc', '/replay/home'],
+ ])('selects the product for %s', (path, href) => {
+ const products = [
+ { path: 'Data management', href: '/data-management' },
+ { path: 'Destinations', href: '/data-management/destinations?tab=all' },
+ { path: 'Session replay', href: '/replay/home' },
+ ]
+ expect(navProductHrefForPath(path, products)).toBe(href)
})
test.each([
@@ -82,10 +82,6 @@ describe('todayShellLogic', () => {
expect(rows.includes(label)).toBe(ownRow)
})
- it('finds the Feature flags row with a search for the product name', () => {
- expect(libraryRowProductLabels('feature_flag')).toContain('Feature flags')
- })
-
test.each([
['home', '/home'],
['spaces', '/spaces/new'],
@@ -101,6 +97,18 @@ describe('todayShellLogic', () => {
expect(logic.values.activePane).toBe(pane)
})
+ test.each([
+ ['products', 'products'],
+ ['home', 'analytics'],
+ ] as const)('opening Dashboards with the %s pane open shows the %s pane', (openPane, pane) => {
+ const logic = todayShellLogic()
+ logic.mount()
+
+ logic.actions.pickPane(openPane)
+ router.actions.push('/project/1/dashboard')
+ expect(logic.values.activePane).toBe(pane)
+ })
+
test.each(['spaces', 'analytics', 'products'] as const)(
'a second rail click on %s hides the sidebar it opened',
(pane) => {
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
index 4e49a3344b6f..4d6f7bdf3fb9 100644
--- a/frontend/src/layout/today/todayShellLogic.ts
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -11,10 +11,11 @@ import { isUnderPath, removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { fromPostHogProducts } from 'scenes/analytics/analyticsUtils'
import { libraryTypeForPath } from 'scenes/library/libraryUtils'
import { settingsSectionSceneForPath } from 'scenes/settings/settingsSectionScenes'
-import { toolHrefForPath } from 'scenes/tools/toolsUtils'
import { urls } from 'scenes/urls'
import { navigationLogic } from '~/layout/navigation/navigationLogic'
+import { getNavProductPages, navProductHrefForPath } from '~/layout/panel-layout/navbar/tabs/navProductItems'
+import { FileSystemImport } from '~/queries/schema/schema-general'
import { TODAY_PANES } from './todayRailItems'
@@ -98,13 +99,31 @@ export function railPaneForPath(pathname: string): TodayRailPane | null {
isUnderPath(path, urls.library()) ||
isUnderPath(path, urls.tools()) ||
libraryTypeForPath(path) ||
- toolHrefForPath(path)
+ productsPaneListsPath(path)
) {
return 'products'
}
return null
}
+let navProductPages: FileSystemImport[] | null = null
+
+/** Whether the Products pane lists the product that owns this page. Some, like Dashboards, open under Analytics too. */
+function productsPaneListsPath(path: string): boolean {
+ navProductPages ??= getNavProductPages()
+ return !!navProductHrefForPath(path, navProductPages)
+}
+
+/** The pane to show after a page change: a page both panes list keeps the Products pane when it is open. */
+function paneAfterNavigation(openPane: TodayRailPane | null, pathname: string): TodayRailPane | null {
+ const routePane = railPaneForPath(pathname)
+ return openPane === 'products' &&
+ routePane === 'analytics' &&
+ productsPaneListsPath(removeProjectIdIfPresent(pathname))
+ ? openPane
+ : (routePane ?? openPane)
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface todayShellLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
@@ -273,7 +292,7 @@ export const todayShellLogic = kea<todayShellLogicType>([
null as TodayRailPane | null,
{
pickPane: (_, { pane }) => pane,
- locationChanged: (state, { pathname }) => railPaneForPath(pathname) ?? state,
+ locationChanged: (state, { pathname }) => paneAfterNavigation(state, pathname),
},
],
sidebarOpen: [
diff --git a/frontend/src/layout/today/todayToolsLogic.ts b/frontend/src/layout/today/todayToolsLogic.ts
deleted file mode 100644
index 11b8eae0dcb5..000000000000
--- a/frontend/src/layout/today/todayToolsLogic.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
-
-import { toolsLogic } from 'scenes/tools/toolsLogic'
-import { ToolGroup, groupTools, toolMatchesSearch } from 'scenes/tools/toolsUtils'
-
-import { FileSystemImport } from '~/queries/schema/schema-general'
-
-import { todayRecentsLogic } from './todayRecentsLogic'
-import { railPaneForPath } from './todayShellLogic'
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayToolsLogicValues {
- recentToolHrefs: string[] // todayRecentsLogic
- tools: FileSystemImport[] // toolsLogic
- productTools: FileSystemImport[]
- recentTools: FileSystemImport[]
- search: string
- toolGroups: ToolGroup[]
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayToolsLogicActions {
- setSearch: (search: string) => {
- search: string
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface todayToolsLogicMeta {
- __keaTypeGenInternalSelectorTypes: {
- productTools: (tools: FileSystemImport[]) => FileSystemImport[]
- toolGroups: (productTools: FileSystemImport[], search: string) => ToolGroup[]
- recentTools: (recentToolHrefs: string[], productTools: FileSystemImport[], search: string) => FileSystemImport[]
- }
-}
-
-export type todayToolsLogicType = MakeLogicType<
- todayToolsLogicValues,
- todayToolsLogicActions,
- Record<string, any>,
- todayToolsLogicMeta
->
-
-export const todayToolsLogic = kea<todayToolsLogicType>([
- path(['layout', 'today', 'todayToolsLogic']),
- connect(() => ({ values: [toolsLogic, ['tools'], todayRecentsLogic, ['recentToolHrefs']] })),
- actions({ setSearch: (search: string) => ({ search }) }),
- reducers({ search: ['', { setSearch: (_, { search }) => search }] }),
- selectors({
- // Tools whose pages open another pane, like dashboards and notebooks under Analytics, stay out of Products.
- productTools: [
- (s) => [s.tools],
- (tools: FileSystemImport[]): FileSystemImport[] =>
- tools.filter((tool) => !tool.href || railPaneForPath(tool.href.split('?')[0]) !== 'analytics'),
- ],
- toolGroups: [
- (s) => [s.productTools, s.search],
- (tools: FileSystemImport[], search: string): ToolGroup[] => groupTools(tools, search),
- ],
- recentTools: [
- (s) => [s.recentToolHrefs, s.productTools, s.search],
- (hrefs: string[], tools: FileSystemImport[], search: string): FileSystemImport[] =>
- hrefs
- .flatMap((href) => tools.find((tool) => tool.href === href) ?? [])
- .filter((tool) => toolMatchesSearch(tool, search)),
- ],
- }),
-])
diff --git a/frontend/src/lib/lemon-ui/icons/icons.tsx b/frontend/src/lib/lemon-ui/icons/icons.tsx
index 463305f13f78..1d86666544be 100644
--- a/frontend/src/lib/lemon-ui/icons/icons.tsx
+++ b/frontend/src/lib/lemon-ui/icons/icons.tsx
@@ -136,6 +136,14 @@ export function IconStamphog(props: LemonIconProps): JSX.Element {
)
}
+export function IconAnalyticsBars(props: LemonIconProps): JSX.Element {
+ return (
+ <LemonIconBase stroke="currentColor" strokeWidth="1.5" strokeLinecap="square" strokeLinejoin="round" {...props}>
+ <path d="M9.25 20.25V13.75H4.75C4.19772 13.75 3.75 14.1977 3.75 14.75V19.25C3.75 19.8023 4.19772 20.25 4.75 20.25H9.25ZM9.25 20.25H14.75M9.25 20.25V4.75C9.25 4.19772 9.69772 3.75 10.25 3.75H13.75C14.3023 3.75 14.75 4.19772 14.75 4.75V20.25M14.75 20.25H19.75C20.0261 20.25 20.25 20.0261 20.25 19.75V9.75C20.25 9.19772 19.8023 8.75 19.25 8.75H14.75V20.25Z" />
+ </LemonIconBase>
+ )
+}
+
// material design clipboard-edit-outline
export function IconClipboardEdit(props: LemonIconProps): JSX.Element {
return (
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
index ed2ead2a6d2f..dfaa0e88e014 100644
--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx
+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
@@ -1073,9 +1073,36 @@ export const LibraryFeatureFlags: Story = {
parameters: { pageUrl: urls.featureFlags() },
}
-export const ToolsPane: Story = {
+const PRODUCT_STARS = mswDecorator({
+ get: {
+ '/api/environments/:team_id/file_system_shortcut/': {
+ count: 3,
+ next: null,
+ previous: null,
+ results: [
+ { id: 'star-1', path: 'Product analytics', type: 'insight', href: '/insights' },
+ { id: 'star-2', path: 'Session replay', type: 'session_recording_playlist', href: '/replay/home' },
+ { id: 'star-3', path: 'Error tracking', type: 'error_tracking', href: '/error_tracking' },
+ ],
+ },
+ },
+})
+
+export const ProductsPane: Story = {
+ decorators: [PRODUCT_STARS],
+ play: async ({ canvasElement }) => {
+ await userEvent.click(await within(canvasElement).findByLabelText('Products'))
+ await within(canvasElement).findByText('Starred')
+ },
+}
+
+// Hovering a product row opens its card with the description, an example and the docs link.
+export const ProductsPaneProductCard: Story = {
+ decorators: [PRODUCT_STARS],
play: async ({ canvasElement }) => {
- await userEvent.click(await within(canvasElement).findByLabelText('Tools'))
+ await userEvent.click(await within(canvasElement).findByLabelText('Products'))
+ await userEvent.hover(await sidebarRow(canvasElement, 'Web analytics', 'today-tool'))
+ await within(document.body).findByText('For example')
},
}
diff --git a/frontend/src/scenes/tools/toolsUtils.ts b/frontend/src/scenes/tools/toolsUtils.ts
index a550cdcc1ab8..98bed0f75225 100644
--- a/frontend/src/scenes/tools/toolsUtils.ts
+++ b/frontend/src/scenes/tools/toolsUtils.ts
@@ -56,42 +56,6 @@ export function isToolItem(item: FileSystemImport): boolean {
)
}
-let productLabelsByLibraryType: Map<string, string[]> | null = null
-
-/** The names of the products a Library type row opens, so a search for "Product analytics" finds Insights. */
-export function libraryRowProductLabels(type: string): string[] {
- if (!productLabelsByLibraryType) {
- const labels = new Map<string, string[]>()
- for (const item of getToolSourceItems()) {
- if (libraryRowOpensProduct(item)) {
- const itemType = productObjectType(item)
- labels.set(itemType, [...(labels.get(itemType) ?? []), toolLabel(item)])
- }
- }
- productLabelsByLibraryType = labels
- }
- return productLabelsByLibraryType.get(type) ?? []
-}
-
-export function toolHrefForPath(
- path: string,
- tools: Pick<FileSystemImport, 'href'>[] = getToolSourceItems().filter(isToolItem)
-): string | null {
- let match: { href: string; toolPath: string } | null = null
- for (const { href } of tools) {
- const toolPath = href?.split(/[?#]/)[0]
- if (
- href &&
- toolPath &&
- (path === toolPath || path.startsWith(`${toolPath}/`)) &&
- (!match || toolPath.length > match.toolPath.length)
- ) {
- match = { href, toolPath }
- }
- }
- return match?.href ?? null
-}
-
export function groupTools(tools: FileSystemImport[], search: string): ToolGroup[] {
const groups = new Map<string, FileSystemImport[]>()
for (const tool of tools) {
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 72dc305d158f..69308a5d592e 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -382,6 +382,8 @@ Attached panel outside the popup: pass `popupSibling` on `SelectContent` — ren
</Combobox>
```
+A highlighted Combobox or Autocomplete item paints its content in the foreground color. Put `data-keep-color` on a child that must keep its own color, such as a colored product icon.
+
Multi-select with chips:
```tsx
diff --git a/packages/quill/packages/primitives/src/autocomplete.css b/packages/quill/packages/primitives/src/autocomplete.css
index 397eb30ad0e1..0d2a94f1e2af 100644
--- a/packages/quill/packages/primitives/src/autocomplete.css
+++ b/packages/quill/packages/primitives/src/autocomplete.css
@@ -127,7 +127,9 @@
opacity: 0.5;
}
- .quill-autocomplete__item:not([data-variant='destructive'])[data-highlighted] * {
+ /* `data-keep-color` opts a child out, for example a product icon that carries its own color. */
+ .quill-autocomplete__item:not([data-variant='destructive'])[data-highlighted]
+ *:not([data-keep-color], [data-keep-color] *) {
color: var(--foreground);
}
diff --git a/packages/quill/packages/primitives/src/combobox.css b/packages/quill/packages/primitives/src/combobox.css
index c5998f6a73c0..094522a2893e 100644
--- a/packages/quill/packages/primitives/src/combobox.css
+++ b/packages/quill/packages/primitives/src/combobox.css
@@ -149,7 +149,9 @@
box-shadow: none;
}
- .quill-combobox__item:not([data-variant='destructive'])[data-highlighted] * {
+ /* `data-keep-color` opts a child out, for example a product icon that carries its own color. */
+ .quill-combobox__item:not([data-variant='destructive'])[data-highlighted]
+ *:not([data-keep-color], [data-keep-color] *) {
color: var(--foreground);
}