Skip to content

feat(database): new-view → customise loop — Group/Fields toolbar peers, richer add-view menu#123

Merged
eliotlim merged 9 commits into
mainfrom
feat/db-view-customise-polish
Jul 11, 2026
Merged

feat(database): new-view → customise loop — Group/Fields toolbar peers, richer add-view menu#123
eliotlim merged 9 commits into
mainfrom
feat/db-view-customise-polish

Conversation

@eliotlim

Copy link
Copy Markdown
Owner

Problem

Creating and customising a database view was buried. Grouping and field visibility lived only inside View options (a settings popover most people never open), so the two most common view tweaks were effectively hidden. The add-view menu was signal-free — a column of icons with no hint of what each layout does or needs. Group-by splintered on free-text property names, and CSV import/export sat mid-config in the toolbar instead of with the database's other actions.

Tracks the Notion epic Epic: Database new-view → customise loop (IA 2026-07). Closes DB-R2 / DB-R5 / DB-R6 / DB-R7 / DB-R8.

Design review (Devon) asked to drop R4's auto-open of View options for unconfigured new views: R1's in-body ViewSetupCard already handles those exact cases with a focused one-click create-and-wire path, and the auto-popover only obscured it. R4's auto-open is removed here in favour of that single in-body surface. The remaining polish items — 2-click grouping and a visible context-menu trigger — are tracked as DB-R9.

Solution

  • R5 — Group / Fields toolbar peers. Promote grouping and field visibility out of View options into Group and Fields buttons beside Filter/Sort, plus a removable Group chip (mirrors Filter/Sort chips). Field visibility is a shared PropertyVisibilityList reused by the toolbar popover and View options, so both stay in lockstep.
  • R2 — categorical-only group-by default. A fresh view defaults its group-by to a categorical (select/status) property rather than any free-text column.
  • R6 — two-line add-view menu. Each layout gets a one-line description and, where relevant, a "Needs a … property" requirement note (now on its own line so it is no longer clipped).
  • R7 — CSV → database context menu. Import/export CSV moved into the database context menu, next to the database's other actions.
  • R8 — sentinel closes the popover + wording. The "+ New … property" sentinels create-and-wire, then close the popover to reveal the configured view; the chart setup card and its sentinel now both say "category".

Key files: DatabaseView.tsx, databaseMenus.tsx, sdk/database.ts, i18n ×4 (en/de/ja/zh). No new dependencies.

Before / After

Behaviour Before After
Toolbar — Group + Fields as peers of Filter/Sort
Only Filter / Sort / View — grouping + fields hidden in View options

Group + Fields sit beside Filter / Sort
Add-view menu — layout descriptions + requirement notes
Bare labels, no signal

One-line description + wrapped "Needs a … property" note
Group chip — grouping reads at a glance, one click to drop Grouping state was invisible unless you reopened View options
Removable chip shows the active group-by
Fields popover — visible-property checklist Column visibility buried in View options
Toggle columns straight from the toolbar

Test procedure

pnpm verify — green: build:libs, typecheck (6 projects), lint, unit test, and test:e2e (server + MCP, 40 checks passed).

DB web e2e (pnpm --filter @book.dev/web exec playwright test), all green:

  • database-view-setup.spec.ts — 8 passed (setup cards + View-options sentinels, reverted to opening View options explicitly and asserting the in-body setup card).
  • database-parity.spec.ts, database-timeline.spec.ts, database-charts.spec.ts, database-context-menu.spec.ts — 55 passed (includes the R5 toolbar group + fields spec).
  • database-charts.spec.ts, database-context-menu.spec.ts, database-map.spec.ts, database-views.spec.ts — 14 passed.

Operational notes

  • No migrations, no new env vars, no new dependencies.
  • R4's new-view auto-open of View options was removed as redundant with R1's in-body setup card (design review). The setup card is the single first-run surface.
  • Deferred → DB-R9: 2-click grouping and a visible context-menu trigger.
  • CSV import/export remains right-click-only in the context menu (pre-existing behaviour, unchanged).

Verify green. Gates: code review ✓ (Quinn, approved); design review ✓ (Devon, after this revision — R4 auto-open dropped, add-view requirement notes un-clipped, stray group chip gated, category wording aligned).

🤖 Generated with Claude Code

https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w

eliotlim and others added 9 commits July 11, 2026 19:20
Boards, bar and pie charts no longer fall back to properties[0] when the
database has no select/status/relation column — they stay ungrouped (a
single "All" group) instead of splintering by an arbitrary text/number
property. Applies to both defaultView (sdk) and the view-options layout
switcher (viewTypePatch).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
addView now returns the created view so DatabaseView can tell whether its
layout defaults found the property it lays rows out by. When they didn't
(a date-less timeline/calendar, a location-less map, a dependency-less
graph, or a chart with nothing to group by), the View options popover —
now controllable, state lifted into DatabaseView — opens right after the
view is added. Configured views and config-free layouts open quietly, so
the timeline canvas-click flows stay clean.

e2e: the view-setup sentinel specs drop their now-redundant explicit
'View options' open click; new spec covers open-vs-quiet both ways.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
- Group button (reuses GroupByPicker, incl. its "+ New select property"
  sentinel which closes the popover once wired); boards get the swimlane
  sub-group picker too.
- Fields button toggles the view's visible properties via the checklist
  extracted from View options into a shared PropertyVisibilityList.
- A removable grouping chip mirrors SortChips so the active grouping is
  visible at a glance and one click to drop (also clears a board's
  sub-group).
- ViewOptionsMenu now shares the groupable/fieldable view-type sets.

i18n: database.toolbar.{group,fields,removeGrouping} in en/de/ja/zh.
e2e: parity spec covers toolbar grouping, chip removal, and field toggling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
Add-view menu items are now two lines — the layout name plus a one-line
hint (mirroring the slash menu) — and layouts that need a property
(timeline/calendar → date, map → location, graph → dependency, charts →
group-by) carry a requirement note. aria-label pins each menuitem's
accessible name to exactly the layout name, so locators stay stable.

i18n: database.addView.{hints,needs}.* in en/de/ja/zh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
…menu

Export CSV / Import CSV are whole-database data actions, not per-view
settings — they now live in the right-click database menu (below New
row) instead of the View options popover. Export still honours the
active view's filters/sorts/search (visibleRows).

e2e: the parity CSV specs drive the context menu (right-click the
toolbar row count) instead of View options.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
…rt setup wording

Choosing a "+ New … property" sentinel in the View options now closes
the popover once the property is created and wired, revealing the
configured view directly (and sidestepping the Escape-after-rerender
quirk). The chart setup card's create button now names the column it
mints — 'Create a Category property and use it' (en/de/ja/zh) — matching
database.setup.names.category.

e2e: the view-setup sentinel specs assert the self-close instead of
toggling the popover shut.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
…ing itself

Two focus races killed the popover right after 'Add view':
- the closing add-view menu returned focus to its trigger a beat after the
  popover opened — a focus-outside dismissal on arrival. The menu no longer
  restores focus on close (onCloseAutoFocus preventDefault), and the View
  options popover ignores focus-outside dismissal outright (pointer-outside
  and Escape still dismiss).

e2e: sync on the popover's own name input (the menu's exit-animation wrapper
made a bare popper-wrapper count pass too early) and wait out the popover
teardown before clicking the Table tab (its Layout grid has a colliding
'Table' button).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
…setup card

Adding an unconfigured view (date-less timeline/calendar, location-less map,
dependency-less graph, group-less chart) auto-popped the View options open over
the view body. But the in-body ViewSetupCard already handles those exact cases
with a focused one-click create-and-wire path, so the auto-popover only obscured
it. Remove the auto-open entirely and make the setup card the single first-run
surface.

Drops the plumbing that only propped up the auto-open: the controlled
open/onOpenChange wiring on ViewOptionsMenu, the popover's onFocusOutside
guard, AddViewMenu's onCloseAutoFocus, and the now-dead viewNeedsSetup helper.
Removing the focus guards also fixes two keyboard-focus nits (focus no longer
gets trapped away from the trigger). Reverts the e2e to opening View options
explicitly and asserting the in-body setup card.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
…p, align category wording

Three view-customise nits from review:

- The add-view menu shared the layout hint and its "Needs a … property" note on
  one truncated line in a w-64 menu, so the requirement note — the most useful
  signal — was always clipped away. Drop the truncate and let it wrap.
- GroupChips rendered with no view-type gate, so switching a grouped board to a
  non-groupable layout (calendar/graph) left a stray, inert grouping chip. Gate
  it on GROUPABLE_VIEW_TYPES to mirror GroupMenu.
- The chart setup card mints a "Category" property, but the group-by "+ New …"
  sentinel still read "select". Align the sentinel to "category" across all four
  locales for cross-surface consistency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app.book.pub Ready Ready Preview, Comment Jul 11, 2026 1:00pm

Request Review

@eliotlim eliotlim merged commit ed59d6a into main Jul 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant