On this page
- Status: Accepted; superseded in part by ADR 0019 (shipped 2026-07-25): the hand-written
NAV_TEMPLATE_BINDINGS/TEMPLATE_PLUGIN_GATEmaps and the silentunsupported -> nullaffordance this ADR shipped are gone. S1-S4 strategy stands. - Date: 2026-07-20
- Context owner: Platform
- Related: ADR 0012 (workspace flexibility — this ADR executes its deferred stage 2), ADR 0008 (pillar separation), §21 (widget union), §49 (one metric = one impl), §70/§71/§74, operator directive: 4 frozen English-term dashboards
Context#
The ask: an org admin activates a "Layout Editor" mode and can then edit ANY dashboard/report page — layout, chart/table types, data binding — the way the Custom Dashboard already works.
What exists (audited 2026-07-20):
- A Data-Studio-class saved-dashboard system:
dashboards+dashboard_widgets(JSONB config, Zod discriminated union), react-grid-layout editing, 15 widget types rendering through real@yng/chartsbuilders, per-widget config panel, template lineage columns (templateWidgetKey/origin/templateBaseline/templateVersion) ALREADY in schema, 20 dashboard templates, org blueprints, menu self-service,edit_dashboardcapability. - ONE widget data path:
explore.queryover the metric catalog — 23 eCom metrics only. Marketing (spend/MER/GA4/GSC/leads/email/social), market-intel, and the new social/CRM planes are bespoke routers invisible to widgets. - Built-in report pages are hardcoded RSC views over bespoke routers; no config record backs them, so there is nothing for an editor to edit.
Industry pattern this design follows (Looker/Grafana/Power BI/Notion-class): pages are documents over a semantic layer; vendor pages are versioned templates; orgs edit forks in place; the vendor keeps an upgrade path. Retrofitting an editor onto code-rendered pages is the known dead end (two rendering paths per page, permanent parity tax) — the winning move is to widen the semantic layer until the document model can EXPRESS those pages, then re-point navigation at template instances.
Decision (staged; each stage independently shippable)#
S1 — Pillar-aware semantic layer (the enabler)
Extend the metric catalog with pillar: 'ecom' | 'marketing' | 'social' | 'crm'.
explore.query dispatches per pillar to ONE resolver per metric that WRAPS the existing
router/SQL implementations (§49 — never a second derivation): e.g. marketing.mer,
marketing.ad_spend, crm.leads_count, crm.mql_rate, social.buzz_volume,
social.mentions_count. New dimensions ride the same shape: channel, campaign,
lead_source, lead_stage, trend_topic, mention_platform. A metric×dimension pair the
resolver cannot honestly answer returns [] (§32 — never fabricated).
S2 — Dataset widgets (tables and lists)
A fourth dataSource: 'dataset' union member for bounded, schema-declared tabular surfaces
(top mentions, lead lists, trend ranking board). Each dataset = a registered server-side
definition (columns, filters, hard row cap, PII mask policy §44) — the widget stores only the
dataset key + display options. No arbitrary SQL, no arbitrary tRPC.
S3 — System pages become template instances ("born editable")
New surfaces (CRM lead center, Social Trend) ship as SYSTEM DASHBOARD TEMPLATES + an org
instance provisioned by blueprint; the nav item points at the org's instance. The org admin
edits it exactly like any saved dashboard; templateBaseline powers "Hoàn tác về mẫu" (reset
to template) and vendor upgrades ship as template version bumps with the existing
TemplateUpdateBanner. Legacy bespoke pages migrate ONE AT A TIME (overview-parity order per
ADR 0012), each only after S1 covers its numbers. The operator-frozen 4 (Home/SKU/Creator/
Livestream Performance) NEVER migrate without explicit operator direction.
S4 — The editing mode UX
- Entry: org admin (capability
edit_dashboard) sees a pencil affordance in thePageHeaderof any template-instance page → toggles "Chỉnh sửa bố cục" (same in-place grid editing as saved dashboards — direct manipulation, no separate builder app). A global toggle in Settings ("Chế độ chỉnh sửa") merely pre-arms the affordance; editing is always per-page and explicit. - Edit surface: existing drag/resize grid + widget picker + per-widget config panel, extended with pillar/dataset pickers from S1/S2. Nothing new to learn — the Custom Dashboard IS the editor.
- Safety rails: changes save as the org's fork (never mutate the vendor template);
role-visibility unchanged (§47 — nav hiding is not enforcement);
report_viewerroles see the same page, never the editor; §70 title rules apply to template titles via i18n keys; §71 stays intact because instances use the dashboard FilterBar which is already a grandfathered consumer. - S3+S4 delivery deviation (2026-07-21): the global Settings "Chế độ chỉnh sửa" pre-arm
toggle is DEFERRED — editing is entry-per-page (the pencil "Chỉnh sửa bố cục" affordance on a
template instance), which is sufficient without a global switch. Instance titles are bilingual
registry LITERALS materialized per-locale by
installTemplate(still §70-clean — no hardcoded English in JSX, no new i18n title keys). Defense-in-depth added beyond the entry UX: a page-levelrequirePlugingate on gated template instances (§47), so a direct URL to an instance fails closed when its owning plugin is off.
Non-goals
Free-form HTML/JS widgets; per-user (as opposed to per-org) page forks; editing genuinely transactional surfaces (connector config, admin, settings); a second data-binding path bypassing the catalog/dataset registries.
Consequences#
- The platform converges on ONE page model: registry-defined templates + org forks over a governed semantic layer. New "pages" become template authorship, not React work.
- Cost concentrates in S1 — every pillar metric wrapped for
explore.queryneeds the same reconciliation discipline as its source router (§53 assertions extend to widget-path results: widget sum == bespoke page sum for the same window). - Until a page migrates, it simply doesn't show the pencil — the mode degrades gracefully, no dual rendering ever exists.
- MVP order (this programme): S2 dataset widgets for the NEW social/CRM surfaces + S3 for those two pages; S1 marketing coverage next; legacy migrations after.