Repository navigation
Commit ff60149
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_
repo:objectstack#7 · zhuangjianguo · session_01QsR2jSr8sNCnJrK6Q9kEF5
Fixes #36362
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:有权设计应用的管理员(工作区管理员、具备元数据管理权限、应用所在的包可写)在页头点「编辑应用」后,不再跳转到
Studio,而是在当前应用里进入设计模式:窗口顶部出现一条横栏,只有「设计模式」「取消」「保存」;切换到同一应用的其它页面时模式保持,换应用或在手机上不出现;进入后侧边栏不再显示个人收藏。只读包(例如已安装的应用)仍然是原来的「在
Studio 中查看」入口。
-
为什么做:这是「运行时设计模式」这条线的第一张卡,先把模式本身和统一的保存/取消机制立起来,后面的菜单编辑、页头按钮固定、从菜单新建仪表盘/报表都挂在它上面;这一版本身还没有任何可改的内容,所以「保存」一直是灰的。
-
出错会怎样:最坏情况是管理员进入设计模式后看到横栏却无事可做,点「取消」即可退出;模式不写任何数据,不影响普通成员,改动只在界面层,可直接撤回。
- 要你做什么:无。另有一个后续问题已交给席位:已安装的只读应用目前进不了设计模式(与原先进不了 Studio
编辑一致),下一张卡(菜单编辑)若要覆盖已安装应用,需要让这类应用也能进入,届时由席位提出。
## What changes
「Edit app」 in the page header no longer opens Studio for an
administrator who may design the app (`useAppStudioEntry`'s `edit`
posture: workspace admin, `manage_metadata`, writable package). It turns
on the shell's **design mode** for the app on screen, in place.
- **The mode** (`layout/designMode.tsx`) is held by `ConsoleLayout` for
the app it was entered in: it survives moving between pages of that app,
goes off (and drops what it held) when the app changes, and is never
drawn on a phone (`enabled: false` hides it and keeps what is staged).
It has no address; no URL enters it.
- **The bar** (`layout/DesignModeBar.tsx`) is drawn in the AppShell's
top slot, across the window, while the mode is on: 「Design mode」 at its
left, 「Cancel」 and 「Save」 at its right, nothing else. 「Save」 is off
while nothing is staged. On desktop the sidebar sits below the bar while
it is shown, and the page header hides its 「Edit app」 button.
- **The extension point** `useDesignModeChange(key)`: a surface stages a
change under a key together with its own `commit`. 「Save」 commits every
staged change in the order first staged, then leaves; a failed commit
stops there, keeps it and every later change staged, keeps the mode on
and toasts the reason. 「Cancel」 drops all and commits none. Outside the
mode nothing can be staged. This PR stages nothing yet; #36363, #36366
and #36364 build on it.
- **Leaving with something staged** goes through the existing
unsaved-edits seam (`chrome/unsavedEdits.ts`), which gains an optional
`keeps(url)` per registration: a link to another page of the same app
does not ask (the mode goes along), a link out of the app and the app
switcher ask, and a tab close or reload is held by the browser prompt.
- **The sidebar in design mode** shows the app's own menu only: the
Favorites section and its pin buttons are off, so the menu under edit is
the app's, not the person's.
- A read-only package's app keeps its eye entry 「Open APP in Studio」
unchanged; a member sees no entry, as before.
- New i18n keys `designMode.title`, `designMode.leaveUnsaved`,
`designMode.saveFailed` in every hand-written locale, zh-Hant generated.
Read first, by risk:
1. `ui/packages/app-shell/src/layout/designMode.tsx` — the save loop
(order, stop-on-failure, re-staged-while-sending) and the app-change
reset.
2. `ui/packages/app-shell/src/chrome/unsavedEdits.ts` — `keeps` only
narrows the click guard; `confirmUnsavedLeave` and `beforeunload` still
ask for every registration.
3. `ui/packages/app-shell/src/layout/ConsoleLayout.tsx` /
`UnifiedSidebar.tsx` — the header slot and the sidebar offset while the
bar is on.
## Tests
- New `layout/__tests__/designMode-36362.test.tsx`: the bar's contents;
「Save」 off until something is staged; commit order and exit; a failed
commit keeps it and later ones, keeps the mode, toasts; 「Cancel」 commits
none; nothing staged outside the mode; another app drops it; a phone
hides it and keeps what is staged; `beforeunload` held only while
staged; an in-app link asks nothing, a link to Home asks; `isPageOfApp`
with a basename.
- `ShellPageActions-36111.test.tsx`: in the `edit` posture 「Edit app」 is
a button (not a link) that enters the mode and is hidden while it is on;
a member sees nothing; the read-only eye entry is unchanged.
- `UnifiedSidebar.favoritesMenu-12427.test.tsx`: the Favorites section
is hidden in design mode and back after.
- `unsavedEdits-13231.test.tsx`: the `keeps` option skips only the
registrations that keep the URL.
- `consoleTopBar.height-12639.test.ts`: the two source pins admit the
design mode's arm (same slot, same 48 px; the sidebar below it on
desktop).
<details><summary>Readings at d78b61b</summary>
- The touched test files: 57/57 passed; `consoleTopBar.height-12639`:
12/12 passed.
- Related-test sweep (every test file naming `ConsoleLayout`,
`UnifiedSidebar`, `ShellPageActions`, `unsavedEdits` or `designMode`,
184 files in 4 batches): 1,654 passed; the 2 reds (the top-bar source
pins above) fixed in d78b61b and re-run green.
- Ablation (the `keeps` check disabled in `unsavedEdits.ts`): 3 tests
red; restored, `git status` clean.
- `turbo type-check` for `@object-ui/app-shell` and `@object-ui/i18n`:
70/70 tasks green. `pnpm build`: exit 0.
- `dispatch-gates.mjs --commands` derived 41 gates, all exit 0; `--ran`
reconciliation: 41 derived, 41 run, 0 not measured.
- `overlap-check.mjs`: origin/main and 8 open PRs sharing files (#36391
shares `ConsoleLayout.tsx` and `UnifiedSidebar.tsx`; the rest share
locale files) all merge cleanly.
</details>
## Acceptance notes
- **Reach.** The mode is entered from the `edit` posture only, the gate
「Edit app」 always had. Apps in read-only packages (the showcase, apps
installed from the marketplace) show the eye entry and cannot enter the
mode. #36363 asks that installed apps' menus be editable through the
customization layer; that needs the read-only posture to enter the mode
too, and is raised with the card's seat rather than decided here.
- The header's crowding (#36201) is not addressed here: the mode only
hides 「Edit app」 while it is on.
- No docs page describes 「Edit app」 (`content/docs` has none), so no
docs change.
## Verification
Live run against a fresh local backend and the console (Vite), signed in
as the seeded admin, on an app in a newly created writable package, at
1280 px and 1440 px: 「Edit app」 is shown in the page header; pressing it
draws the bar (`Design modeCancelSave`, 「Save」 off), the sidebar moves
below it; moving to another page of the app keeps the bar; 「Cancel」
removes it and 「Edit app」 comes back. Screenshots of both states at both
widths are in the project files at `repo-objectstack-7/shots/36362/`
(`before-1280.png`, `before-1440.png`, `design-1280.png`,
`design-1440.png`).
The card's 「PR 正文附截图」 is met by those files: a cloud container cannot
upload images to the PR.
Two minutes: as a workspace admin, open an app in a package you created
in Studio, press 「Edit app」 in the page header: the blue bar appears
with 「Cancel」 and a disabled 「Save」; open another page from the sidebar:
the bar stays; press 「Cancel」: the bar goes and 「Edit app」 is back. Open
an installed app: the header still offers 「Open APP in Studio」.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jSr8sNCnJrK6Q9kEF5 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent fb6eb80 commit ff60149
23 files changed
Lines changed: 927 additions & 32 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- chrome
- layout
- __tests__
- i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| |||
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
74 | | - | |
| 86 | + | |
| 87 | + | |
75 | 88 | | |
76 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
81 | | - | |
82 | | - | |
| 97 | + | |
| 98 | + | |
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
90 | 106 | | |
91 | 107 | | |
92 | | - | |
93 | | - | |
94 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
95 | 111 | | |
96 | 112 | | |
97 | | - | |
98 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
99 | 116 | | |
100 | | - | |
| 117 | + | |
101 | 118 | | |
102 | | - | |
103 | 119 | | |
104 | 120 | | |
105 | 121 | | |
| |||
110 | 126 | | |
111 | 127 | | |
112 | 128 | | |
113 | | - | |
114 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
115 | 134 | | |
116 | 135 | | |
117 | 136 | | |
| |||
133 | 152 | | |
134 | 153 | | |
135 | 154 | | |
136 | | - | |
137 | | - | |
| 155 | + | |
| 156 | + | |
138 | 157 | | |
139 | 158 | | |
140 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| 263 | + | |
258 | 264 | | |
259 | 265 | | |
260 | 266 | | |
| |||
271 | 277 | | |
272 | 278 | | |
273 | 279 | | |
274 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
275 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
276 | 288 | | |
277 | 289 | | |
278 | 290 | | |
| |||
281 | 293 | | |
282 | 294 | | |
283 | 295 | | |
| 296 | + | |
284 | 297 | | |
285 | 298 | | |
286 | 299 | | |
| |||
371 | 384 | | |
372 | 385 | | |
373 | 386 | | |
| 387 | + | |
374 | 388 | | |
375 | 389 | | |
376 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
207 | 214 | | |
208 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
209 | 224 | | |
210 | 225 | | |
211 | 226 | | |
| |||
226 | 241 | | |
227 | 242 | | |
228 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
229 | 261 | | |
230 | 262 | | |
231 | 263 | | |
| |||
261 | 293 | | |
262 | 294 | | |
263 | 295 | | |
| 296 | + | |
264 | 297 | | |
265 | 298 | | |
266 | 299 | | |
267 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
268 | 303 | | |
269 | 304 | | |
270 | 305 | | |
| |||
0 commit comments