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(customer-analytics): add responsive account view spans (#107162)

Arthur Moreira de Deus02f43d461630
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f1ac29027531..d7e9b0d30452 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8475,25 +8475,25 @@ snapshots:
scenes-app-businessknowledge-knowledgesourcenamecell--user-text--light:
hash: v1.k794b7964.fba04716b8f344e21fa3bb2ec69e627bd9836ff2161986538ac2b562973b0edc.Xl-YJ8Poqz1nofU4nIyAfnM4GbZZ1YYtbM37mIzZ4w4
scenes-app-customer-analytics-account-detail--default--dark:
- hash: v1.k794b7964.f55cbc927d83349e6016946865d60af9ebfbe3724597caf9bf682c4d885b5f55.pZQ15hvOXcX-PPQg5opIFACfL02olPu3GdjWWADiyIo
+ hash: v1.k794b7964.e406f25e10ea518a95bc5facd84b2eb328fb2510f7c84775a4e194defd7e68ee.10U-4oFjHBL3kpfrMkIXXRByXOcG082RMJqiuKuJnYM
scenes-app-customer-analytics-account-detail--default--light:
- hash: v1.k794b7964.17f23e44d4be6419b743063d4acb33c56cc2db90bda270441bf6846b8fa5c9dd.rDWoID_DTSWG3KvlD1692sNZ2TfFlVv-locqE4UG6yI
+ hash: v1.k794b7964.6e361eda840f3562080ab5a82e1b77d046151674ced3c2040d93ae381a3ba9c4.2eeP7b-IFlqXCNnod08vFTQ0oc9hNBxzcFfAAOz5wXk
scenes-app-customer-analytics-account-detail--external-id--dark:
hash: v1.k794b7964.7a97ff01865aa33e2e515dbcfa3271c4d09b30e178c2068cfd6c50b354dc0c88.M4v9oXKbuYzcCJpEjJxSBlFvxNVJ_ML54IzW5y0drwA
scenes-app-customer-analytics-account-detail--external-id--light:
hash: v1.k794b7964.0dd4405e4b4afc137065998960479aead50b51dd699d78fcd5ee69a7f0c341ef.6ZpL-2UskmHTXtHbB2Fym3H1GBqkpNILhX5aN5_VdKY
scenes-app-customer-analytics-account-detail--narrow--dark:
- hash: v1.k794b7964.3afacd443ad5e52ea3928f246ec369cef0e96e9fdcaa8df42bea2f28c9ed68ea.m1gsgodQb5ZRVNX8upsuVpOsgoL7_gpJB2bScwvBXC0
+ hash: v1.k794b7964.acb3423c3a688e82a8d3304f52abc9ec9fe1bb85b498b2a5014c2a2e95b9d877.O3Dc_DGbMRxU8xAvLVsLhmaDF30FZT7vFNKa5dkYlq0
scenes-app-customer-analytics-account-detail--narrow--light:
- hash: v1.k794b7964.2e433c51ae4e4964ff5ef866c16c329e1c8efdc7309c8e52b3c6356b5f5284fd.ygUYz_umKVeGeUQxWKccERjADuln7EmWLMwWSrPtjsc
+ hash: v1.k794b7964.fa04c3ccdb0dae243b62e5a3e7760db14917044d5499046026eae617804acb29.ssrKGWqZ8hXPBhxXc5gmOOZFBeJQ0JbaWv-STkBpPYY
scenes-app-customer-analytics-account-detail--pinned-properties--dark:
- hash: v1.k794b7964.54ea48d6975378be56d4e7173249f474dd8918e21edb8403c01faec6291283a4.b9-0ww9qPZpRSI6Y5zO39ZoQOJrsTL_4eJzmamPOvbs
+ hash: v1.k794b7964.58a838edf3a5be2f5ed19358028e5805b4ab03adc9cbe4eecfc1da4bdfe9e28e.kPVPRuMe3bBam15KhH4xq_xGydxtVwxqo5Ii4LnKOGM
scenes-app-customer-analytics-account-detail--pinned-properties--light:
- hash: v1.k794b7964.3c50d69127e61293fd954705cdffafcd34f29d5351b326eecfd02a3c3342fbef.eGAb5f9f9CvdrdRduMhUbmOTmdXvhA0LxPvWbrKgT-A
+ hash: v1.k794b7964.98646922752bd85fc0c7bd33745ef22ea1f8ddaf3699c7e735d3abdc853145c5.K72VbHO6G7lt2N9BoXxdCNLydXyMvAlKwTOP5NGRJbg
scenes-app-customer-analytics-account-detail--pinned-properties-narrow--dark:
- hash: v1.k794b7964.cd775573d45974bb438db1d97582091af93786bab2119fc3ba1fb6d1704563f5.xR1-jf_tn9a1PLQRZrEhuIlKXVmVu5LWmNc_8umPF-k
+ hash: v1.k794b7964.d44827f7d55e749657c87a7737a47e1376401fa04ddacec22d7e3f54d41a03fb.FNYwJjH3B9ZgdOgKC8xIDT7UpXFGrcwAD5-MK9gulUg
scenes-app-customer-analytics-account-detail--pinned-properties-narrow--light:
- hash: v1.k794b7964.04da5af95a08a1b9ff1dcd34e0411556930d1f337012afacbcba0ded5b05b8a6.4IPSYRPZJx4fgSouqwBJ68lzocov_SugJCTZt2ot4-s
+ hash: v1.k794b7964.143c75f12d5a5967393fe957805eb91c86463cfa76d1e890d6a867bb7a7cd51a.2mMepzFefUEAUKA3TIIeOM8xSjb21jg_68RGPJj-2aU
scenes-app-customer-analytics-account-detail-property-sidebar--custom-property-editors--dark:
hash: v1.k794b7964.caefec23d66985f72f6eb40a23370ec4bf1701b9b6cfccd2a4b2b09cc9c1606f.lJ1UWZ6LkZI-k4XJw5UtuIJx1m5tWlMyvgoPlQH2L-g
scenes-app-customer-analytics-account-detail-property-sidebar--custom-property-editors--light:
diff --git a/products/customer_analytics/backend/logic/account_views.py b/products/customer_analytics/backend/logic/account_views.py
index 7ccb3f2891fa..980da4a9ecec 100644
--- a/products/customer_analytics/backend/logic/account_views.py
+++ b/products/customer_analytics/backend/logic/account_views.py
@@ -24,7 +24,7 @@ ACCOUNT_VIEW_COMPONENT_LABELS = {
"Conversations": "Conversations",
"Meetings": "Meetings",
}
-ACCOUNT_VIEW_ALLOWED_PROPS = {"config", "nodeId", "title"}
+ACCOUNT_VIEW_ALLOWED_PROPS = {"config", "nodeId", "span", "title"}
ACCOUNT_VIEW_COMPONENT_TITLE_MAX_LENGTH = 400
ACCOUNT_VIEW_CONFIG_MAX_BYTES = 16_384
ACCOUNT_VIEW_IDENTITY_PROPS = {
@@ -118,6 +118,10 @@ def validate_account_view_content(content: dict[str, Any]) -> tuple[dict[str, An
else:
node_ids.add(node_id)
+ span = component.props.get("span", 12)
+ if isinstance(span, bool) or not isinstance(span, int) or not 1 <= span <= 12:
+ errors.append(f"Component {index} span must be an integer from 1 to 12.")
+
config = component.props.get("config")
if config is not None:
if not isinstance(config, dict):
diff --git a/products/customer_analytics/backend/test/test_account_views.py b/products/customer_analytics/backend/test/test_account_views.py
index 41ab2bed7b2c..844e8118138f 100644
--- a/products/customer_analytics/backend/test/test_account_views.py
+++ b/products/customer_analytics/backend/test/test_account_views.py
@@ -1,6 +1,8 @@
from posthog.test.base import APIBaseTest
from unittest.mock import patch
+from django.test import SimpleTestCase
+
from rest_framework import status
from posthog.constants import AvailableFeature
@@ -8,6 +10,10 @@ from posthog.models import OrganizationMembership, Team, User
from posthog.models.activity_logging.activity_log import ActivityLog
from products.access_control.backend.models.access_control import AccessControl
+from products.customer_analytics.backend.logic.account_views import (
+ InvalidAccountViewContent,
+ validate_account_view_content,
+)
from products.customer_analytics.backend.models import Account, AccountView
@@ -23,6 +29,14 @@ def account_view_content(*components: str) -> dict:
}
+class TestAccountViewContentValidation(SimpleTestCase):
+ def test_rejects_span_outside_twelve_columns(self) -> None:
+ with self.assertRaises(InvalidAccountViewContent) as context:
+ validate_account_view_content(account_view_content('<Usage nodeId="usage-one" span={13} />'))
+
+ self.assertEqual(context.exception.errors, ["Component 1 span must be an integer from 1 to 12."])
+
+
class TestAccountViews(APIBaseTest):
def setUp(self) -> None:
super().setUp()
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index cc8a3d7fbb86..425ce71dc9ea 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -165,6 +165,7 @@ Tag edits save through `accountsPartialUpdate` and update optimistically. Only t
Pinned property preferences belong to the current user and project, never to an account. `accountSidebarConfigLogic({ projectId })` owns their load, draft, cancel, reorder, and save lifecycle through generated API functions. Keep that logic keyed by project so switching projects cannot briefly expose another project's preferences.
Project admins set the ordered defaults under Customer analytics > Accounts settings. A user config without `properties.pinned_properties` reads those current defaults without copying them into the user row. The first personal save stores a complete override. An explicit empty list is an override with no pins.
Omitting `pinned_properties` from a PATCH leaves existing pins unchanged. Personal API keys and OAuth tokens need `account:write` for PATCH. Session-authenticated viewers can still personalize their own sidebar.
+Account views store a reusable Markdown document, not an account ID. `accountViewComponents.ts` lists the system tabs and view components. `accountViewsLogic` owns view editing and tile settings. The account scene supplies the current account ID when it renders a view. Each tile keeps a stable `nodeId`, so two tiles of the same kind keep separate settings. `UserCustomerAnalyticsConfig.account_detail_tabs` stores each user's tab order, hidden tabs, and default for the project. A direct link can still open a hidden tab. View components render in document order and use `span` to share a row in a wide container. They stack in a narrow container.
The configuration is one ordered list containing both account custom-property and relationship references. Definitions load across every API page, account custom properties are filtered by target, and the shared limit is 50. Missing definitions remain visible as a stale warning; opening the configurator omits them from its draft, so the next save cleans them up.
The empty Properties state uses the hedgehog and primary **Pin properties** action, with no gear. Once at least one reference is pinned, the gear opens the same configurator.
Property reference keys at the component boundary are namespaced as `custom:<uuid>` and `relationship:<uuid>`; persistence maps custom keys back to the API's `custom_property` kind.
@@ -172,12 +173,12 @@ Property reference keys at the component boundary are namespaced as `custom:<uui
Clearing posts a null custom value and preserves history. Relationship removals end assignments; single-holder replacements let the server end the previous holder. Multi-holder retries reload current assignments to avoid duplicating a partially completed save. Failed saves keep the draft open.
Sidebar saves refresh the mounted Relationships tab and account-list data nodes. Tab relationship reloads also refresh sidebar values. See `docs/internal/customer-analytics/account-sidebar.md` for the behavior and API contract.
On wide layouts, the sidebar and the active account-detail tab are separate vertical scroll containers. Narrow layouts retain the single stacked page scroll.
-It reuses `AccountDetailTabs` and `AccountNotesExpansion` with the expanded row, but mounts only the active tab so inactive detail tabs do not load data.
+`AccountDetailNavigation` uses the account component registry and mounts only the active tab, so inactive tabs do not load data. Expanded rows still use `AccountDetailTabs`.
Tables use borders in the detail scene and remain embedded in expanded rows.
-Configure tabs and Add view sit in the scene header. They open work-in-progress dialogs.
+Configure tabs and New view sit in the scene header. They open the tab configurator and view editor when their separate flags are on.
The active tab is path-backed at `/customer_analytics/accounts/:accountId/:tab`.
-The bare path, unknown tabs, and tabs hidden by feature flags render Notes.
+The bare path uses the saved default tab or the first available system tab. An unavailable system tab falls back the same way. A direct link to a hidden tab remains available. A missing custom view shows an unavailable-view message.
User tab changes preserve URL search and hash state and capture `TabViewed`; URL restoration does not capture that event.
When `CUSTOMER_ANALYTICS_ACCOUNT_SCENE` is off, the scene renders `CustomerAnalyticsScene` and preserves the filtered, expanded-row fallback.
@@ -208,7 +209,7 @@ Usage aggregation lives in `billingUsageQuery.ts`: the Usage tab wraps the saved
The Usage and Spend tabs render existing saved billing insights — **point users to them, don't rebuild billing as new insights.**
-**Customer analytics owns the billing chart render.** Each billing chart is multi-series on one shared axis, so a small-magnitude series (e.g. feature flag requests) is a flat sliver against large ones (events/enhanced persons) and can't be read. To offer per-series show/hide **without touching shared data-viz code**, `AccountBillingChart` renders the saved insight's SQL chart directly via `@posthog/quill-charts` instead of an embedded `<Query>`/DataVisualization. It reuses `dataVisualizationLogic` read-only for fetch + SQL-results→series parsing, and renders via `sqlLineGraphAdapter.ts`'s pure builders — the same series building, render dispatch, and line/bar/combo config building (per-column formatting, area fills, right-axis routing, goal and trend lines, percent stacks, plus the 200-series render cap applied locally) the SQL insight chart uses — while staying off that chart's React layer (`SqlChart`/`useSqlChartModel`). Chart-semantics changes belong in the adapter (covered by `sqlLineGraphAdapter.test.ts`), not here. Hidden series are injected into quill's controlled `legend.hiddenKeys` (excluded from drawing and scales; the rest rescale into the freed space). `AccountBillingSeriesToggle` is the control: a compact chip row under each chart, one chip per series colored to match its line/bar (items come from `legendItemsFromSeries` over the same `buildSeries` output the chart draws, so keys and colors can't drift), plus Select all / Clear all buttons at the end of the row that show or hide every series at once (`setAllSeriesHidden`, dispatched with the chart's own key list). The hidden-keys state lives in `accountBillingLogic` (`ephemeralHiddenSeriesKeysByShortId`, keyed per insight because the spend tab renders two) — per-view only: never written to the saved insight, reset on date change, gone on row collapse. Queries whose shape `AccountBillingChart` can't render (non-DataViz, table/number/pie displays, series breakdowns — see `canRenderBillingChart`) fall back to the embedded `<Query>` with no chips. Billing queries stay embedded in both the account list and detail scene: the account and date filter supply SQL variables, so their read-only pickers remain hidden. Embedded SQL charts use their container height instead of the standalone insight viewport height.
+**Customer analytics owns the billing chart render.** Each billing chart is multi-series on one shared axis, so a small-magnitude series (e.g. feature flag requests) is a flat sliver against large ones (events/enhanced persons) and can't be read. To offer per-series show/hide **without touching shared data-viz code**, `AccountBillingChart` renders the saved insight's SQL chart directly via `@posthog/quill-charts` instead of an embedded `<Query>`/DataVisualization. It reuses `dataVisualizationLogic` read-only for fetch + SQL-results→series parsing, and renders via `sqlLineGraphAdapter.ts`'s pure builders — the same series building, render dispatch, and line/bar/combo config building (per-column formatting, area fills, right-axis routing, goal and trend lines, percent stacks, plus the 200-series render cap applied locally) the SQL insight chart uses — while staying off that chart's React layer (`SqlChart`/`useSqlChartModel`). Chart-semantics changes belong in the adapter (covered by `sqlLineGraphAdapter.test.ts`), not here. Hidden series are injected into quill's controlled `legend.hiddenKeys` (excluded from drawing and scales; the rest rescale into the freed space). `AccountBillingSeriesToggle` is the control: a compact chip row under each chart, one chip per series colored to match its line/bar (items come from `legendItemsFromSeries` over the same `buildSeries` output the chart draws, so keys and colors can't drift), plus Select all / Clear all buttons at the end of the row that show or hide every series at once (`setAllSeriesHidden`, dispatched with the chart's own key list). The hidden-keys state lives in `accountBillingLogic` (`ephemeralHiddenSeriesKeysByShortId`, keyed per insight because the spend tab renders two). System tabs keep it for their mounted lifetime. Custom view tiles store it in tile settings. A date change resets it in both cases. Neither path changes the saved insight. Queries whose shape `AccountBillingChart` can't render (non-DataViz, table/number/pie displays, series breakdowns — see `canRenderBillingChart`) fall back to the embedded `<Query>` with no chips. Billing queries stay embedded in both the account list and detail scene: the account and date filter supply SQL variables, so their read-only pickers remain hidden. Embedded SQL charts use their container height instead of the standalone insight viewport height.
The Opportunities tab lists the account's Salesforce opportunities from the data-warehouse `salesforce.opportunity` table (joined by the account's `sfdc_id`). The query runs in `accountOpportunitiesLogic` rather than via a bare `<Query>` so the tab owns every state: a missing `sfdc_id` shows a "not linked to Salesforce" empty state, and because `salesforce.opportunity` is **access-gated and production-only**, a failed query degrades to a pretty hog empty state instead of a red error box. The expected denied/absent-table `QueryError` (`You don't have access to table …` / `Unknown table …`) is **not** captured to PostHog — it's the normal empty state, not a bug — while genuine, unexpected query failures are still reported (`isExpectedMissingTableError` in `accountOpportunitiesLogic`). Each opportunity name links to its Salesforce record (`SALESFORCE_ORIGIN/<id>` in `constants.ts`, the same origin the Useful links sidebar uses).
diff --git a/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.scss b/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.scss
index 2e80883eb356..8fe315e822e6 100644
--- a/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.scss
+++ b/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.scss
@@ -11,10 +11,19 @@
display: none;
}
+// Collapse a hidden column to zero width instead of removing its cells. LemonTable's loader row spans
+// every column, so a removed cell would shift the cells after it into the wrong columns.
+@mixin collapsed-cell {
+ padding: 0 !important;
+ overflow: hidden;
+ visibility: hidden;
+ border: 0 !important;
+}
+
@container (max-width: 720px) {
.CustomerTasksTable__updated,
.CustomerTasksTable__assignee {
- display: none;
+ @include collapsed-cell;
}
.CustomerTasksTable__narrow-assignee {
@@ -27,22 +36,30 @@
.CustomerTasksTable--account .LemonTable colgroup col:nth-child(5),
.CustomerTasksTable--inbox .LemonTable colgroup col:nth-child(4),
.CustomerTasksTable--inbox .LemonTable colgroup col:nth-child(6) {
- display: none;
+ width: 0 !important;
}
}
@container (max-width: 560px) {
.CustomerTasksTable--account {
- // Also hides the Status (2) and Due (4) <col> elements.
+ // Also collapses the Status (2) and Due (4) <col> elements.
.CustomerTasksTable__status,
- .CustomerTasksTable__due,
+ .CustomerTasksTable__due {
+ @include collapsed-cell;
+ }
+
.LemonTable colgroup col:nth-child(2),
.LemonTable colgroup col:nth-child(4) {
- display: none;
+ width: 0 !important;
}
.CustomerTasksTable__narrow-controls {
display: flex;
+
+ // LemonCalendarSelectInput always renders full width, which pushes the due date onto its own line.
+ .LemonButton--full-width {
+ width: auto;
+ }
}
.LemonTable colgroup col:first-child {
diff --git a/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.tsx b/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.tsx
index 53399e194ac0..233c08255d8c 100644
--- a/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.tsx
+++ b/products/customer_analytics/frontend/components/CustomerTasks/CustomerTasksTable.tsx
@@ -150,7 +150,7 @@ export function CustomerTasksTable({
)
return (
<div className={`CustomerTasksTable CustomerTasksTable--${context}`} data-attr="customer-tasks-table">
- <div className="mb-4 flex items-center justify-between gap-2">
+ <div className="mb-4 flex items-start justify-between gap-2">
<CustomerTasksFilters logic={logic} context={context} canViewAll={canViewAll} />
{canCreate && (
<LemonButton type="primary" size="small" onClick={openCreateModal}>
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorComponentItem.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorComponentItem.tsx
index 667af1f9fb77..7e3c7b6cb459 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorComponentItem.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorComponentItem.tsx
@@ -2,7 +2,7 @@ import { useSortable } from '@dnd-kit/sortable'
import { CSS } from '@dnd-kit/utilities'
import { IconCopy, IconTrash } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
+import { LemonButton, LemonSegmentedButton } from '@posthog/lemon-ui'
import { SortableDragIcon } from 'lib/lemon-ui/icons'
@@ -12,6 +12,7 @@ interface AccountViewEditorComponentItemProps {
component: AccountViewComponentInstance
label: string
disabled: boolean
+ onSpanChange: (span: number) => void
onDuplicate: () => void
onRemove: () => void
}
@@ -20,6 +21,7 @@ export function AccountViewEditorComponentItem({
component,
label,
disabled,
+ onSpanChange,
onDuplicate,
onRemove,
}: AccountViewEditorComponentItemProps): JSX.Element {
@@ -27,6 +29,19 @@ export function AccountViewEditorComponentItem({
id: component.nodeId,
disabled,
})
+ const spanOptions = [
+ { value: 6, label: 'Half', 'data-attr': 'account-view-component-span-half' },
+ { value: 12, label: 'Full', 'data-attr': 'account-view-component-span-full' },
+ ...(component.span === 6 || component.span === 12
+ ? []
+ : [
+ {
+ value: component.span,
+ label: `Custom (${component.span}/12)`,
+ 'data-attr': 'account-view-component-span-custom',
+ },
+ ]),
+ ]
return (
<div
@@ -51,6 +66,13 @@ export function AccountViewEditorComponentItem({
<SortableDragIcon />
</button>
<span className="min-w-32 flex-1 font-medium">{label}</span>
+ <LemonSegmentedButton
+ value={component.span}
+ onChange={onSpanChange}
+ options={spanOptions}
+ size="xsmall"
+ disabledReason={disabled ? 'Saving changes' : undefined}
+ />
<div className="flex items-center gap-1">
<LemonButton
size="xsmall"
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.test.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.test.tsx
index ecea5674453d..3f1dbb1fa542 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.test.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.test.tsx
@@ -16,7 +16,7 @@ const visibilityOnlyTeamView: AccountViewApi = {
id: '11111111-2222-4333-8444-555555555555',
name: 'Restricted team view',
visibility: 'team',
- content: createAccountViewContent([{ nodeId: 'usage-one', kind: 'usage', title: 'Usage' }]),
+ content: createAccountViewContent([{ nodeId: 'usage-one', kind: 'usage', span: 12, title: 'Usage' }]),
text_content: 'Usage',
version: 1,
created_by: 2,
@@ -28,6 +28,12 @@ const visibilityOnlyTeamView: AccountViewApi = {
can_change_visibility: true,
}
+const editableCustomSpanView: AccountViewApi = {
+ ...visibilityOnlyTeamView,
+ content: createAccountViewContent([{ nodeId: 'usage-one', kind: 'usage', span: 7, title: 'Usage' }]),
+ can_edit: true,
+}
+
jest.mock('../../generated/api', () => ({
accountViewsList: jest.fn(),
accountViewsPartialUpdate: jest.fn(),
@@ -64,6 +70,19 @@ describe('AccountViewEditorModal', () => {
featureFlagLogic.unmount()
})
+ it('shows the actual value for a stored custom tile span', async () => {
+ mockAccountViewsList.mockResolvedValue([editableCustomSpanView])
+ const logic = accountViewsLogic({ projectId: 1 })
+ logic.mount()
+ render(<AccountViewEditorModal projectId={1} />)
+
+ await waitFor(() => expect(logic.values.views).toEqual([editableCustomSpanView]))
+ act(() => logic.actions.openEditEditor(editableCustomSpanView))
+
+ expect(screen.getByText('Custom (7/12)')).toBeInTheDocument()
+ logic.unmount()
+ })
+
it('allows a visibility-only team view editor to save only the visibility', async () => {
const logic = accountViewsLogic({ projectId: 1 })
logic.mount()
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.tsx
index e9a8e8c0209a..e9cd6af88fb2 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewEditorModal.tsx
@@ -42,6 +42,7 @@ export function AccountViewEditorModal({ projectId }: AccountViewEditorModalProp
duplicateEditorComponent,
removeEditorComponent,
reorderEditorComponent,
+ setEditorComponentSpan,
saveEditor,
reloadEditor,
deleteView,
@@ -191,6 +192,9 @@ export function AccountViewEditorModal({ projectId }: AccountViewEditorModalProp
component={component}
label={component.title ?? definition?.label ?? component.kind}
disabled={editorSaving}
+ onSpanChange={(span) =>
+ setEditorComponentSpan(component.nodeId, span)
+ }
onDuplicate={() => duplicateEditorComponent(component.nodeId)}
onRemove={() => removeEditorComponent(component.nodeId)}
/>
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.test.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.test.tsx
index c6e92907564e..17f9a122eaeb 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.test.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.test.tsx
@@ -14,9 +14,13 @@ jest.mock('./AccountViewTile', () => {
const React = jest.requireActual<typeof import('react')>('react')
return {
- AccountViewTile: ({ component }: { component: { config?: { searchTerm?: string } } }) => {
+ AccountViewTile: ({ component }: { component: { nodeId: string; config?: { searchTerm?: string } } }) => {
const [mountedSearchTerm] = React.useState(component.config?.searchTerm)
- return React.createElement('span', { 'data-attr': 'mounted-search-term' }, mountedSearchTerm)
+ return React.createElement(
+ 'span',
+ { 'data-attr': `account-view-tile-${component.nodeId}` },
+ React.createElement('span', { 'data-attr': 'mounted-search-term' }, mountedSearchTerm)
+ )
},
}
})
@@ -30,6 +34,7 @@ function createView(searchTerm: string): AccountViewApi {
{
nodeId: 'tile-1',
kind: 'notes',
+ span: 12,
config: { searchTerm },
},
]),
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.tsx
index 317eb38c3ef6..7aebfbaf8d5d 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewRenderer.tsx
@@ -8,6 +8,21 @@ import { parseAccountViewContent } from './accountViewDocument'
import { accountViewsLogic } from './accountViewsLogic'
import { AccountViewTile } from './AccountViewTile'
+const SPAN_CLASSES: Record<number, string> = {
+ 1: '@min-[48rem]/account-view:col-span-1',
+ 2: '@min-[48rem]/account-view:col-span-2',
+ 3: '@min-[48rem]/account-view:col-span-3',
+ 4: '@min-[48rem]/account-view:col-span-4',
+ 5: '@min-[48rem]/account-view:col-span-5',
+ 6: '@min-[48rem]/account-view:col-span-6',
+ 7: '@min-[48rem]/account-view:col-span-7',
+ 8: '@min-[48rem]/account-view:col-span-8',
+ 9: '@min-[48rem]/account-view:col-span-9',
+ 10: '@min-[48rem]/account-view:col-span-10',
+ 11: '@min-[48rem]/account-view:col-span-11',
+ 12: '@min-[48rem]/account-view:col-span-12',
+}
+
interface AccountViewRendererProps {
view: AccountViewApi
accountId: string
@@ -22,7 +37,7 @@ export function AccountViewRenderer({ view, accountId, externalId, projectId }:
const components = parseAccountViewContent(view.content).filter((component) => availableKinds.has(component.kind))
return (
- <div className="flex flex-col gap-3 py-3" data-attr="account-view-content">
+ <div className="@container/account-view grid grid-cols-12 gap-3 py-3" data-attr="account-view-content">
{components.map((component) => (
<AccountViewTile
key={`${component.nodeId}:${tileConfigReloads[view.id] ?? 0}`}
@@ -32,6 +47,7 @@ export function AccountViewRenderer({ view, accountId, externalId, projectId }:
projectId={projectId}
accountId={accountId}
externalId={externalId}
+ spanClassName={SPAN_CLASSES[component.span] ?? SPAN_CLASSES[12]}
/>
))}
</div>
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewTile.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewTile.tsx
index a410dc19e938..ba284e8f4719 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewTile.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/AccountViewTile.tsx
@@ -16,6 +16,7 @@ interface AccountViewTileProps {
projectId: number
accountId: string
externalId: string
+ spanClassName: string
}
export function AccountViewTile({
@@ -25,6 +26,7 @@ export function AccountViewTile({
projectId,
accountId,
externalId,
+ spanClassName,
}: AccountViewTileProps): JSX.Element {
const logic = accountViewsLogic({ projectId })
const { tileSaving, tileConfigReloads } = useValues(logic)
@@ -67,7 +69,7 @@ export function AccountViewTile({
]
return (
- <LemonCard hoverEffect={false} className="min-w-0 overflow-hidden p-0">
+ <LemonCard hoverEffect={false} className={`col-span-12 min-w-0 overflow-hidden p-0 ${spanClassName}`}>
<div className="flex items-center gap-2 border-b px-2 py-1">
<span className="min-w-0 flex-1 truncate text-xs font-medium text-secondary">{title}</span>
<LemonMenu items={items}>
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/CustomerAnalyticsAccountScene.stories.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/CustomerAnalyticsAccountScene.stories.tsx
index db3ab87ecf5c..c0c6b7b0146f 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/CustomerAnalyticsAccountScene.stories.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/CustomerAnalyticsAccountScene.stories.tsx
@@ -7,6 +7,7 @@ import { urls } from 'scenes/urls'
import { mswDecorator } from '~/mocks/browser'
import type { CustomPropertyValueWriteApi, AccountRelationshipWriteApi } from '../../generated/api.schemas'
+import { createAccountViewContent } from './accountViewDocument'
const ACCOUNT_ID = '11111111-2222-4333-8444-555555555555'
const EXTERNAL_ACCOUNT_ID = 'spaces %2F slash / ? # + Unicode 漢字'
@@ -27,18 +28,10 @@ const accountView = {
id: ACCOUNT_VIEW_ID,
name: 'Account workspace',
visibility: 'private',
- content: {
- type: 'doc',
- content: [
- {
- type: 'ph-markdown-notebook',
- attrs: {
- nodeId: 'markdown-notebook-v2',
- markdown: '<Notes nodeId="notes" />\n\n<Relationships nodeId="relationships" />',
- },
- },
- ],
- },
+ content: createAccountViewContent([
+ { nodeId: 'notes', kind: 'notes', span: 7 },
+ { nodeId: 'relationships', kind: 'relationships', span: 5 },
+ ]),
text_content: 'Notes\nRelationships',
version: 1,
created_by: 1,
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewDocument.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewDocument.ts
index 83066b1318a3..c4c7364e5cc5 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewDocument.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewDocument.ts
@@ -19,12 +19,13 @@ import { AccountViewContentTypeEnumApi, AccountViewMarkdownNodeTypeEnumApi } fro
export interface AccountViewComponentInstance {
nodeId: string
kind: AccountViewComponentKind
+ span: number
title?: string
config?: AccountViewTileConfig
}
export function createAccountViewComponentInstance(kind: AccountViewComponentKind): AccountViewComponentInstance {
- return { nodeId: uuidv4(), kind }
+ return { nodeId: uuidv4(), kind, span: 12 }
}
export function parseAccountViewContent(content: AccountViewContentApi): AccountViewComponentInstance[] {
@@ -35,6 +36,7 @@ export function parseAccountViewContent(content: AccountViewContentApi): Account
}
const definition = getAccountViewComponentByTag(node.tagName)
const nodeId = node.props.nodeId
+ const span = node.props.span
const title = node.props.title
const config = node.props.config
if (!definition || typeof nodeId !== 'string') {
@@ -44,6 +46,7 @@ export function parseAccountViewContent(content: AccountViewContentApi): Account
{
nodeId,
kind: definition.kind,
+ span: typeof span === 'number' && Number.isInteger(span) && span >= 1 && span <= 12 ? span : 12,
title: typeof title === 'string' && title.trim() ? title : undefined,
config:
config && typeof config === 'object' && !Array.isArray(config)
@@ -65,6 +68,7 @@ export function createAccountViewContent(components: AccountViewComponentInstanc
tagName: getTagName(component.kind),
props: {
nodeId: component.nodeId,
+ ...(component.span === 12 ? {} : { span: component.span }),
...(component.title ? { title: component.title } : {}),
...(component.config ? { config: component.config as NotebookPropValue } : {}),
},
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewsLogic.ts
index 967edbaf0974..f16f5c52a23b 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewsLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountViewsLogic.ts
@@ -208,6 +208,13 @@ export interface accountViewsLogicActions {
setConfigureOpen: (open: boolean) => {
open: boolean
}
+ setEditorComponentSpan: (
+ nodeId: string,
+ span: number
+ ) => {
+ nodeId: string
+ span: number
+ }
setEditorConflict: (conflict: boolean) => {
conflict: boolean
}
@@ -349,6 +356,7 @@ export const accountViewsLogic = kea<accountViewsLogicType>([
deleteViewFailure: true,
deleteViewSuccess: (viewId: string) => ({ viewId }),
setConfigureOpen: (open: boolean) => ({ open }),
+ setEditorComponentSpan: (nodeId: string, span: number) => ({ nodeId, span }),
openConfigure: (config: AccountDetailTabsConfigApi | null) => ({ config }),
setConfigDraft: (config: AccountDetailTabsConfigApi) => ({ config }),
saveConfig: true,
@@ -486,6 +494,12 @@ export const accountViewsLogic = kea<accountViewsLogicType>([
components.splice(toIndex, 0, moved)
return { ...state, components }
},
+ setEditorComponentSpan: (state, { nodeId, span }: { nodeId: string; span: number }) => ({
+ ...state,
+ components: state.components.map((component) =>
+ component.nodeId === nodeId ? { ...component, span } : component
+ ),
+ }),
},
],
editorSaving: [