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(navigation): star all product rows and keep menus on starred ones (#111088)

Mike Warren913398f21dad
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 7947292c6fe3..20fd68266dd1 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -4073,45 +4073,45 @@ snapshots:
layout-products-and-files--chat--light:
hash: v1.k794b7964.4ef1016755694332433ac609609d9260b3f41ec0d4e2976d865e80ec659eb6ea.1h6HQOJz0Cx2kEkA-uRjet4eMxoBWDkZafr5JGHrKBw
layout-products-and-files--collapsed--dark:
- hash: v1.k794b7964.47ba306c86104d0b1205b706a040aa06a49f124c71b0f2d602230bda6a438f97.UVVSeegIP8asQH9E5D0dNTGCllz9ANHtpftLX043dvw
+ hash: v1.k794b7964.67a1d6c96ccb2cb7476f0d35e922386235c3ff0a803a8e02deda6b73f61cc68d.YvRt8rU0z_f86hQ_1RwvtCYu74ZOO-oHNrXrP65yAYQ
layout-products-and-files--collapsed--light:
- hash: v1.k794b7964.de50a58a262adfe7c5541fcf12dcc6733ff6126028ce8444bffb111820a90acf.ZB3fLSm9GPnhA7f33FtGRfW8_h3eC9WOzNSLd-4Kjsg
+ hash: v1.k794b7964.e7d8f5b94607d6626a434328a7d3b09f6b896b0b8b1069a519e7f147c6a9a0ff.by7DXbMATATWtZjbLK1xoXtHypya157EapE7anGY6bo
layout-products-and-files--customize-sidebar--dark:
- hash: v1.k794b7964.be15e9a73184c7e18b0d429653f0ab163c5b828267e544c6b390a8ec7d63898b.1eYvNSSIklRr_wgw1q7TjAmOsWtW9Y4TBcLmmGhPaMc
+ hash: v1.k794b7964.e7dac0b8931a4b266f739fd31b31f5d66cf105c763179e83a12dd26b008d0d76.3K2MSFKq9uEdcpAMnAN1DVpzjC1OE-YIG97zgyqSicA
layout-products-and-files--customize-sidebar--light:
hash: v1.k794b7964.3df0b86a695cd6b3c50650fa27cc45d4d74bc297854e15c5695e5bc8259fdaac.1OvFXGYQ3Q1mJgfJ5wBcOfazO53BGarOG92UIYwLiOE
layout-products-and-files--customize-sidebar-dark--dark:
- hash: v1.k794b7964.c3033a8a6d2be864f0c3f1a40cdebef20790deb676c061cb9afc8b975f113947.mm7E7sVnlqy9WZAV-vXAn8IRw-U4JY6JRytb5HgklCY
+ hash: v1.k794b7964.fbd4c49af4ddd94e0d7430237297907397e8851742ace987c886907846d8aa49.Nc4AXxtA46SuvENT1PhTanX3bFdm35oXGBkBefP5WmM
layout-products-and-files--customize-sidebar-dark--light:
hash: v1.k794b7964.3646a1633aa28c20992cda4f6d5ab5e3ecc215956592021010e2fd97e8d6783f.z98bESKSeramkQ9fk7YYE17cBCIarb0uGg3UZC-yp8k
layout-products-and-files--customize-sidebar-narrow--dark:
hash: v1.k794b7964.095c90506553382548950f74838853c6947b6bc981b02d9f4e3c631196b6edd1.iu1ndLSh35pf1MeFeGMhs-q4RBNR37cNVIjXWy0QcTo
layout-products-and-files--customize-sidebar-narrow--light:
- hash: v1.k794b7964.df82aa5d6b7cbd7aa11ea68f1a51624ae397c4fca8ac18debe5159bb5cb0ebe7.SKqP1uJdUmbV07W0ASLB0dWSOY3Uko-l-zbyEBR_0C8
+ hash: v1.k794b7964.8ea9526d99b7c5798e53655662ae500869ecd80d6330f21b50e3375c06e87cf3.qpmjY7z6nd9fYOI1YBpp0qSn__TZvgjJe_pLmKe2pdI
layout-products-and-files--customize-sidebar-no-matches--dark:
- hash: v1.k794b7964.6848315b9ffb70f3a861de9bb4709d240129d108860da54df277d066f8ed7e64.vNQOH0G6I7MttOCdme-ERBX1B4a8hcOHCqdtcbGLmB8
+ hash: v1.k794b7964.d8953119c0c33dc226f10e0445817eeee9428bdea4ed25365c57237085136708.x0RnF9WBdVhF0hWRZ0-L_asUwk_YD-Zk-3DRvOmapLQ
layout-products-and-files--customize-sidebar-no-matches--light:
hash: v1.k794b7964.11fadf9a26e3bea7c99b1fef56fb81a5af572088ea393a476a0c3da3efa5cf1e.6c5Prelzy0f6v8FfdgHdIcJrKPV85PNMt9jTiGgtY60
layout-products-and-files--customize-sidebar-ranked--dark:
- hash: v1.k794b7964.c3033a8a6d2be864f0c3f1a40cdebef20790deb676c061cb9afc8b975f113947.CxmThvfWkO7gPZrb_Ijl9HU_QiA2dZw2JuX_IxGpgPA
+ hash: v1.k794b7964.fbd4c49af4ddd94e0d7430237297907397e8851742ace987c886907846d8aa49.tKet8Ns5o9bpFsxA6KMDDTEADClCF0AnB6dwcgSrZqU
layout-products-and-files--customize-sidebar-ranked--light:
hash: v1.k794b7964.3646a1633aa28c20992cda4f6d5ab5e3ecc215956592021010e2fd97e8d6783f.ctJW3LDUOuDIwYLfI9yijOJZoO3y1dkmYmvAy_wdzPM
layout-products-and-files--customize-sidebar-save-failure--dark:
- hash: v1.k794b7964.eb248d9cc36e988516bb8d928c649728dd7599383a73fa72563728a80a4667fa._JDdaahTh9SL7hn6z8L-4OoJrwQ8KQZDsirIY8C6SJg
+ hash: v1.k794b7964.623cd82098b755fbfaf1edf3006675cffbcf4f06af98d160a0bda39cdca8bf10.5eY7EqbVfL6mjbbgLoMqaW3dJNYebUJuXFwEdEQrBfM
layout-products-and-files--customize-sidebar-save-failure--light:
- hash: v1.k794b7964.5cba1c138bfbe01e265563d049acc5b2f5274753abec493f9b76a4b85d5c6d99.lKqc2g0iuCmKinN1MfyzAtBiYEmAyDUsGkHpHDwsfPQ
+ hash: v1.k794b7964.37f180b759c113acc19ccdf14228e07903eef16004b204ab0450812cb3d69d26.E32-g9Ny3nJE0keyu6mwawhpBQWoGJ1KfF3NFKzTVrg
layout-products-and-files--customize-sidebar-unavailable--dark:
- hash: v1.k794b7964.c26357818063f547580526dbe787c22c2add7fe36957212419d9d020a8a5004b.K6WlkQgKPmbMmzoehwVwekyVawJZKcz1DDS69-6OPao
+ hash: v1.k794b7964.f5f2964731ccb8ff6216ee559b7ddebd9d271d594cfeaabc9a6e6adf2e39dfc3.bFu3kSwynuIaA6d0UxOOUy3bAkQL9dm_DBH10geKnlA
layout-products-and-files--customize-sidebar-unavailable--light:
hash: v1.k794b7964.dee7641b74a77589901ae0ba973119b56ce48e94ef25b59fc856db4b34766ca5.t3XfSfDOE75_5sYB3x1YVkcQEbXI66qe7W0a_lhSsNw
layout-products-and-files--customize-sidebar-without-ai-consent--dark:
- hash: v1.k794b7964.02166bcb825bbad0324fc693ebf52d9d242ffdf24f89b2dd5868e76c6ba63970.fAasuDhx6ME8RRQsRC0gFdM9yOpqqH2Dh9CZKR2aON8
+ hash: v1.k794b7964.30c92a3838d575dea4b1b819a0dcc6e0ee218243b8a7e39ab345b9d5865a45e6.v9rZDs01EFEGIxghLrMSevaT2KauiSXUd_zfxTEiVis
layout-products-and-files--customize-sidebar-without-ai-consent--light:
hash: v1.k794b7964.5cfe5d5c954783c811687f1cc5cb8441c1fc405618a7e834960b001712e334e2.qXCqh7Ef7IfZSO8S2yOjISZpiQamvysZFq83kfZn1fQ
layout-products-and-files--dark--dark:
- hash: v1.k794b7964.1a3ba25fbe4f24fa8f15c72d3ef3059d6a08869ebe3455117349f212b91aabef.27KX6370Yy_74-C9PFJtXZaJDwvhDGu-UArgd73Sgkw
+ hash: v1.k794b7964.e5643b2e27fd9baca7ea43e0ffc6bd4826038941952b6bc3f838cb672b7e1165.TkuoEA0Q0GKXHoCw30C6qt1mSrvHOKg9l7q-0vsuR24
layout-products-and-files--dark--light:
- hash: v1.k794b7964.1b095b740828abe68d601475723987c109e1aa975d0af822584638dc6086034b.yd17jIHqYCr_lgywbI_dpGoz5z26PHdi96apzKzOpNs
+ hash: v1.k794b7964.947ddfd010de73c2736b84d475f78b8f2baec83762b24c334831eb63f8032ba2.4_zlB4WjHUQz_vmxJ9i0GFqjR9IukIsX-AjVdzvaIv0
layout-products-and-files--empty-starred--dark:
hash: v1.k794b7964.c5d922c5608ecb21aab95ccdd3fdab9b566ba1b3bfdc02f4cee4eca2de3fbd69.UEjbExMAXNLMgg7gu_nFGCikQi-DZIk4dFU4Om4kU9Y
layout-products-and-files--empty-starred--light:
@@ -4121,9 +4121,9 @@ snapshots:
layout-products-and-files--files--light:
hash: v1.k794b7964.54b36a3a3bb7fde8997dfb4acf02a956cea252c908a52d90622b5cb25b9104ca.4L_xrXJ6jZla02s2VH1uMgwn50-BsHf4zE0_B_NxVpA
layout-products-and-files--files-collapsed--dark:
- hash: v1.k794b7964.b0591952d4006e603e6aa76eef63d9d02c2b190a1c3362383dfceef8d92ad3c2.XEXVgIvheCTaMBhbqMf79NhBgl09QCASZtS7UD9Ht0I
+ hash: v1.k794b7964.30c9c8d9d44a35f6ea4bc343c7593037b0975caea30271e8d497d94c4fb554f1.GlbRb1GfbmhAvCVEQoYzSmKlidcDCoWsmgYDl52X7fM
layout-products-and-files--files-collapsed--light:
- hash: v1.k794b7964.a5901a3ceac08697f2e8d24f57601eae9f939178a5c6bd980388f562b4bc1f9a.JiYoRAw2m1MC3k3rJNNEIAGDE19sXfGDW3RjkX-9_Nc
+ hash: v1.k794b7964.47e56cb189b9d477cc3e6c719d9e5d7795aa598b1be345f125c01cac9962d79b.xoSpVqW-Y1npXlUo3xGEsb42b8wovfQPTAj8OYRIxWg
layout-products-and-files--files-dark--dark:
hash: v1.k794b7964.2108f656960d8d2c354b8e867035968a366c303023268ee449c7bfe8eebf732e.ZYMDTA0KeMO7esogAEzUkGykOtDMrp1lEceUbEA-ZgI
layout-products-and-files--files-dark--light:
@@ -4189,9 +4189,9 @@ snapshots:
layout-products-and-files--flag-off-flat-nav--light:
hash: v1.k794b7964.58bd050e6237f472e90016f997b7d6f68f6650ab35545a91cadd7d519fadbdc7.kcMUzUgt6_2NA7vLY9Gt50iZD0MF6Ja5Z2i19ku68Iw
layout-products-and-files--narrow--dark:
- hash: v1.k794b7964.1d5621d6484e5f9a1be163b55a31d536ed06ce2c4ecb2d8769dfeacc5349d858.uc21bIJLxleZtw8tDapaXmdl-RYMxUxjFKMwhR5jwdo
+ hash: v1.k794b7964.cd3fd97826f1051c82de710424c59197201e0a3c0df5ff38962b57176c7af308.H4TY4HQlvMEi8IToIoNzRZluhnQm8cjRfqLpLei-pVs
layout-products-and-files--narrow--light:
- hash: v1.k794b7964.0e3aa12b3d1a5de515b67e158590fe242c29f89700d4568208dfbc13094bc0c7.PrkbIqB-9zIXJkJbjso-KzfYhwVPJXHUkKsuChxCtZY
+ hash: v1.k794b7964.cd81f9371117fd83dd00d149ec06c6248d150d7a321f0218e40577fcb37ac11b.xFPZYxiDsnJy1Jo0KwtwgldERFthy1v75SHHbFqXxvg
layout-products-and-files--no-results--dark:
hash: v1.k794b7964.7d26437565c2cc909ce308d195baee69d640ea10a6d5e2caaa7586edb01dea33.pbR09mG5i45jUJ70vG8xFGDcnwpozmWYWdvTMeuwIfY
layout-products-and-files--no-results--light:
@@ -4201,25 +4201,25 @@ snapshots:
layout-products-and-files--open-folder--light:
hash: v1.k794b7964.246baac643fe4a369b82151b6bcab2840a860b93a784d4a350b27be3bc380fff.B2objI5BYOF1Q5SItTOGTwxYczF0rBk4xf69ggaRZII
layout-products-and-files--products--dark:
- hash: v1.k794b7964.1a3ba25fbe4f24fa8f15c72d3ef3059d6a08869ebe3455117349f212b91aabef.oNiwZwiZNw6HngQ5N7GgNN1YCs9RnV_x--BgxHXk5bk
+ hash: v1.k794b7964.e5643b2e27fd9baca7ea43e0ffc6bd4826038941952b6bc3f838cb672b7e1165.yLHRPtUPzoeyOaW8WYO_MwGeYzGoz1n7Fyu1QLH42is
layout-products-and-files--products--light:
- hash: v1.k794b7964.1b095b740828abe68d601475723987c109e1aa975d0af822584638dc6086034b.xoShswyrZqleMN5KpPZdag22HKREysAYFXl2uPoYE6M
+ hash: v1.k794b7964.947ddfd010de73c2736b84d475f78b8f2baec83762b24c334831eb63f8032ba2.Q4JHbB9ginZ6v1gyfZTpNlxy0b-G_Sb1jAG8o8Mezus
layout-products-and-files--products-closed--dark:
- hash: v1.k794b7964.211928d26337d64731be096bf69cf0b6a1bb899b00476b6b40ba60789d5112ef.3zaMMKbB-TlMj_RS8YPPQOBER163qlJUO0-EhvcJZF8
+ hash: v1.k794b7964.e85de62e8963cd09a426eccf80b29c48895c8a7d3282d49a681790e4ed6a6bd3.VTn7MBrgYHbWtdIfpwXDiL66JHRpOgJzBy9JSWW5dEU
layout-products-and-files--products-closed--light:
- hash: v1.k794b7964.b38322b77a975fbe926d1ec970b8bc5e3ef38711fba922838f53c033e4761053.hw6lP2EV8nsvS-dD6X5Hw9gd5nz8sDOCsv_R0HI53Dc
+ hash: v1.k794b7964.8e25ba56fa6a01d6804a67f4c91be83e0d8fe781e60342b978427e559589cd17.8V2uRhpACLQqe9kGb2-1SLakkaAtiZ3I21hlqruJv8o
layout-products-and-files--products-overlay--dark:
- hash: v1.k794b7964.da6496c7cfd403c026aee12764a52189d5a8eb7b1ce4b0d71a7427cb699e4976.GgF5-xvoL50umyYcCEVbybWuNHTN4z6hF10qJVXfMG0
+ hash: v1.k794b7964.809fcda7d7f0d8f28d5fd67a4829ef202da8648071b5a8c0ac68f1f61136b0a2.GmX4vYC7aiTNaOWt6Z3HT2Pf2T4GBS1EtWiY3KggKpE
layout-products-and-files--products-overlay--light:
- hash: v1.k794b7964.edb8703c375a21ee32415b3b687cb4f78be4cae9aab21cf965b0caf2073eddbe.DISGy0e7QXP7SOhNPVH0OvckrXbDRpIe3UVucAV1ovg
+ hash: v1.k794b7964.7950c5d4b23bb1a9452151473c9a8179af9ee9cf05c6c9a88dbbaf359570e2eb.C6IQTJ6_LRkFh9UabLT1PNKRRuFU195dGu7zsZ-wLjY
layout-products-and-files--products-starred-collapsed--dark:
- hash: v1.k794b7964.b84041e30d09e8a3124c311325fb3c8b6501b48f9d866ee14a36d5f60a3a8358.Zf0PDV_uCZMZIpllzTytwNsDwU5KU0-KRtIWB8V5tec
+ hash: v1.k794b7964.1fc283b24303c7212fb47de33a057c870667f8bd7a87458a2631e9bd35d725e7.5lEXAvKeG1QkrcebQhB0ixmIXgAaenxw0WCMttrhN9s
layout-products-and-files--products-starred-collapsed--light:
- hash: v1.k794b7964.43b0e70b7586c67c26f8387f4890492ef50265d45e9c110002fd46e8734b87e5.hqUcEnApmleUzzbspQIGusCl6_YI8nf0diyr2kK8lSk
+ hash: v1.k794b7964.44533a12c58c83a253be3424bd24a6eae261feec47d3411bd896ac21cf584525.8lDvM03JlIuE1ki0q3wpcBen63AqJnQiiGqmFu87yk4
layout-products-and-files--search--dark:
- hash: v1.k794b7964.1f52d7316737db0140daaabcb222df4aa9734bec57db313f0c904491fa9704bb.NKQ14VoLKhYTSzXwueJtC8fZcrek5TVdLt9N9kw5WMM
+ hash: v1.k794b7964.6695fe610e3f2c6defc39393d92d7075ee02c494f49c840a6aacb90f521bfe1f.6pIULWHpgkRwZOKuJOF4mNBxJlVemTXRwX0f-wbvnXI
layout-products-and-files--search--light:
- hash: v1.k794b7964.2e14d960e523a1f0b9394a4771433a5873d2c7027257f987f8035c68b1fc7e09.2ygAVM1lRvUnx_e7PuE_MDXv9fB47RXx6LqBijHwpTc
+ hash: v1.k794b7964.2f1fc9d1cd3b0c4141c564ba244b0cf17599ff92a95fbea4937f5a7c05fd5040.hwD6HSMsaa7NWobGJRS5hjX89po3O5KU10hOKbE-Zbs
layout-products-and-files--starred-setup--dark:
hash: v1.k794b7964.4b84c0b4ad1ed54202d5186e8a397d49c242e244569d00309fee244f0b3a74e6.bRdajXCYxVPeEO9YAfyqIZ51JIaSdrgOLPCE6th6Sro
layout-products-and-files--starred-setup--light:
diff --git a/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx b/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx
index e2323f4b37c7..d64e01596557 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx
@@ -5,7 +5,7 @@ import { ReactNode, RefObject, useEffect, useRef, useState } from 'react'
import {
IconCheckbox,
- IconChevronRight,
+ IconChevronDown,
IconEllipsis,
IconFolderPlus,
IconHome,
@@ -40,6 +40,7 @@ import { FileSystemEntry } from '~/queries/schema/schema-general'
import { UserBasicType } from '~/types'
import { PanelLayoutPanel } from '../PanelLayoutPanel'
+import { getSidebarProduct } from './defaultTree'
import { isHomeFolder, withHomeFolderEmptyState } from './homeFolderUtils'
import { MenuItems } from './menus/MenuItems'
import { projectTreeLogic } from './projectTreeLogic'
@@ -48,6 +49,13 @@ import { TreeSearchField } from './TreeSearchField'
import { TreeSortMenuItems } from './TreeSortMenuItems'
import { calculateMovePath, isProjectTreeItemActive, resolveProjectTreeDrop } from './utils'
+// Product menus that open on a create action or a picker show a matching hint instead of the ellipsis
+const PRODUCT_MENU_BUTTON_ICONS: Record<string, JSX.Element> = {
+ 'Product analytics': <IconPlusSmall className="text-tertiary" />,
+ Dashboards: <IconPlusSmall className="text-tertiary" />,
+ 'Session replay': <IconChevronDown className="text-tertiary" />,
+}
+
interface ProjectTreeBaseProps {
layout?: 'panel' | 'inline'
beforeTree?: ReactNode
@@ -447,22 +455,20 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {
const showDropdownMenu =
root === 'products://' ||
root === 'custom-products://' ||
- (root === 'shortcuts://' && item.record?.href && item.record.href.split('/').length - 1 === 1)
-
- if (showDropdownMenu) {
- if (item.name === 'Product analytics') {
- return (
- <ButtonPrimitive iconOnly isSideActionRight className="z-2 -outline-offset-2">
- <IconPlusSmall className="text-tertiary" />
- </ButtonPrimitive>
- )
- } else if (item.name === 'Dashboards' || item.name === 'Session replay') {
- return (
- <ButtonPrimitive iconOnly isSideActionRight className="z-2 -outline-offset-2">
- <IconChevronRight className="size-3 text-tertiary rotate-90" />
- </ButtonPrimitive>
- )
- }
+ (root === 'shortcuts://' && !!getSidebarProduct(item.record?.href))
+
+ const menuButtonIcon = showDropdownMenu ? PRODUCT_MENU_BUTTON_ICONS[item.name] : undefined
+ if (menuButtonIcon) {
+ return (
+ <ButtonPrimitive
+ iconOnly
+ isSideActionRight
+ className="z-2 -outline-offset-2"
+ data-attr={`menu-item-${item.name.toLowerCase().replace(/\s+/g, '-')}-menu-button`}
+ >
+ {menuButtonIcon}
+ </ButtonPrimitive>
+ )
}
}}
emptySpaceContextMenu={() => {
diff --git a/frontend/src/layout/panel-layout/ProjectTree/menus/DashboardsMenuItems.tsx b/frontend/src/layout/panel-layout/ProjectTree/menus/DashboardsMenuItems.tsx
index 832580e1564e..eaeebd686afd 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/menus/DashboardsMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/menus/DashboardsMenuItems.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { IconChevronRight } from '@posthog/icons'
+import { IconChevronRight, IconPlusSmall } from '@posthog/icons'
import { Link } from 'lib/lemon-ui/Link'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
@@ -26,11 +26,30 @@ export function DashboardsMenuItems({
MenuGroup = DropdownMenuGroup,
onLinkClick,
}: CustomMenuProps): JSX.Element {
- const { pinnedDashboards, dashboardsLoading } = useValues(dashboardsModel)
+ const { pinnedDashboards, dashboardsLoading, loadDashboardsFailed } = useValues(dashboardsModel)
const { loadDashboardsIfNeeded } = useActions(dashboardsModel)
return (
<>
+ <MenuItem
+ asChild
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ onLinkClick?.(true)
+ }
+ }}
+ >
+ {/* The dashboards scene reads the hash when it mounts, so the modal opens from any page */}
+ <Link
+ buttonProps={{ menuItem: true }}
+ to={`${urls.dashboards()}#newDashboard=modal`}
+ onClick={() => onLinkClick?.(false)}
+ data-attr="tree-item-menu-new-dashboard"
+ >
+ <IconPlusSmall />
+ New dashboard
+ </Link>
+ </MenuItem>
<MenuSub
onOpenChange={(open) => {
if (open) {
@@ -39,15 +58,21 @@ export function DashboardsMenuItems({
}}
>
<MenuSubTrigger asChild>
- <ButtonPrimitive menuItem>
+ <ButtonPrimitive menuItem data-attr="tree-item-menu-pinned-dashboards">
Pinned dashboards
<IconChevronRight className="ml-auto size-3" />
</ButtonPrimitive>
</MenuSubTrigger>
- <MenuSubContent>
+ {/* Matches the parent menu's width, so long dashboard names truncate instead of widening it */}
+ <MenuSubContent className="max-w-[250px]">
<MenuGroup>
- {dashboardsLoading ? (
+ {/* A failed load leaves dashboardsLoading true for good, so it has to be read first */}
+ {loadDashboardsFailed ? (
+ <MenuItem disabled>
+ <ButtonPrimitive menuItem>Couldn't load dashboards</ButtonPrimitive>
+ </MenuItem>
+ ) : dashboardsLoading ? (
<MenuItem disabled>
<ButtonPrimitive menuItem>Loading...</ButtonPrimitive>
</MenuItem>
@@ -60,6 +85,7 @@ export function DashboardsMenuItems({
}}
to={urls.dashboard(dashboard.id)}
tooltip={dashboard.name}
+ data-attr="tree-item-menu-pinned-dashboard"
tooltipPlacement="right"
onClick={(e) => {
e.stopPropagation()
diff --git a/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx b/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx
index b204b29ae795..fe86a0cf61e8 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx
@@ -45,6 +45,7 @@ import { FileSystemEntry } from '~/queries/schema/schema-general'
import { NewMenu } from '../../menus/NewMenu'
import { panelLayoutLogic } from '../../panelLayoutLogic'
import { customProductsLogic } from '../customProductsLogic'
+import { getSidebarProduct } from '../defaultTree'
import { projectTreeDataLogic } from '../projectTreeDataLogic'
import { projectTreeLogic } from '../projectTreeLogic'
import { joinPath, splitPath } from '../utils'
@@ -117,11 +118,11 @@ export function MenuItems({
const showSelectMenuItems =
root === 'project://' && item.record?.path && !item.disableSelect && !onlyTree && showSelectMenuOption
- // Show product menu items if the item is a product or shortcut (and the item is a product, products have 1 slash in the href)
+ // Show product menu items if the item is a product, or a starred link to one
const showProductMenuItems =
root === 'products://' ||
root === 'custom-products://' ||
- (root === 'shortcuts://' && item.record?.href && item.record.href.split('/').length - 1 === 1)
+ (root === 'shortcuts://' && !!getSidebarProduct(item.record?.href))
// Note: renderMenuItems() is called often, so we're using custom components to isolate logic and network requests
const productMenu =
diff --git a/frontend/src/layout/panel-layout/ProjectTree/menus/ProductAnalyticsMenuItems.tsx b/frontend/src/layout/panel-layout/ProjectTree/menus/ProductAnalyticsMenuItems.tsx
index 2ace6b4f9a78..5a258e28c8b0 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/menus/ProductAnalyticsMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/menus/ProductAnalyticsMenuItems.tsx
@@ -36,6 +36,7 @@ export function ProductAnalyticsMenuItems({ MenuItem = DropdownMenuItem, onLinkC
>
<Link
to={child.record?.href}
+ data-attr="tree-item-menu-new-insight"
buttonProps={{ menuItem: true }}
onClick={() => {
onLinkClick?.(false)
diff --git a/frontend/src/layout/panel-layout/ProjectTree/menus/SessionReplayMenuItems.tsx b/frontend/src/layout/panel-layout/ProjectTree/menus/SessionReplayMenuItems.tsx
index 91b94604fc36..d566b973e379 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/menus/SessionReplayMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/menus/SessionReplayMenuItems.tsx
@@ -31,9 +31,10 @@ export function SessionReplayMenuItems({
MenuSeparator = DropdownMenuSeparator,
onLinkClick,
}: CustomMenuProps): JSX.Element {
- const { savedFilters, savedFiltersLoading } = useValues(sessionRecordingSavedFiltersLogic)
- const { loadSavedFiltersIfNeeded } = useActions(sessionRecordingSavedFiltersLogic)
- const { playlists, playlistsLoading } = useValues(sessionRecordingCollectionsLogic)
+ const { savedFilters, savedFiltersLoading, loadSavedFiltersFailed } = useValues(sessionRecordingSavedFiltersLogic)
+ const { loadSavedFiltersIfNeeded, loadSavedFilters } = useActions(sessionRecordingSavedFiltersLogic)
+ const { playlists, playlistsLoading, loadPlaylistsFailed } = useValues(sessionRecordingCollectionsLogic)
+ const { loadPlaylists } = useActions(sessionRecordingCollectionsLogic)
function handleKeyDown(e: React.KeyboardEvent<HTMLElement>): void {
if (e.key === 'Enter' || e.key === ' ') {
@@ -48,12 +49,16 @@ export function SessionReplayMenuItems({
<MenuSub
onOpenChange={(open) => {
if (open) {
- loadSavedFiltersIfNeeded()
+ if (loadSavedFiltersFailed) {
+ loadSavedFilters()
+ } else {
+ loadSavedFiltersIfNeeded()
+ }
}
}}
>
<MenuSubTrigger asChild>
- <ButtonPrimitive menuItem>
+ <ButtonPrimitive menuItem data-attr="tree-item-menu-saved-filters">
Saved filters
<IconChevronRight className="ml-auto size-3" />
</ButtonPrimitive>
@@ -65,8 +70,13 @@ export function SessionReplayMenuItems({
<MenuItem disabled>
<LemonSkeleton className="h-4 w-32" repeat={3} />
</MenuItem>
+ ) : loadSavedFiltersFailed ? (
+ <MenuItem disabled>
+ <ButtonPrimitive menuItem>Couldn't load saved filters</ButtonPrimitive>
+ </MenuItem>
) : null}
{!savedFiltersLoading &&
+ !loadSavedFiltersFailed &&
savedFilters.results.map((savedFilter) => (
<MenuItem asChild key={savedFilter.short_id}>
<Link
@@ -79,6 +89,7 @@ export function SessionReplayMenuItems({
}).url
)}
tooltip={savedFilter.name || savedFilter.derived_name || 'Unnamed'}
+ data-attr="tree-item-menu-saved-filter"
tooltipPlacement="right"
onKeyDown={handleKeyDown}
onClick={() => onLinkClick?.(false)}
@@ -89,15 +100,16 @@ export function SessionReplayMenuItems({
</Link>
</MenuItem>
))}
- {!savedFiltersLoading && savedFilters.next ? (
+ {!savedFiltersLoading ? (
<>
- <MenuSeparator />
+ {savedFilters.results.length > 0 && !loadSavedFiltersFailed && <MenuSeparator />}
<MenuItem asChild key="all-saved-filters">
<Link
buttonProps={{
menuItem: true,
}}
to={`${urls.replay(ReplayTabs.Home)}?showFilters=true&filtersTab=saved`}
+ data-attr="tree-item-menu-all-saved-filters"
onKeyDown={handleKeyDown}
onClick={() => onLinkClick?.(false)}
>
@@ -110,22 +122,32 @@ export function SessionReplayMenuItems({
</MenuSubContent>
</MenuSub>
- {playlistsLoading ? (
- <MenuItem disabled>
- <ButtonPrimitive menuItem>Loading...</ButtonPrimitive>
- </MenuItem>
- ) : playlists.count > 0 ? (
- <MenuSub>
- <MenuSubTrigger asChild>
- <ButtonPrimitive menuItem>
- Collections
- <IconChevronRight className="ml-auto size-3" />
- </ButtonPrimitive>
- </MenuSubTrigger>
+ <MenuSub
+ onOpenChange={(open) => {
+ if (open && loadPlaylistsFailed && !playlistsLoading) {
+ loadPlaylists()
+ }
+ }}
+ >
+ <MenuSubTrigger asChild>
+ <ButtonPrimitive menuItem data-attr="tree-item-menu-collections">
+ Collections
+ <IconChevronRight className="ml-auto size-3" />
+ </ButtonPrimitive>
+ </MenuSubTrigger>
- <MenuSubContent>
- <MenuGroup>
- {playlists.results.map((playlist) => (
+ <MenuSubContent>
+ <MenuGroup>
+ {playlistsLoading ? (
+ <MenuItem disabled>
+ <LemonSkeleton className="h-4 w-32" repeat={3} />
+ </MenuItem>
+ ) : loadPlaylistsFailed ? (
+ <MenuItem disabled>
+ <ButtonPrimitive menuItem>Couldn't load collections</ButtonPrimitive>
+ </MenuItem>
+ ) : (
+ playlists.results.map((playlist) => (
<MenuItem asChild key={playlist.short_id}>
<Link
buttonProps={{
@@ -133,6 +155,7 @@ export function SessionReplayMenuItems({
}}
to={urls.replayPlaylist(playlist.short_id)}
tooltip={playlist.name || playlist.derived_name || 'Unnamed'}
+ data-attr="tree-item-menu-collection"
tooltipPlacement="right"
onKeyDown={handleKeyDown}
onClick={() => onLinkClick?.(false)}
@@ -142,28 +165,29 @@ export function SessionReplayMenuItems({
</span>
</Link>
</MenuItem>
- ))}
- {playlists.next ? (
- <>
- <DropdownMenuSeparator />
- <MenuItem asChild key="all-collections">
- <Link
- buttonProps={{
- menuItem: true,
- }}
- to={`${urls.replay(ReplayTabs.Playlists)}`}
- onKeyDown={handleKeyDown}
- onClick={() => onLinkClick?.(false)}
- >
- <span className="truncate">All collections</span>
- </Link>
- </MenuItem>
- </>
- ) : null}
- </MenuGroup>
- </MenuSubContent>
- </MenuSub>
- ) : null}
+ ))
+ )}
+ {!playlistsLoading ? (
+ <>
+ {playlists.results.length > 0 && !loadPlaylistsFailed && <MenuSeparator />}
+ <MenuItem asChild key="all-collections">
+ <Link
+ buttonProps={{
+ menuItem: true,
+ }}
+ to={urls.replay(ReplayTabs.Playlists)}
+ data-attr="tree-item-menu-all-collections"
+ onKeyDown={handleKeyDown}
+ onClick={() => onLinkClick?.(false)}
+ >
+ <span className="truncate">All collections</span>
+ </Link>
+ </MenuItem>
+ </>
+ ) : null}
+ </MenuGroup>
+ </MenuSubContent>
+ </MenuSub>
<MenuItem asChild>
<Link
@@ -171,6 +195,7 @@ export function SessionReplayMenuItems({
menuItem: true,
}}
to={urls.replay(ReplayTabs.Home)}
+ data-attr="tree-item-menu-all-recordings"
onKeyDown={handleKeyDown}
onClick={() => onLinkClick?.(false)}
>
diff --git a/frontend/src/layout/panel-layout/navbar/NavBar.tsx b/frontend/src/layout/panel-layout/navbar/NavBar.tsx
index 5a9dc8e77366..3800243ba904 100644
--- a/frontend/src/layout/panel-layout/navbar/NavBar.tsx
+++ b/frontend/src/layout/panel-layout/navbar/NavBar.tsx
@@ -39,6 +39,7 @@ import { PostHogTeamCohortBanner } from './PostHogTeamCohortBanner'
import { postHogTeamCohortBannerLogic } from './postHogTeamCohortBannerLogic'
import { FlatNavBrowse } from './tabs/flat-nav/FlatNavBrowse'
import { navProductsTabLogic } from './tabs/navProductsTabLogic'
+import { NavStarredProductsTree } from './tabs/NavStarredProductsTree'
import { NavTabBrowse } from './tabs/NavTabBrowse'
import { NavTabFiles } from './tabs/NavTabFiles'
import { NavTabProducts } from './tabs/NavTabProducts'
@@ -324,7 +325,10 @@ export function NavBar(): JSX.Element {
{...props}
className={cn(
'group gap-1 data-[composite-item-active]:bg-surface-tertiary justify-center',
- isSimpleSidepanelEnabled ? 'flex-1 min-w-0' : 'w-1/2'
+ // In the vertical collapsed list, flex-1 would override the button height
+ !isSimpleSidepanelEnabled
+ ? 'w-1/2'
+ : !isLayoutNavCollapsed && 'flex-1 min-w-0'
)}
iconOnly={isSimpleSidepanelEnabled && isLayoutNavCollapsed}
tooltip={isSimpleSidepanelEnabled ? tab.label : undefined}
@@ -368,9 +372,14 @@ export function NavBar(): JSX.Element {
<div
className={cn(
'flex-1 overflow-hidden relative',
- isSimpleSidepanelEnabled && isLayoutNavCollapsed && '[&>*]:hidden'
+ isSimpleSidepanelEnabled && isLayoutNavCollapsed && '[&>[role=tabpanel]]:hidden'
)}
>
+ {isSimpleSidepanelEnabled && isLayoutNavCollapsed && (
+ <div className="absolute inset-0 flex flex-col items-center group/colorful-product-icons colorful-product-icons-true">
+ <NavStarredProductsTree treeSize="narrow" />
+ </div>
+ )}
<Tabs.Panel value="home" className="absolute inset-0 flex flex-col" keepMounted tabIndex={-1}>
{isSimpleSidepanelEnabled ? (
<NavTabProducts />
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavProductMenu.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavProductMenu.tsx
deleted file mode 100644
index ea7559b677f0..000000000000
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavProductMenu.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
-import { LemonMenuItems, LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu'
-import { sessionRecordingCollectionsLogic } from 'scenes/session-recordings/collections/sessionRecordingCollectionsLogic'
-import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'
-import { urls } from 'scenes/urls'
-
-import { dashboardsModel } from '~/models/dashboardsModel'
-import { ReplayTabs } from '~/types'
-
-import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
-
-export function NavProductMenu({ product }: { product: string }): JSX.Element {
- const { treeItemsNew } = useValues(projectTreeDataLogic)
- const { pinnedDashboards, dashboardsLoading, loadDashboardsFailed } = useValues(dashboardsModel)
- const { loadDashboardsIfNeeded, loadDashboards } = useActions(dashboardsModel)
- const { savedFilters, savedFiltersLoading, loadSavedFiltersFailed } = useValues(sessionRecordingSavedFiltersLogic)
- const { loadSavedFilters } = useActions(sessionRecordingSavedFiltersLogic)
- const { playlists, playlistsLoading, loadPlaylistsFailed } = useValues(sessionRecordingCollectionsLogic)
- const { loadPlaylists } = useActions(sessionRecordingCollectionsLogic)
-
- let items: LemonMenuItems
- if (product === 'Product analytics') {
- items = [
- {
- title: 'Create new insight type',
- items: [...(treeItemsNew.find(({ name }) => name === 'Insight')?.children ?? [])]
- .sort((a, b) => (a.visualOrder ?? 0) - (b.visualOrder ?? 0))
- .map((item) => ({ label: item.name, icon: <>{item.icon}</>, to: item.record?.href })),
- },
- ]
- } else if (product === 'Dashboards') {
- items = [
- {
- title: 'Pinned dashboards',
- items: loadDashboardsFailed
- ? [
- {
- label: 'Could not load dashboards. Reopen this menu to retry.',
- disabledReason: 'Could not load dashboards',
- },
- ]
- : dashboardsLoading
- ? [{ label: 'Loading dashboards…', disabledReason: 'Loading' }]
- : pinnedDashboards.length
- ? pinnedDashboards.map((dashboard) => ({
- label: dashboard.name || 'Untitled dashboard',
- to: urls.dashboard(dashboard.id),
- }))
- : [{ label: 'No pinned dashboards', disabledReason: 'Pin a dashboard to show it here' }],
- },
- ]
- } else {
- items = [
- {
- label: 'Saved filters',
- items: [
- ...(savedFiltersLoading
- ? [{ label: 'Loading saved filters…', disabledReason: 'Loading' }]
- : loadSavedFiltersFailed
- ? [
- {
- label: 'Could not load saved filters. Reopen this menu to retry.',
- disabledReason: 'Could not load saved filters',
- },
- ]
- : savedFilters.results.map((filter) => ({
- label: filter.name || filter.derived_name || 'Unnamed',
- // Replay reads savedFilterId on mount, so a full navigation applies it even from Replay home.
- to: urls.absolute(
- combineUrl(urls.replay(ReplayTabs.Home), { savedFilterId: filter.short_id }).url
- ),
- disableClientSideRouting: true,
- }))),
- {
- label: 'All saved filters',
- to: `${urls.replay(ReplayTabs.Home)}?showFilters=true&filtersTab=saved`,
- },
- ],
- },
- {
- label: 'Collections',
- items: [
- ...(playlistsLoading
- ? [{ label: 'Loading collections…', disabledReason: 'Loading' }]
- : loadPlaylistsFailed
- ? [
- {
- label: 'Could not load collections. Reopen this menu to retry.',
- disabledReason: 'Could not load collections',
- },
- ]
- : playlists.results.map((playlist) => ({
- label: playlist.name || playlist.derived_name || 'Unnamed',
- to: urls.replayPlaylist(playlist.short_id),
- }))),
- { label: 'All collections', to: urls.replay(ReplayTabs.Playlists) },
- ],
- },
- { label: 'All recordings', to: urls.replay(ReplayTabs.Home) },
- ]
- }
-
- useOnMountEffect(() => {
- if (product === 'Dashboards') {
- if (loadDashboardsFailed) {
- loadDashboards()
- } else {
- loadDashboardsIfNeeded()
- }
- } else if (product === 'Session replay') {
- if (!savedFiltersLoading) {
- loadSavedFilters()
- }
- if (!playlistsLoading && loadPlaylistsFailed) {
- loadPlaylists()
- }
- }
- })
-
- return <LemonMenuOverlay items={items} />
-}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavProductRow.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavProductRow.tsx
index 86e2f90cfd87..b75ee7f0f981 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavProductRow.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavProductRow.tsx
@@ -1,9 +1,8 @@
import { useActions, useValues } from 'kea'
-import { IconChevronDown, IconGear, IconPlusSmall, IconStar, IconStarFilled } from '@posthog/icons'
-import { LemonButton, LemonDialog, LemonMenu } from '@posthog/lemon-ui'
+import { IconGear, IconStar, IconStarFilled } from '@posthog/icons'
+import { LemonButton, LemonDialog } from '@posthog/lemon-ui'
-import { LemonMenuItems } from 'lib/lemon-ui/LemonMenu'
import { Link } from 'lib/lemon-ui/Link'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
@@ -19,7 +18,6 @@ import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
import { findProductShortcut } from '../../ProjectTree/utils'
import { sidebarProductMeta } from '../../sidebarProductMeta'
import { NavProductIcon } from './NavProductIcon'
-import { NavProductMenu } from './NavProductMenu'
import { navProductsTabLogic } from './navProductsTabLogic'
import { NavProductTooltip } from './NavProductTooltip'
import { productsItemName } from './productsCatalog'
@@ -43,7 +41,6 @@ export function NavProductRow({ item, pinned = false }: { item: FileSystemImport
const disabledReason = getProductAccessDisabledReason(item)
const isHome = item.path === 'Home'
- const hasProductMenu = ['Product analytics', 'Dashboards', 'Session replay'].includes(item.path)
const hasSideAction = isHome || !pinned
const starAction = {
label: shortcut ? 'Remove from starred' : 'Add to starred',
@@ -69,18 +66,17 @@ export function NavProductRow({ item, pinned = false }: { item: FileSystemImport
})
},
}
- const menuItems: LemonMenuItems = [{ label: () => <NavProductMenu product={item.path} /> }, { items: [starAction] }]
// Appears at once like a tree row's side action, while keeping LemonButton's press animation.
const sideActionClassName =
'absolute right-0 opacity-0 group-hover/product-row:opacity-100 group-has-[:focus-visible]/product-row:opacity-100 [--lemon-button-transition:transform_200ms_ease]'
return (
- <div className="group/product-row relative flex items-center gap-px min-w-0">
- <Tooltip
- title={disabledReason || <NavProductTooltip item={item} />}
- docLink={disabledReason ? undefined : sidebarProductMeta(item).docsHref}
- placement="right"
- >
+ <Tooltip
+ title={disabledReason || <NavProductTooltip item={item} />}
+ docLink={disabledReason ? undefined : sidebarProductMeta(item).docsHref}
+ placement="right"
+ >
+ <div className="group/product-row relative flex items-center gap-px min-w-0">
<Link
to={disabledReason ? undefined : href}
disabledReason={disabledReason}
@@ -91,7 +87,7 @@ export function NavProductRow({ item, pinned = false }: { item: FileSystemImport
className: cn(
'flex-1 min-w-0 -outline-offset-2 motion-safe:transition-[padding] duration-50',
hasSideAction && 'group-hover/product-row:pr-7 group-has-[:focus-visible]/product-row:pr-7',
- !pinned && !hasProductMenu && shortcut && 'pr-7'
+ !pinned && shortcut && 'pr-7'
),
}}
data-attr="nav-apps-item"
@@ -105,47 +101,28 @@ export function NavProductRow({ item, pinned = false }: { item: FileSystemImport
</span>
<span className="flex-1 truncate">{label}</span>
</Link>
- </Tooltip>
- {isHome ? (
- <LemonButton
- size="xsmall"
- className={sideActionClassName}
- icon={<IconGear />}
- tooltip="Customize sidebar"
- aria-label="Customize sidebar"
- onClick={() => setCustomizeSidebarOpen(true)}
- data-attr="nav-customize-sidebar"
- />
- ) : pinned ? null : hasProductMenu ? (
- <LemonMenu placement="right-start" items={menuItems}>
+ {isHome ? (
<LemonButton
size="xsmall"
className={sideActionClassName}
- icon={item.path === 'Product analytics' ? <IconPlusSmall /> : <IconChevronDown />}
- tooltip={`Open ${label} menu`}
- aria-label={`Open ${label} menu`}
- disabledReason={disabledReason}
- data-attr={
- item.path === 'Product analytics'
- ? 'flat-nav-tool-menu-insight'
- : item.path === 'Dashboards'
- ? 'flat-nav-tool-menu-dashboards'
- : 'flat-nav-tool-menu-session-replay'
- }
+ icon={<IconGear />}
+ tooltip="Customize sidebar"
+ aria-label="Customize sidebar"
+ onClick={() => setCustomizeSidebarOpen(true)}
+ data-attr="nav-customize-sidebar"
/>
- </LemonMenu>
- ) : (
- <LemonButton
- size="xsmall"
- className={cn(sideActionClassName, shortcut && 'opacity-100')}
- icon={starAction.icon}
- tooltip={starAction.label}
- aria-label={starAction.label}
- disabledReason={starAction.disabledReason}
- onClick={starAction.onClick}
- data-attr={starAction['data-attr']}
- />
- )}
- </div>
+ ) : pinned ? null : (
+ <LemonButton
+ size="xsmall"
+ className={cn(sideActionClassName, shortcut && 'opacity-100')}
+ icon={starAction.icon}
+ aria-label={starAction.label}
+ disabledReason={starAction.disabledReason}
+ onClick={starAction.onClick}
+ data-attr={starAction['data-attr']}
+ />
+ )}
+ </div>
+ </Tooltip>
)
}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavStarredProductsTree.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavStarredProductsTree.tsx
new file mode 100644
index 000000000000..ae3153b98775
--- /dev/null
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavStarredProductsTree.tsx
@@ -0,0 +1,28 @@
+import { LemonTreeSize } from 'lib/lemon-ui/LemonTree/LemonTree'
+
+import { getSidebarProduct } from '../../ProjectTree/defaultTree'
+import { ProjectTree } from '../../ProjectTree/ProjectTree'
+import { sidebarProductMeta } from '../../sidebarProductMeta'
+import { PRODUCTS_STARRED_TREE_KEY } from './navProductsTabLogic'
+import { NavProductTooltip } from './NavProductTooltip'
+
+export function NavStarredProductsTree({ treeSize = 'default' }: { treeSize?: LemonTreeSize }): JSX.Element {
+ return (
+ <ProjectTree
+ root="shortcuts://"
+ shortcutScope="products"
+ logicKey={PRODUCTS_STARRED_TREE_KEY}
+ onlyTree
+ showShortcutHelp={false}
+ treeSize={treeSize}
+ renderItemTooltip={(treeItem) => {
+ const product = getSidebarProduct(treeItem.record?.href)
+ return product ? <NavProductTooltip item={product} /> : undefined
+ }}
+ renderItemTooltipDocLink={(treeItem) => {
+ const product = getSidebarProduct(treeItem.record?.href)
+ return product ? sidebarProductMeta(product).docsHref : undefined
+ }}
+ />
+ )
+}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabProducts.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavTabProducts.tsx
index 29e3266d27e3..99edb0dc3148 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavTabProducts.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabProducts.tsx
@@ -5,15 +5,12 @@ import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableSh
import { Collapsible } from 'lib/ui/Collapsible/Collapsible'
import { cn } from 'lib/utils/css-classes'
-import { getSidebarProduct } from '../../ProjectTree/defaultTree'
-import { ProjectTree } from '../../ProjectTree/ProjectTree'
import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'
-import { sidebarProductMeta } from '../../sidebarProductMeta'
import { CustomizeSidebarModal } from './CustomizeSidebarModal'
import { NavProductRow } from './NavProductRow'
import { PRODUCTS_STARRED_TREE_KEY, navProductsTabLogic } from './navProductsTabLogic'
-import { NavProductTooltip } from './NavProductTooltip'
+import { NavStarredProductsTree } from './NavStarredProductsTree'
import { NavTabSection } from './NavTabSection'
export function NavTabProducts(): JSX.Element {
@@ -33,10 +30,12 @@ export function NavTabProducts(): JSX.Element {
<div className="flex flex-col h-full min-h-0 group/colorful-product-icons colorful-product-icons-true">
{/* Parents own the spacing: this gap separates the sections, and each section's gap separates
its title from its rows. Titles and rows carry no vertical padding or margin. */}
+ {/* The stable gutter keeps the scrollbar's space when it is hidden, so the section chevrons do not
+ shift when expanding All products adds a scrollbar */}
<ScrollableShadows
direction="vertical"
className="flex-1 min-h-0"
- innerClassName="px-1 pb-2"
+ innerClassName="px-1 pb-2 [scrollbar-gutter:stable]"
contentClassName="flex flex-col gap-3"
styledScrollbars
>
@@ -57,21 +56,7 @@ export function NavTabProducts(): JSX.Element {
{/* The tree insets its rows by 5px and pads itself by 4px vertically. This lines its
icons up with the rows above and cancels its own vertical padding. */}
<div className="-ml-[5px] -my-1">
- <ProjectTree
- root="shortcuts://"
- shortcutScope="products"
- logicKey={PRODUCTS_STARRED_TREE_KEY}
- onlyTree
- showShortcutHelp={false}
- renderItemTooltip={(treeItem) => {
- const product = getSidebarProduct(treeItem.record?.href)
- return product ? <NavProductTooltip item={product} /> : undefined
- }}
- renderItemTooltipDocLink={(treeItem) => {
- const product = getSidebarProduct(treeItem.record?.href)
- return product ? sidebarProductMeta(product).docsHref : undefined
- }}
- />
+ <NavStarredProductsTree />
</div>
</NavTabSection>
</section>
@@ -92,8 +77,8 @@ export function NavTabProducts(): JSX.Element {
>
{allProductsCollapsible && (
<Collapsible.Trigger
- className="min-h-6 py-0.5 rounded hover:bg-fill-button-tertiary-hover focus-visible:bg-fill-button-tertiary-hover pr-2"
- labelClassName="flex-1 text-xs font-semibold text-tertiary normal-case tracking-normal"
+ className="min-h-7 rounded hover:bg-fill-button-tertiary-hover focus-visible:bg-fill-button-tertiary-hover pr-2"
+ labelClassName="flex-1 text-xs font-semibold text-secondary normal-case"
data-attr="nav-apps-project-toggle"
>
{allProductsVisible ? 'All products' : 'See all products'}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx
index b90f692e9757..9ddeaa199007 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx
@@ -1,6 +1,10 @@
import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
-import { render, waitFor } from '@testing-library/react'
+import { fireEvent, render, waitFor } from '@testing-library/react'
+import { router } from 'kea-router'
+
+import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'
+import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { UserProductListItem } from '~/queries/schema/schema-general'
@@ -77,4 +81,18 @@ describe('FlatNavProducts', () => {
expect(menuButton?.getAttribute('data-attr') ?? null).toBe(menuAttr)
})
})
+
+ // The dashboards list scene mounts only after the navigation, so the modal opens from the URL alone
+ it('opens the new dashboard modal from another page', async () => {
+ router.actions.push(urls.currentProject(urls.insights()))
+ const { container, findByText } = render(<FlatNavProducts />)
+
+ await waitFor(() => renderedProductRow(container, 'dashboards'))
+ fireEvent.click(container.querySelector('[data-attr="flat-nav-tool-menu-dashboards"]')!)
+ fireEvent.click(await findByText('New dashboard'))
+
+ expect(router.values.location.pathname).toBe(urls.currentProject(urls.dashboards()))
+ newDashboardLogic.mount()
+ expect(newDashboardLogic.values.newDashboardModalVisible).toBe(true)
+ })
})
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx
index 3f5d56e56e09..ba403a9dc83e 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx
@@ -30,8 +30,8 @@ const PRODUCT_MENUS: Record<string, JSX.Element> = {
),
Dashboards: (
<FlatNavProductMenu
- icon={<IconChevronDown />}
- tooltip="Pinned dashboards"
+ icon={<IconPlusSmall />}
+ tooltip="New dashboard and pinned dashboards"
data-attr="flat-nav-tool-menu-dashboards"
>
<FlatNavDashboardsMenuItems />
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavDashboardsMenuItems.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavDashboardsMenuItems.tsx
index 5ef9dd379f4b..13db69ec013c 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavDashboardsMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavDashboardsMenuItems.tsx
@@ -1,6 +1,7 @@
import { useActions, useValues } from 'kea'
-import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, Skeleton } from '@posthog/quill'
+import { IconPlusSmall } from '@posthog/icons'
+import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, Skeleton } from '@posthog/quill'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { urls } from 'scenes/urls'
@@ -8,6 +9,7 @@ import { urls } from 'scenes/urls'
import { dashboardsModel } from '~/models/dashboardsModel'
import { FlatNavMenuLinkItem } from './FlatNavMenuLinkItem'
+import { FlatNavProductLinkMenuItems } from './FlatNavProductLinkMenuItems'
export function FlatNavDashboardsMenuItems(): JSX.Element {
const { pinnedDashboards, dashboardsLoading, loadDashboardsFailed } = useValues(dashboardsModel)
@@ -18,22 +20,41 @@ export function FlatNavDashboardsMenuItems(): JSX.Element {
})
return (
- <DropdownMenuGroup>
- <DropdownMenuLabel>Pinned dashboards</DropdownMenuLabel>
- {/* A failed load leaves dashboardsLoading true for good, so it has to be read first */}
- {loadDashboardsFailed ? (
- <DropdownMenuItem disabled>Couldn't load dashboards</DropdownMenuItem>
- ) : dashboardsLoading ? (
- <Skeleton className="mx-2 my-1 h-4" />
- ) : pinnedDashboards.length === 0 ? (
- <DropdownMenuItem disabled>No pinned dashboards</DropdownMenuItem>
- ) : (
- pinnedDashboards.map((dashboard) => (
- <FlatNavMenuLinkItem key={dashboard.id} to={urls.dashboard(dashboard.id)}>
- {dashboard.name}
- </FlatNavMenuLinkItem>
- ))
- )}
- </DropdownMenuGroup>
+ <>
+ <DropdownMenuGroup>
+ {/* The same link search uses. The dashboards scene reads the hash when it mounts, so the modal opens from any page */}
+ <FlatNavMenuLinkItem
+ to={`${urls.dashboards()}#newDashboard=modal`}
+ icon={<IconPlusSmall />}
+ data-attr="flat-nav-dashboards-menu-new-dashboard"
+ >
+ New dashboard
+ </FlatNavMenuLinkItem>
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuGroup>
+ <DropdownMenuLabel>Pinned dashboards</DropdownMenuLabel>
+ {/* A failed load leaves dashboardsLoading true for good, so it has to be read first */}
+ {loadDashboardsFailed ? (
+ <DropdownMenuItem disabled>Couldn't load dashboards</DropdownMenuItem>
+ ) : dashboardsLoading ? (
+ <Skeleton className="mx-2 my-1 h-4" />
+ ) : pinnedDashboards.length === 0 ? (
+ <DropdownMenuItem disabled>No pinned dashboards</DropdownMenuItem>
+ ) : (
+ pinnedDashboards.map((dashboard) => (
+ <FlatNavMenuLinkItem
+ key={dashboard.id}
+ to={urls.dashboard(dashboard.id)}
+ data-attr="flat-nav-dashboards-menu-pinned-dashboard"
+ >
+ {dashboard.name}
+ </FlatNavMenuLinkItem>
+ ))
+ )}
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <FlatNavProductLinkMenuItems productPath="Dashboards" href={urls.dashboards()} />
+ </>
)
}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavMenuLinkItem.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavMenuLinkItem.tsx
index faf8eef4ac00..a13153113780 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavMenuLinkItem.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavMenuLinkItem.tsx
@@ -5,12 +5,18 @@ import { LinkPrimitive } from 'lib/lemon-ui/Link'
interface FlatNavMenuLinkItemProps {
to?: string
icon?: React.ReactNode
+ 'data-attr'?: string
children: React.ReactNode
}
-export function FlatNavMenuLinkItem({ to, icon, children }: FlatNavMenuLinkItemProps): JSX.Element {
+export function FlatNavMenuLinkItem({
+ to,
+ icon,
+ 'data-attr': dataAttr,
+ children,
+}: FlatNavMenuLinkItemProps): JSX.Element {
return (
- <DropdownMenuItem render={<Button size="row" left render={<LinkPrimitive to={to} />} />}>
+ <DropdownMenuItem render={<Button size="row" left render={<LinkPrimitive to={to} />} />} data-attr={dataAttr}>
{icon}
<span className="truncate">{children}</span>
</DropdownMenuItem>
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductAnalyticsMenuItems.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductAnalyticsMenuItems.tsx
index 31c992378681..16e89b4593d9 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductAnalyticsMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductAnalyticsMenuItems.tsx
@@ -20,7 +20,12 @@ export function FlatNavProductAnalyticsMenuItems(): JSX.Element {
<DropdownMenuItem disabled>No insight types available</DropdownMenuItem>
) : (
insightTypes.map((insightType) => (
- <FlatNavMenuLinkItem key={insightType.id} to={insightType.record?.href} icon={insightType.icon}>
+ <FlatNavMenuLinkItem
+ key={insightType.id}
+ to={insightType.record?.href}
+ icon={insightType.icon}
+ data-attr="flat-nav-insight-menu-new-insight"
+ >
{insightType.name}
</FlatNavMenuLinkItem>
))
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductLinkMenuItems.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductLinkMenuItems.tsx
new file mode 100644
index 000000000000..3fd8de87a4a7
--- /dev/null
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavProductLinkMenuItems.tsx
@@ -0,0 +1,42 @@
+import { useActions } from 'kea'
+
+import { DropdownMenuGroup, DropdownMenuItem } from '@posthog/quill'
+
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
+import { urls } from 'scenes/urls'
+
+import { customProductsLogic } from '~/layout/panel-layout/ProjectTree/customProductsLogic'
+
+interface FlatNavProductLinkMenuItemsProps {
+ productPath: string
+ href: string
+}
+
+/** The items every product row offers in the tree sidebar menu, for products that also have their own menu. */
+export function FlatNavProductLinkMenuItems({ productPath, href }: FlatNavProductLinkMenuItemsProps): JSX.Element {
+ const { setProductEnabled } = useActions(customProductsLogic)
+ const absoluteUrl = urls.absolute(urls.currentProject(href))
+
+ return (
+ <DropdownMenuGroup>
+ <DropdownMenuItem
+ onClick={() => window.open(absoluteUrl, '_blank')}
+ data-attr="flat-nav-menu-open-in-new-tab"
+ >
+ Open link in new browser tab
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => void copyToClipboard(absoluteUrl, 'link')}
+ data-attr="flat-nav-menu-copy-link"
+ >
+ Copy link address
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => setProductEnabled(productPath, false)}
+ data-attr="flat-nav-menu-remove-from-sidebar"
+ >
+ Remove from sidebar
+ </DropdownMenuItem>
+ </DropdownMenuGroup>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavSessionReplayMenuItems.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavSessionReplayMenuItems.tsx
index 782ddd61d22a..79e30f6f93ce 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavSessionReplayMenuItems.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/menus/FlatNavSessionReplayMenuItems.tsx
@@ -47,7 +47,9 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
}
}}
>
- <DropdownMenuSubTrigger>Saved filters</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger data-attr="flat-nav-session-replay-menu-saved-filters">
+ Saved filters
+ </DropdownMenuSubTrigger>
<DropdownMenuSubContent data-lemon-skin className="min-w-48">
{savedFiltersLoading ? (
<Skeleton className="mx-2 my-1 h-4 w-32" />
@@ -59,7 +61,11 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
)
) : (
savedFilters.results.map((savedFilter) => (
- <FlatNavMenuLinkItem key={savedFilter.short_id} to={savedFilterUrl(savedFilter.short_id)}>
+ <FlatNavMenuLinkItem
+ key={savedFilter.short_id}
+ to={savedFilterUrl(savedFilter.short_id)}
+ data-attr="flat-nav-session-replay-menu-saved-filter"
+ >
{savedFilter.name || savedFilter.derived_name || 'Unnamed'}
</FlatNavMenuLinkItem>
))
@@ -69,6 +75,7 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
<DropdownMenuSeparator />
<FlatNavMenuLinkItem
to={`${urls.replay(ReplayTabs.Home)}?showFilters=true&filtersTab=saved`}
+ data-attr="flat-nav-session-replay-menu-all-saved-filters"
>
All saved filters
</FlatNavMenuLinkItem>
@@ -85,7 +92,9 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
}
}}
>
- <DropdownMenuSubTrigger>Collections</DropdownMenuSubTrigger>
+ <DropdownMenuSubTrigger data-attr="flat-nav-session-replay-menu-collections">
+ Collections
+ </DropdownMenuSubTrigger>
<DropdownMenuSubContent data-lemon-skin className="min-w-48">
{playlistsLoading ? (
<Skeleton className="mx-2 my-1 h-4 w-32" />
@@ -100,6 +109,7 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
<FlatNavMenuLinkItem
key={playlist.short_id}
to={urls.replayPlaylist(playlist.short_id)}
+ data-attr="flat-nav-session-replay-menu-collection"
>
{playlist.name || playlist.derived_name || 'Unnamed'}
</FlatNavMenuLinkItem>
@@ -108,7 +118,10 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
{!playlistsLoading && playlists.next && (
<>
<DropdownMenuSeparator />
- <FlatNavMenuLinkItem to={urls.replay(ReplayTabs.Playlists)}>
+ <FlatNavMenuLinkItem
+ to={urls.replay(ReplayTabs.Playlists)}
+ data-attr="flat-nav-session-replay-menu-all-collections"
+ >
All collections
</FlatNavMenuLinkItem>
</>
@@ -117,7 +130,12 @@ export function FlatNavSessionReplayMenuItems(): JSX.Element {
</DropdownMenuSub>
) : null}
- <FlatNavMenuLinkItem to={urls.replay(ReplayTabs.Home)}>All recordings</FlatNavMenuLinkItem>
+ <FlatNavMenuLinkItem
+ to={urls.replay(ReplayTabs.Home)}
+ data-attr="flat-nav-session-replay-menu-all-recordings"
+ >
+ All recordings
+ </FlatNavMenuLinkItem>
</>
)
}
diff --git a/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx b/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx
index cc4023f3e5b9..6c81858d5693 100644
--- a/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx
+++ b/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx
@@ -333,6 +333,8 @@ const LemonTreeItemRow = forwardRef<HTMLDivElement, LemonTreeItemRowProps>(
}
const contextMenuContent = itemContextMenu?.(item)
+ const sideActionContent = !isEmptyFolder && size === 'default' ? itemSideAction?.(item) : undefined
+ const sideActionButton = sideActionContent !== undefined ? itemSideActionButton?.(item) : undefined
const linkEl = (
<Link
@@ -373,6 +375,8 @@ const LemonTreeItemRow = forwardRef<HTMLDivElement, LemonTreeItemRowProps>(
'rounded-l-[var(--radius)] justify-center [&_svg]:size-4': size === 'narrow',
'group-hover/lemon-tree-button-group:pr-[30px] group-has-data-[state=open]/lemon-tree-button-group:pr-[30px] group-has-focus-within/lemon-tree-button-group:pr-[30px]':
size !== 'narrow' && !isEmptyFolder,
+ // A custom side action button stays visible, so its space stays reserved
+ 'pr-[30px]': !!sideActionButton,
}
),
}}
@@ -488,8 +492,6 @@ const LemonTreeItemRow = forwardRef<HTMLDivElement, LemonTreeItemRowProps>(
)
}
- const sideActionContent = !isEmptyFolder && size === 'default' ? itemSideAction?.(item) : undefined
- const sideActionButton = sideActionContent !== undefined ? itemSideActionButton?.(item) : undefined
const sideAction =
sideActionContent !== undefined ? (
sideActionContent !== null ? (
@@ -499,6 +501,7 @@ const LemonTreeItemRow = forwardRef<HTMLDivElement, LemonTreeItemRowProps>(
<ButtonPrimitive
iconOnly
isSideActionRight
+ data-attr={`menu-item-${item.name.toLowerCase().replace(/\s+/g, '-')}-menu-button`}
className="
absolute right-0
opacity-0