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): switch group display from the group menu (#124073)

Paul D'Ambra4dbab5b4172e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 36e0245620a6..3e37d54f400a 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7288,10 +7288,22 @@ snapshots:
hash: v1.k794b7964.7520c13b8a344d6d667fac6f402e2418b65f07e8479c9ab7c5764b9908409b64.IqQ8q-w1XqU52kZ4cA8mei_LdAEcvGXHuODmviYTbPU
products-dashboards-tiles-tile-group--long-title-in-narrow-scene--light:
hash: v1.k794b7964.a12a7ea7501e57d64e33b9b2f2d8c3877af396a7fdd34492b9cf74c40604bd10.pThN8_C9JqaiQgLQAjHWnFb94JOknMJkqjDJByKiKOk
+ products-dashboards-tiles-tile-group--menu-open--dark:
+ hash: v1.k794b7964.a0c3751dbf321d7467f7376e93adda08f0bd29354d60f6ab6ad5531ad8b76d1f.s8v2vugQRRbWw2RJ7OQKV_PaEJCU2k97m76BJjLqLuc
+ products-dashboards-tiles-tile-group--menu-open--light:
+ hash: v1.k794b7964.cfd096e611a803c57713b59ecd2b3086c37a1686f458301e8443d498e839a5aa.Zwt_2mShgLUh335VpZOJfMqooexTWeQntIBNtO7_4U8
products-dashboards-tiles-tile-group--styles--dark:
hash: v1.k794b7964.be0395b6c09a3c0380edd0b5bb22cfe61482fa0c977f51b144dab5fdd77f6ce8.-KKnKUn0dUiBlAtuIOzPRIVfjImLj8UbTWHpPj1r6zY
products-dashboards-tiles-tile-group--styles--light:
hash: v1.k794b7964.1ea4c4743d7380fe85985e50795f9a6dd4dc1909f37a926800aa316aebb26a31.-z1Igyir2gbb9kVTuxP9EAoUX1Dg5J1fKGFJINxzh7g
+ products-dashboards-tiles-tile-group-tabs--group-tab-menu-open--dark:
+ hash: v1.k794b7964.1b61c52567f1b5a1c8ab1327f463f5e0c26e786fb8eaab08b4b5fa02669a5be2.JRSjR2Xd9-SyNQ_zbaqBj9pARoWVep8y3Ny-pjlUuUQ
+ products-dashboards-tiles-tile-group-tabs--group-tab-menu-open--light:
+ hash: v1.k794b7964.320c1708f492f3663d25503a1d652ad244c25ac3e87ea4f9bd9a3914136addf4.TNlLgNvpjwPY5H5_XPQmXkVo3cii6zySskqUci-BhPk
+ products-dashboards-tiles-tile-group-tabs--overview-tab-menu-open--dark:
+ hash: v1.k794b7964.5bb3321201cfd932ad8b4678f85ccb1c14d998ded1e2be520aed4fb5f78b4228.Jecda0GeagvkWplgFZiTQQr70fOzZhc3BAWFL3lRJek
+ products-dashboards-tiles-tile-group-tabs--overview-tab-menu-open--light:
+ hash: v1.k794b7964.486a78f0edf06ff69cd66fb993eab897868162b540c5c618809d40f7e311c284.KCS4__SBZK414hHJ_S8IjGrkmCkpn8bIMsIHl0DUKtA
products-data-catalog-metric-lineage--being-prepared--dark:
hash: v1.k794b7964.9b3dd08fa1426e0715daefdf347f20d3e251483c787dd3a9f3ad02fca88ae00b.N85-92zGL68U5fyXpoWHYbbTGLRVTOw42k7LxJ3HZHw
products-data-catalog-metric-lineage--being-prepared--light:
diff --git a/frontend/src/scenes/dashboard/DashboardItems.test.tsx b/frontend/src/scenes/dashboard/DashboardItems.test.tsx
index 343a9b5a6e05..baad66f24966 100644
--- a/frontend/src/scenes/dashboard/DashboardItems.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardItems.test.tsx
@@ -11,6 +11,8 @@ import { dashboardsModel } from '~/models/dashboardsModel'
import { insightsModel } from '~/models/insightsModel'
import { DashboardPlacement } from '~/types'
+import { UNGROUPED_TILES_TAB_KEY } from 'products/dashboards/frontend/dashboardTileSections'
+
import { DashboardItems } from './DashboardItems'
jest.mock('kea', () => ({
@@ -221,6 +223,7 @@ const mockTriggerDashboardRefresh = jest.fn()
const mockInsightCard = jest.fn()
const mockUpdateContainerWidth = jest.fn()
const mockMoveTileToSection = jest.fn()
+const mockChangeTileGroupDisplay = jest.fn()
const mockPositionStrategies = new Map<Element, unknown>()
let mockGridWidth = 1200
let mockGridMounts = 0
@@ -293,6 +296,7 @@ describe('DashboardItems', () => {
setTileOverride: jest.fn(),
setDashboardMode: jest.fn(),
moveTileToSection: mockMoveTileToSection,
+ changeTileGroupDisplay: mockChangeTileGroupDisplay,
}
}
@@ -765,6 +769,54 @@ describe('DashboardItems', () => {
expect(container.querySelector('[data-attr="dashboard-tile-group-menu"]')).not.toBeInTheDocument()
})
+ it.each([
+ { layout: 'bands', overrides: {}, item: 'Show all groups as tabs', display: 'tabs', copyItemHidden: false },
+ {
+ layout: 'tabs',
+ overrides: { activeTileGroupTab: 'plans' },
+ item: 'Show groups as sections',
+ display: 'sections',
+ copyItemHidden: false,
+ },
+ {
+ layout: 'tabs (overview tab)',
+ overrides: {
+ activeTileGroupTab: UNGROUPED_TILES_TAB_KEY,
+ tileGroupSections: [{ kind: 'tiles', key: UNGROUPED_TILES_TAB_KEY, tiles: [] }],
+ },
+ item: 'Show groups as sections',
+ display: 'sections',
+ copyItemHidden: true,
+ },
+ ])(
+ 'switches how groups show from the group menu in $layout',
+ async ({ overrides, item, display, copyItemHidden }) => {
+ showBands(overrides)
+ const bandValues = mockedUseValues.getMockImplementation()!
+ mockedUseValues.mockImplementation((logic) =>
+ logic === dashboardsModel ? { dashboardsLoading: false } : bandValues(logic)
+ )
+ const defaultActions = mockedUseActions.getMockImplementation()!
+ mockedUseActions.mockImplementation((logic) =>
+ logic === dashboardsModel ? { loadDashboardsIfNeeded: jest.fn() } : defaultActions(logic)
+ )
+
+ const { container, findByText, queryByText, unmount } = render(<DashboardItems />)
+ fireEvent.click(container.querySelector('[data-attr="dashboard-tile-group-menu"]')!)
+ await findByText(item)
+
+ expect(Boolean(queryByText(/Copy .* to dashboard/))).toBe(!copyItemHidden)
+
+ fireEvent.click(await findByText(item))
+
+ expect(mockChangeTileGroupDisplay).toHaveBeenCalledWith(display)
+
+ // The menu's dropdown portals to document.body and stays open after a mocked
+ // selection, so unmount before the next case to stop its content leaking into it.
+ unmount()
+ }
+ )
+
it('keeps a band grid mounted when a tile streams into the band', () => {
const defaultValues = mockedUseValues.getMockImplementation()!
showBands()
diff --git a/frontend/src/scenes/dashboard/DashboardItems.tsx b/frontend/src/scenes/dashboard/DashboardItems.tsx
index a4612fc2d309..5e19a19827c1 100644
--- a/frontend/src/scenes/dashboard/DashboardItems.tsx
+++ b/frontend/src/scenes/dashboard/DashboardItems.tsx
@@ -143,6 +143,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsP
moveToDashboard,
copyToDashboard,
copyGroupToDashboard,
+ changeTileGroupDisplay,
setDashboardEditing,
toggleTileGroup,
selectTileGroupTab,
@@ -266,6 +267,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsP
!!dashboard && canEditDashboard && !layoutEditMode && !isMobileView && isEditablePlacement
const onCopyGroupToDashboard = canEditDashboard && isEditablePlacement ? copyGroupToDashboard : undefined
+ const onChangeGroupDisplay = canEditDashboard && isEditablePlacement ? changeTileGroupDisplay : undefined
const isLayoutZoomToggled = layoutEditMode && layoutZoom !== 1
@@ -841,6 +843,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsP
copyToDestinations={copyToDestinations}
onCopyGroupToDashboard={onCopyGroupToDashboard}
copyLoading={copyGroupToDashboardLoading}
+ onChangeGroupDisplay={onChangeGroupDisplay}
>
{renderSectionGrid(section, index)}
</DashboardTileSectionBand>
@@ -863,6 +866,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsP
copyToDestinations={copyToDestinations}
onCopyGroupToDashboard={onCopyGroupToDashboard}
copyLoading={copyGroupToDashboardLoading}
+ onChangeGroupDisplay={onChangeGroupDisplay}
>
{renderSectionGrid(tileGroupSections[activeTabIndex], activeTabIndex)}
</DashboardTileGroupTabs>
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.stories.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.stories.tsx
index 637e34a175e1..5582ac0f8c6a 100644
--- a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.stories.tsx
+++ b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.stories.tsx
@@ -1,5 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
+import { waitFor } from '@testing-library/react'
+import { useStorybookMocks } from '~/mocks/browser'
import type { DashboardBasicType } from '~/types'
import type { DashboardTileGroupApi } from '../../generated/api.schemas'
@@ -37,6 +39,7 @@ export const LongTitleInNarrowScene: StoryObj = {
onToggle={() => {}}
copyToDestinations={[{ dashboard: { id: 42, name: 'Example dashboard' } as DashboardBasicType }]}
onCopyToDashboard={() => {}}
+ onChangeGroupDisplay={() => {}}
>
<FakeTile />
</DashboardTileGroup>
@@ -44,6 +47,37 @@ export const LongTitleInNarrowScene: StoryObj = {
),
}
+export const MenuOpen: StoryObj = {
+ render: () => {
+ useStorybookMocks({ get: { '/api/projects/:team_id/dashboards/': { count: 0, results: [] } } })
+ return (
+ <div className="h-60 w-[640px] bg-primary p-4">
+ <DashboardTileGroup
+ group={{ title: 'Activation', color: 'blue' }}
+ tileCount={2}
+ collapsed={false}
+ onToggle={() => {}}
+ copyToDestinations={[{ dashboard: { id: 42, name: 'Example dashboard' } as DashboardBasicType }]}
+ onCopyToDashboard={() => {}}
+ onChangeGroupDisplay={() => {}}
+ >
+ <FakeTile />
+ </DashboardTileGroup>
+ </div>
+ )
+ },
+ play: async () => {
+ const trigger = await waitFor(() => {
+ const element = document.querySelector<HTMLElement>('[data-attr="dashboard-tile-group-menu"]')
+ if (!element) {
+ throw new Error('Group menu trigger not found')
+ }
+ return element
+ })
+ trigger.click()
+ },
+}
+
export const Styles: StoryObj = {
render: () => (
<div className="flex flex-col gap-4 bg-primary p-4">
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.tsx
index 71cfe15fad89..049a7dd62c1a 100644
--- a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.tsx
+++ b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroup.tsx
@@ -6,8 +6,10 @@ import type { DashboardWidgetPlacementDestination } from 'lib/components/Cards/I
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { pluralize } from 'lib/utils/strings'
+import type { TileGroupDisplay } from '~/types'
+
import type { DashboardTileGroupApi } from '../../generated/api.schemas'
-import { DashboardTileGroupCopyMenu } from './DashboardTileGroupCopyMenu'
+import { DashboardTileGroupMenu } from './DashboardTileGroupMenu'
import { TileGroupColorDot } from './TileGroupColorDot'
interface DashboardTileGroupProps {
@@ -18,6 +20,7 @@ interface DashboardTileGroupProps {
copyToDestinations?: DashboardWidgetPlacementDestination[]
onCopyToDashboard?: (dashboardId: number, dashboardName: string) => void
copyLoading?: boolean
+ onChangeGroupDisplay?: (groupDisplay: TileGroupDisplay) => void
children: React.ReactNode
}
@@ -29,6 +32,7 @@ export function DashboardTileGroup({
copyToDestinations,
onCopyToDashboard,
copyLoading,
+ onChangeGroupDisplay,
children,
}: DashboardTileGroupProps): JSX.Element {
const tileCountLabel = pluralize(tileCount, 'tile')
@@ -59,12 +63,13 @@ export function DashboardTileGroup({
</LemonButton>
{group.title && collapsed && <span className="shrink-0 text-secondary text-xs">{tileCountLabel}</span>}
<div className="min-w-4 flex-1 border-t border-primary" />
- {onCopyToDashboard && (
- <DashboardTileGroupCopyMenu
- label="Copy group to dashboard"
- destinations={copyToDestinations ?? []}
+ {(onChangeGroupDisplay || onCopyToDashboard) && (
+ <DashboardTileGroupMenu
+ groupDisplay="sections"
+ onChangeGroupDisplay={onChangeGroupDisplay}
+ copyToDestinations={copyToDestinations}
onCopyToDashboard={onCopyToDashboard}
- loading={copyLoading}
+ copyLoading={copyLoading}
/>
)}
</div>
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupCopyMenu.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupCopyMenu.tsx
deleted file mode 100644
index e85fb58dfd65..000000000000
--- a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupCopyMenu.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { useActions } from 'kea'
-
-import { DashboardWidgetPlacementMenu } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
-import type { DashboardWidgetPlacementDestination } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
-import { More } from 'lib/lemon-ui/LemonButton/More'
-
-import { dashboardsModel } from '~/models/dashboardsModel'
-
-interface DashboardTileGroupCopyMenuProps {
- label: string
- destinations: DashboardWidgetPlacementDestination[]
- onCopyToDashboard: (dashboardId: number, dashboardName: string) => void
- loading?: boolean
-}
-
-export function DashboardTileGroupCopyMenu({
- label,
- destinations,
- onCopyToDashboard,
- loading,
-}: DashboardTileGroupCopyMenuProps): JSX.Element {
- const { loadDashboardsIfNeeded } = useActions(dashboardsModel)
-
- return (
- <More
- data-attr="dashboard-tile-group-menu"
- tooltip="Group actions"
- loading={loading}
- disabledReason={loading ? 'Copying group' : undefined}
- dropdown={{ onVisibilityChange: (visible) => visible && loadDashboardsIfNeeded() }}
- overlay={
- <div className="min-w-48 p-1">
- <DashboardWidgetPlacementMenu
- label={label}
- destinations={destinations}
- onSelect={({ id, name }) => onCopyToDashboard(id, name || 'Untitled')}
- />
- </div>
- }
- />
- )
-}
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupMenu.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupMenu.tsx
new file mode 100644
index 000000000000..d61b7219a644
--- /dev/null
+++ b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupMenu.tsx
@@ -0,0 +1,82 @@
+import { useActions } from 'kea'
+
+import { DashboardWidgetPlacementMenu } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
+import type { DashboardWidgetPlacementDestination } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { More } from 'lib/lemon-ui/LemonButton/More'
+import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
+
+import { dashboardsModel } from '~/models/dashboardsModel'
+import type { TileGroupDisplay } from '~/types'
+
+const MENU_ITEMS: Record<
+ TileGroupDisplay,
+ { copyLabel: string; copyNoun: string; switchTo: TileGroupDisplay; switchLabel: string }
+> = {
+ sections: {
+ copyLabel: 'Copy group to dashboard',
+ copyNoun: 'group',
+ switchTo: 'tabs',
+ switchLabel: 'Show all groups as tabs',
+ },
+ tabs: {
+ copyLabel: 'Copy tab to dashboard',
+ copyNoun: 'tab',
+ switchTo: 'sections',
+ switchLabel: 'Show groups as sections',
+ },
+}
+
+interface DashboardTileGroupMenuProps {
+ // Set by the caller to match where this menu renders: "sections" in the group header,
+ // "tabs" in the tab bar. Not read from the dashboard's actual display mode.
+ groupDisplay: TileGroupDisplay
+ onChangeGroupDisplay?: (groupDisplay: TileGroupDisplay) => void
+ copyToDestinations?: DashboardWidgetPlacementDestination[]
+ onCopyToDashboard?: (dashboardId: number, dashboardName: string) => void
+ copyLoading?: boolean
+}
+
+export function DashboardTileGroupMenu({
+ groupDisplay,
+ onChangeGroupDisplay,
+ copyToDestinations,
+ onCopyToDashboard,
+ copyLoading,
+}: DashboardTileGroupMenuProps): JSX.Element {
+ const { loadDashboardsIfNeeded } = useActions(dashboardsModel)
+ const { copyLabel, copyNoun, switchTo, switchLabel } = MENU_ITEMS[groupDisplay]
+
+ return (
+ <More
+ data-attr="dashboard-tile-group-menu"
+ tooltip="Group actions"
+ loading={copyLoading}
+ disabledReason={copyLoading ? `Copying ${copyNoun}` : undefined}
+ dropdown={{ onVisibilityChange: (visible) => visible && onCopyToDashboard && loadDashboardsIfNeeded() }}
+ overlay={
+ <div className="min-w-48 p-1">
+ {onCopyToDashboard && (
+ <>
+ <DashboardWidgetPlacementMenu
+ label={copyLabel}
+ destinations={copyToDestinations ?? []}
+ onSelect={({ id, name }) => onCopyToDashboard(id, name || 'Untitled')}
+ />
+ {onChangeGroupDisplay && <LemonDivider />}
+ </>
+ )}
+ {onChangeGroupDisplay && (
+ <LemonButton
+ fullWidth
+ onClick={() => onChangeGroupDisplay(switchTo)}
+ data-attr={`dashboard-tile-group-menu-group-display-${switchTo}`}
+ >
+ {switchLabel}
+ </LemonButton>
+ )}
+ </div>
+ }
+ />
+ )
+}
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.stories.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.stories.tsx
new file mode 100644
index 000000000000..2ee16be36073
--- /dev/null
+++ b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.stories.tsx
@@ -0,0 +1,66 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { waitFor } from '@testing-library/react'
+
+import { useStorybookMocks } from '~/mocks/browser'
+import type { DashboardBasicType } from '~/types'
+
+import { type DashboardSection, UNGROUPED_TILES_TAB_KEY } from '../../dashboardTileSections'
+import { DashboardTileGroupTabs } from './DashboardTileGroupTabs'
+
+const meta: Meta<typeof DashboardTileGroupTabs> = {
+ title: 'Products/Dashboards/Tiles/Tile group tabs',
+ component: DashboardTileGroupTabs,
+ parameters: { layout: 'padded' },
+}
+export default meta
+
+const SECTIONS: DashboardSection[] = [
+ { kind: 'tiles', key: UNGROUPED_TILES_TAB_KEY, tiles: [] },
+ { kind: 'group', key: 'group-activation', groupKey: 'activation', group: { title: 'Activation' }, tiles: [] },
+ {
+ kind: 'group',
+ key: 'group-revenue',
+ groupKey: 'revenue',
+ group: { title: 'Revenue', color: 'purple' },
+ tiles: [],
+ },
+]
+
+function TabsWithMenu({ activeSectionKey }: { activeSectionKey: string }): JSX.Element {
+ useStorybookMocks({ get: { '/api/projects/:team_id/dashboards/': { count: 0, results: [] } } })
+ return (
+ <div className="h-60 w-[640px] bg-primary p-4">
+ <DashboardTileGroupTabs
+ sections={SECTIONS}
+ activeSectionKey={activeSectionKey}
+ onSelect={() => {}}
+ copyToDestinations={[{ dashboard: { id: 42, name: 'Example dashboard' } as DashboardBasicType }]}
+ onCopyGroupToDashboard={() => {}}
+ onChangeGroupDisplay={() => {}}
+ >
+ <div className="h-20 rounded border bg-surface-primary" />
+ </DashboardTileGroupTabs>
+ </div>
+ )
+}
+
+async function openGroupMenu(): Promise<void> {
+ const trigger = await waitFor(() => {
+ const element = document.querySelector<HTMLElement>('[data-attr="dashboard-tile-group-menu"]')
+ if (!element) {
+ throw new Error('Group menu trigger not found')
+ }
+ return element
+ })
+ trigger.click()
+}
+
+export const GroupTabMenuOpen: StoryObj = {
+ render: () => <TabsWithMenu activeSectionKey="group-revenue" />,
+ play: openGroupMenu,
+}
+
+export const OverviewTabMenuOpen: StoryObj = {
+ render: () => <TabsWithMenu activeSectionKey={UNGROUPED_TILES_TAB_KEY} />,
+ play: openGroupMenu,
+}
diff --git a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.tsx b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.tsx
index e5001b1b0374..97a1db099735 100644
--- a/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.tsx
+++ b/products/dashboards/frontend/components/DashboardTileGroup/DashboardTileGroupTabs.tsx
@@ -1,8 +1,10 @@
import type { DashboardWidgetPlacementDestination } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
import { LemonTabs } from 'lib/lemon-ui/LemonTabs'
+import type { TileGroupDisplay } from '~/types'
+
import { type DashboardSection, getTileGroupLabel } from '../../dashboardTileSections'
-import { DashboardTileGroupCopyMenu } from './DashboardTileGroupCopyMenu'
+import { DashboardTileGroupMenu } from './DashboardTileGroupMenu'
import { TileGroupColorDot } from './TileGroupColorDot'
interface DashboardTileGroupTabsProps {
@@ -12,6 +14,7 @@ interface DashboardTileGroupTabsProps {
copyToDestinations?: DashboardWidgetPlacementDestination[]
onCopyGroupToDashboard?: (groupKey: string, dashboardId: number, dashboardName: string) => void
copyLoading?: boolean
+ onChangeGroupDisplay?: (groupDisplay: TileGroupDisplay) => void
children: React.ReactNode
}
@@ -22,6 +25,7 @@ export function DashboardTileGroupTabs({
copyToDestinations,
onCopyGroupToDashboard,
copyLoading,
+ onChangeGroupDisplay,
children,
}: DashboardTileGroupTabsProps): JSX.Element {
const activeSection = sections.find((section) => section.key === activeSectionKey)
@@ -43,16 +47,20 @@ export function DashboardTileGroupTabs({
'Overview'
),
}))}
+ rightSlotClassName="pr-0"
rightSlot={
- activeSection?.kind === 'group' &&
- onCopyGroupToDashboard && (
- <DashboardTileGroupCopyMenu
- label="Copy tab to dashboard"
- destinations={copyToDestinations ?? []}
- onCopyToDashboard={(dashboardId, dashboardName) =>
- onCopyGroupToDashboard(activeSection.groupKey, dashboardId, dashboardName)
+ (onChangeGroupDisplay || onCopyGroupToDashboard) && (
+ <DashboardTileGroupMenu
+ groupDisplay="tabs"
+ onChangeGroupDisplay={onChangeGroupDisplay}
+ copyToDestinations={copyToDestinations}
+ onCopyToDashboard={
+ activeSection?.kind === 'group' && onCopyGroupToDashboard
+ ? (dashboardId, dashboardName) =>
+ onCopyGroupToDashboard(activeSection.groupKey, dashboardId, dashboardName)
+ : undefined
}
- loading={copyLoading}
+ copyLoading={copyLoading}
/>
)
}
diff --git a/products/dashboards/frontend/components/DashboardTileSectionBand.tsx b/products/dashboards/frontend/components/DashboardTileSectionBand.tsx
index 02315657c6f8..abcf881002f5 100644
--- a/products/dashboards/frontend/components/DashboardTileSectionBand.tsx
+++ b/products/dashboards/frontend/components/DashboardTileSectionBand.tsx
@@ -3,6 +3,8 @@ import clsx from 'clsx'
import type { DashboardWidgetPlacementDestination } from 'lib/components/Cards/InsightCard/DashboardWidgetPlacementMenu'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
+import type { TileGroupDisplay } from '~/types'
+
import type { DashboardSection } from '../dashboardTileSections'
import { DashboardTileGroup } from './DashboardTileGroup/DashboardTileGroup'
@@ -15,6 +17,7 @@ interface DashboardTileSectionBandProps {
copyToDestinations?: DashboardWidgetPlacementDestination[]
onCopyGroupToDashboard?: (groupKey: string, dashboardId: number, dashboardName: string) => void
copyLoading?: boolean
+ onChangeGroupDisplay?: (groupDisplay: TileGroupDisplay) => void
children: React.ReactNode
}
@@ -27,6 +30,7 @@ export function DashboardTileSectionBand({
copyToDestinations,
onCopyGroupToDashboard,
copyLoading,
+ onChangeGroupDisplay,
children,
}: DashboardTileSectionBandProps): JSX.Element {
return (
@@ -51,6 +55,7 @@ export function DashboardTileSectionBand({
: undefined
}
copyLoading={copyLoading}
+ onChangeGroupDisplay={onChangeGroupDisplay}
>
{children}
</DashboardTileGroup>