Repository navigation
Commit dad9b55
feat(console): create a dashboard from the design mode's Add menu item (#36606)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi93yJM5eSHAibimwWb6xCgvP)_
Part of #36364
Clause-②: yes (widening) — new `@object-ui/i18n` keys
(`designMode.menu.*` for the new picker row and name step,
`dashboard.noCards.*`), in all 11 locales; no spec, schema or public
export change
Metadata-protocol: none
repo:objectstack#2 · os-steve · session_01ADHkmPiTdmLxHXBjakSvJy
## 维护者速读
- 用户能看到什么变化:管理员在设计模式里「添加菜单项 →
仪表盘」,第一行是「新建仪表盘…」,填名称确定后,新仪表盘出现在占好的菜单位置,其他改动一起保存,然后直接进入它的编辑状态;没有卡片的仪表盘会显示「还没有卡片」。
- 为什么做:设计模式专题的第三张卡,让管理员不用进 Studio 就能在应用里新建仪表盘并挂到菜单上。
- 出错会怎样:菜单保存失败时,刚建的仪表盘会被删掉,设计模式保持打开并说明原因;中途取消什么都不写;可以直接撤回本次合并。
- 要你做什么:不用做什么。新建报表这一半席位已定(报表必须先选数据集和指标,改为从报表搭建页新建),等 #36374 合并后另做。
## What changes
- The design-mode picker's Dashboards list starts with 「New dashboard…」
(`DesignModeMenu.tsx`). It asks for a name only. 「Cancel」 (or closing
the dialog) writes nothing and drops the held place.
- 「Create」 runs, in order (`designModeMenuCreate.ts`): every check of
the menu save first (`prepareAppMenuSave`, split out of `saveAppMenu`
unchanged in behaviour); the dashboard created empty (`{ name, label,
widgets: [] }`) and published in the menu's own package (the app's
package when listed writable, else its `.custom` pair via the ensure
door; ADR-0146 D2, #35624 ruling C) through the existing confirmed-save
door `saveDashboardInPlace`; then the menu written and published with
the new entry in the held place and every other staged menu edit
(`writeAppMenu`). Where the menu cannot be saved, nothing is created: no
package-less fallback.
- A refused menu removes the dashboard again (the item DELETE with
`?package=`, measured on a live server: `Deleted dashboard ... it no
longer exists`). If that removal is refused too, the error says the
dashboard was left.
- The design mode gains `saveWith(key, change)` (`designMode.tsx`):
commit everything staged with one change in its key's place, never
staging it on its own, so a failed create leaves no half-written entry
staged for a later Save.
- The machine name is generated from the name (Chinese through pinyin),
and checked free on the server (`GET /meta/dashboard/:name`) so a create
never publishes over an existing dashboard.
- On success the mode is left and the page navigates to the dashboard
with a one-time navigation-state landing (`designModeArrival.ts`);
`DashboardView.tsx` opens its #36372 edit state on that landing once the
Edit button is offered, and clears it.
- A dashboard with no cards now draws 「No cards yet」 instead of a blank
canvas (view mode only).
- **Not in this PR: 「New report…」.** The spec refuses a report without
`dataset` + `values`, and the server's draft save refuses it too
(`INVALID_METADATA`, measured), so a name-only report cannot be created.
The seat's premise correction on the card (comment 7090058961) settles
it: 「New report…」 opens the report builder (#36374) in a create mode and
writes the report and its menu entry once a dataset and a measure are
picked; that half follows after #36374 merges.
Branch name: this card thread's container pushes only to
`claude/project-thread-un7cwb`, so the `claude/issue-36364-*` spelling
the Duplicate Fix Guard looks for is not available; the card is #36364
(claim comment 7088329990).
Overlap: touches `DashboardView.tsx`, which draft PR #36461 also
touches; `overlap-check` reads both merging cleanly. This PR lands after
#36461 per the claim.
## Tests
<details><summary>Unit and component tests (head 313b6bf)</summary>
Run from the repo root under `os-verify-lock`; vitest root `ui/`.
- Head `313b6bf8` merges `origin/main`, bringing #36604 (the
`designModeMenu.ts` rename to `designModeMenuModel.ts`), #36622
(#36591's menu `order` rule) and #36461. The one conflict, in
`DesignModeMenu-36363.test.tsx`, was resolved by keeping both sides:
this card's `server` mock, its reset and its describe, next to #36591's
`servedNav` and its describe. Two imports were moved to the renamed
module (`designModeMenuCreate.ts` and its test); no file names the old
module any more. #36591's `inShownOrder` / `withOrderRewritten`
auto-merged into `prepareAppMenuSave`, so the create path applies the
same rule. It is pinned by a new test: the new entry, held between two
entries of an `order`-carrying level, is saved as `[customer 0,
nav_item_1 1, contact 2, opportunity 3]`.
- At `313b6bf8`, after rebuilding the app-shell dependency closure
(`VERDICT command-exit 0`): `pnpm --dir ui exec vitest run
--maxWorkers=2 packages/app-shell/src/layout/ packages/i18n/` plus the 9
`packages/app-shell/src/views/DashboardView*.test.tsx` files gives `Test
Files 271 passed (271)`, `Tests 3301 passed | 13 skipped (3314)`,
`VERDICT command-exit 0`. This covers the 4 card files and every
layout/i18n/DashboardView test the merge touched.
- At `313b6bf8`: `designModeMenuCreate-36364.test.ts` alone gives `Tests
14 passed (14)`.
- At `313b6bf8`: `pnpm --dir ui --filter @object-ui/app-shell --filter
@object-ui/i18n run type-check` (both `tsc --noEmit` and
`tsconfig.test.json`) gives `VERDICT command-exit 0`, 0 `error TS`.
- Earlier, at `ab2257f4`: the i18n run plus the 4 card files gave 110
files and 2050 tests passing. At `0647077c`, a narrowed app-shell + i18n
run found 3 failures caused by this change: zh-Hant was not regenerated,
and the de quote count was 125 against 126. Both were fixed. The full
app-shell suite is left to CI's `Test` shards.
- New and extended pins:
- `designModeMenuCreate-36364.test.ts`: 14 tests (13, plus the `order`
pin).
- `DesignModeMenu-36363.test.tsx`: 4 tests (the create row, Cancel
writes nothing, the create-and-land flow, a refused menu).
- `designMode-36362.test.tsx`: 3 tests for `saveWith`.
- `DashboardView.inPageEdit-36372.test.tsx`: 3 landing tests and 2
empty-state tests.
</details>
<details><summary>Ablations (one-shot, not kept)</summary>
- Removal of the created dashboard on a refused menu deleted
(`ablation-replace`, anchor 1 to 0, restored blob equals HEAD): 3 tests
red (`a refused menu removes the dashboard it was made for…`, `…cannot
be removed says the dashboard was left`, `a refused menu removes the new
dashboard; the mode, the held place and the other staged edits stay`).
- The dashboard created before the menu-save checks: 8 of 13 red in
`designModeMenuCreate-36364.test.ts`, every "nothing is created" case
among them. A first attempt of this leg was refused by the tool (the
replacement contained its own anchor) and ran no tests; the second
attempt is the reading above.
</details>
## Acceptance notes
- The card's first acceptance line names the group 「数据洞察」; the CRM
example's group is 「数据分析」, used for the screenshots.
- 「Members see an empty state」 was checked as the admin in view mode;
the empty-state branch has no role gate. A non-admin session was NOT
MEASURED.
- Test pins went into the existing harness files for the design mode,
the menu editor and the dashboard in-page edit (AGENTS.md: a new pin for
a component with a shared harness goes into that file), plus one new
file for the new module, `designModeMenuCreate-36364.test.ts`.
## Verification
Screenshots (live CRM example on a `--fresh` backend, console dev
server, zh-CN, deviceScaleFactor 2) are stored with the seat
(`objectstack-seat2/36364-shots/`): design mode; picker 「仪表盘」 with
「新建仪表盘…」 first; the name step; the new 「回款分析」 in its edit state, in the
held place under 数据分析; Cancel leaving nothing; the new dashboard in view
mode (「还没有卡片」); Studio 「界面」 listing the same 回款分析 in the app's
navigation. After the run: the dashboard is the only item of
`com.example.crm.custom`, the app's stored menu holds `nav_item_1:
hui_kuan_fenxi` under `group_analytics`, no draft is pending, and the
cancelled name has no item (404).
Read first: `ui/packages/app-shell/src/layout/designModeMenuCreate.ts`
(the order and the removal), `designMode.tsx` (`saveWith`'s drop rule
after a commit), `DashboardView.tsx` (the landing effect).
Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/designModeMenuCreate-36364.test.ts`
shows 14 passing.
<details><summary>Derived gates (head ab2257f)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 41 commands from the tree at commit
ab2257f. Each was run with stdin from /dev/null, and its exit code was
captured before any pipe. The two heavy commands ran under
`os-verify-lock`: `pnpm --dir ui exec vitest run scripts/` and `pnpm
check:type-check-debt`.
- All 41 exited 0. The reconciliation with `--ran` reads: `Run
reconciliation — 41 derived, 41 run, 0 NOT-MEASURED, 0 UNRUN.`
- The record is stored with the seat
(`objectstack-seat2/36364-gates-ran.txt`).
- Before the PR was opened, `overlap-check` gave `VERDICT clean exit 0`
against origin/main and the open PR heads.
- At `313b6bf8`, `dispatch-gates --commands` derives the same 41
commands as at `ab2257f4`. The merge brought no new gate family for the
touched paths, so the run above was not repeated. At push,
`overlap-check` against origin/main is clean; it conflicts with open PR
#36629 on the serial de quote-count pin, and whichever lands second
rebumps it.
- CI families (lint farm, `Test` shards, `Test Core`) are left to this
PR's check-runs; none was rerun locally.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPiTdmLxHXBjakSvJy)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmPiTdmLxHXBjakSvJy -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f590f3e commit dad9b55
23 files changed
Lines changed: 1096 additions & 20 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- layout
- __tests__
- views
- i18n/src
- __tests__
- locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
| |||
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
52 | | - | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| |||
150 | 158 | | |
151 | 159 | | |
152 | 160 | | |
| 161 | + | |
| 162 | + | |
153 | 163 | | |
154 | 164 | | |
155 | 165 | | |
| |||
362 | 372 | | |
363 | 373 | | |
364 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
365 | 420 | | |
366 | 421 | | |
367 | 422 | | |
| |||
467 | 522 | | |
468 | 523 | | |
469 | 524 | | |
| 525 | + | |
470 | 526 | | |
471 | 527 | | |
472 | 528 | | |
| |||
754 | 810 | | |
755 | 811 | | |
756 | 812 | | |
| 813 | + | |
757 | 814 | | |
758 | 815 | | |
759 | 816 | | |
760 | 817 | | |
761 | 818 | | |
762 | 819 | | |
| 820 | + | |
| 821 | + | |
763 | 822 | | |
764 | 823 | | |
765 | 824 | | |
766 | 825 | | |
767 | 826 | | |
768 | 827 | | |
769 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
770 | 846 | | |
771 | 847 | | |
772 | 848 | | |
| |||
854 | 930 | | |
855 | 931 | | |
856 | 932 | | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
857 | 946 | | |
858 | 947 | | |
859 | 948 | | |
| |||
885 | 974 | | |
886 | 975 | | |
887 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
888 | 1057 | | |
889 | 1058 | | |
890 | 1059 | | |
| |||
0 commit comments