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(dashboards): separate the empty dashboard build menu (#119827)

Matt Puac56811d266c8
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
index f96619a3d68d..51c2d46da286 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
@@ -82,7 +82,7 @@ describe('EmptyDashboardComponent', () => {
return { logic }
}
- async function openAddFirstChartDropdown(): Promise<void> {
+ async function openBuildItMyselfMenu(): Promise<void> {
await userEvent.click(document.querySelector('[data-attr="dashboard-add-dropdown"]')!)
}
@@ -102,13 +102,14 @@ describe('EmptyDashboardComponent', () => {
)
).toBeInTheDocument()
expect(screen.getByText('Add a chart')).toBeInTheDocument()
+ expect(screen.getByText('Build it myself')).toBeInTheDocument()
expect(screen.getByText('or View Web Analytics')).toBeInTheDocument()
expect(screen.getByText('What do you want to learn?')).toBeInTheDocument()
logic.unmount()
})
- it('opens the insight picker when Add your first chart is clicked', async () => {
+ it('opens the insight picker when Add a chart is clicked', async () => {
const { logic } = renderEmptyState()
await userEvent.click(document.querySelector('[data-attr="dashboard-add-graph-header"]')!)
@@ -130,7 +131,7 @@ describe('EmptyDashboardComponent', () => {
const pushSpy = jest.spyOn(router.actions, 'push')
const { logic } = renderEmptyState()
- await openAddFirstChartDropdown()
+ await openBuildItMyselfMenu()
await userEvent.click(screen.getByText('Widget'))
expect(pushSpy).toHaveBeenCalledWith(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS))
@@ -140,10 +141,10 @@ describe('EmptyDashboardComponent', () => {
logic.unmount()
})
- it('shows the shared dashboard add options in the Add your first chart dropdown', async () => {
+ it('shows the shared dashboard add options in the Build it myself menu', async () => {
const { logic } = renderEmptyState()
- await openAddFirstChartDropdown()
+ await openBuildItMyselfMenu()
expect(screen.getByText('Content')).toBeInTheDocument()
expect(screen.getByText('Charts')).toBeInTheDocument()
@@ -157,10 +158,10 @@ describe('EmptyDashboardComponent', () => {
logic.unmount()
})
- it('shows Widget in the Add your first chart dropdown when dashboard widgets flag is enabled', async () => {
+ it('shows Widget in the Build it myself menu when dashboard widgets flag is enabled', async () => {
const { logic } = renderEmptyState({ widgetsEnabled: true })
- await openAddFirstChartDropdown()
+ await openBuildItMyselfMenu()
expect(screen.getByText('Widget')).toBeInTheDocument()
expect(screen.getAllByText('NEW')).toHaveLength(2)
@@ -171,7 +172,7 @@ describe('EmptyDashboardComponent', () => {
it('opens the add widget modal when Widget is clicked', async () => {
const { logic } = renderEmptyState({ widgetsEnabled: true })
- await openAddFirstChartDropdown()
+ await openBuildItMyselfMenu()
await userEvent.click(screen.getByText('Widget'))
expect(logic.values.addWidgetModalOpen).toBe(true)
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
index a913ac126538..470b2c1e11d8 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
@@ -2,14 +2,14 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import * as chartPng from '@posthog/brand/hoggies/png/chart'
-import { IconPlus } from '@posthog/icons'
+import { IconChevronDown, IconPlus } from '@posthog/icons'
import { DashboardLoadingState } from '@posthog/products-dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState'
import { pngHoggie } from 'lib/brand/hoggies'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu'
+import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { urls } from 'scenes/urls'
@@ -70,42 +70,52 @@ function DashboardEmptyActions({
)}
<div className="flex flex-wrap items-center justify-center gap-x-4 gap-y-2 @min-[48rem]/main-content:justify-start">
{dashboard && (
- <AccessControlAction
- resourceType={AccessControlResourceType.Dashboard}
- minAccessLevel={AccessControlLevel.Editor}
- userAccessLevel={dashboard.user_access_level}
- >
- <LemonButton
- data-attr="dashboard-add-graph-header"
- type="primary"
- icon={<IconPlus />}
- onClick={handleAddInsight}
- disabledReason={canEdit ? null : DASHBOARD_CANNOT_EDIT_MESSAGE}
- sideAction={{
- dropdown: {
- placement: 'bottom-end',
- overlay: (
- <LemonMenuOverlay
- items={getAddTileMenuItems({
- dashboardWidgetsEnabled,
- onAddInsight: handleAddInsight,
- onAddText,
- onAddImage,
- onAddButton,
- push,
- setAddWidgetModalOpen: onAddWidget,
- })}
- />
- ),
- },
- disabled: !canEdit,
- disabledReason: canEdit ? null : DASHBOARD_CANNOT_EDIT_MESSAGE,
- 'data-attr': 'dashboard-add-dropdown',
- }}
+ <>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Dashboard}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={dashboard.user_access_level}
>
- Add a chart
- </LemonButton>
- </AccessControlAction>
+ <LemonButton
+ data-attr="dashboard-add-graph-header"
+ type="primary"
+ icon={<IconPlus />}
+ onClick={handleAddInsight}
+ disabledReason={canEdit ? null : DASHBOARD_CANNOT_EDIT_MESSAGE}
+ >
+ Add a chart
+ </LemonButton>
+ </AccessControlAction>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Dashboard}
+ minAccessLevel={AccessControlLevel.Editor}
+ userAccessLevel={dashboard.user_access_level}
+ >
+ {({ disabledReason }) => (
+ <LemonMenu
+ placement="bottom-start"
+ items={getAddTileMenuItems({
+ dashboardWidgetsEnabled,
+ onAddInsight: handleAddInsight,
+ onAddText,
+ onAddImage,
+ onAddButton,
+ push,
+ setAddWidgetModalOpen: onAddWidget,
+ })}
+ >
+ <LemonButton
+ type="secondary"
+ data-attr="dashboard-add-dropdown"
+ sideIcon={<IconChevronDown />}
+ disabledReason={canEdit ? disabledReason : DASHBOARD_CANNOT_EDIT_MESSAGE}
+ >
+ Build it myself
+ </LemonButton>
+ </LemonMenu>
+ )}
+ </AccessControlAction>
+ </>
)}
<LemonButton
type="secondary"