Repository navigation
Commit 47ee57f
fix(app-shell): the metadata editor page tells its scoped inspector why it is read-only (#29203)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb2ejsWw32Bacu7MBXXjd2HN)_
Fixes #29079
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:元数据编辑页(Setup 的条目页,以及 Studio「全部元数据」下的
`/studio/包/metadata/flow/名称`)现在会把「为什么只读」告诉右侧的节点属性栏。属性栏显示的原因,就是编辑器上方提示条对当前原因说的那句话:只读软件包、锁定、缺少
`manage_metadata` 能力、代码包提供的条目、运行时只读的类型,以及安全目录的隔离墙。没有新增文案。
- **为什么改**:#28985 之后,Studio
自动化页的流程节点属性栏会解释灰掉的控件,但同一个属性栏放在元数据编辑页上时,宿主不传原因,控件仍然灰着却没有任何说明。
- **风险与回滚**:低。只多传一个可选属性
`readOnlyReason`,且只传给按选中项打开的属性栏;可写时不传,渲染与之前相同。未选中时的默认属性栏不变。回滚即还原本 PR。
- **先看**:`ResourceEditPage.tsx` 中 `formReadOnly` 下方新增的
`inspectorReadOnlyReason`(原因的先后顺序与上方提示条一致),以及 `InspectorComponent`
调用处新增的一行。
- **两分钟验证**:在 `ui/` 下运行 `pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/ResourceEditPage.inspectorReadOnlyReason-29079.test.tsx`,预期
6 个测试全绿;去掉调用处那一行后 5 个变红。
- **需要你做的**:无,席位落地。
## What changes
- **`ResourceEditPage` derives `inspectorReadOnlyReason`** next to
`formReadOnly` and passes it to the scoped inspector
(`InspectorComponent`) as `readOnlyReason`, the prop #28985 added to
`MetadataInspectorProps`. The sentence is the one the page's own notice
gives for the cause in force, in the notices' order:
1. the walled security catalog: `engine.catalog.readOnly.walled`;
2. a read-only package (Studio's "All metadata" area):
`engine.studio.pkg.readonlyHint`, the sentence Studio's Automations
pillar passes;
3. a lock: the lock banner's title, then the `lockReason` the server
serves;
4. a declaration-only catalog: its `engine.catalog.declaredOnly.hint`
sentence;
5. a caller without `manage_metadata`: `engine.edit.capabilityReadOnly`;
6. an item a code package ships: `engine.edit.artifactLockedBanner`;
7. a type that is read-only at runtime:
`engine.edit.readOnlyTypeBanner`.
An editable page passes none.
- **No string is new**, so no i18n pack changes: every sentence is an
existing key the page already shows above the editor.
- **The no-selection default inspector is unchanged.**
`MetadataDefaultInspectorProps` declares no `readOnlyReason`, and
widening it is outside this card.
## Deviations
The card asks for three causes on the node inspector: no write access, a
pending walled decision, and view mode pointing at Edit. Measured on
`main` `87d6baef`, only the first can reach the flow node inspector on
this page:
- **Walled** applies only to the security catalog types (`position`,
`permission`, `capability`), and none of them registers a scoped
inspector. The page still names the wall first, so an inspector a host
registers for one of those types gets the right sentence and not the
capability one. The test pins that through a host inspector registered
for `position`.
- **View mode does not reach a scoped inspector.** The inspector renders
only beside a designer canvas. A designer type enters editing as soon as
the item can be written (the designer auto-on effect), stays in editing
after save and reset, and has no Edit button (the Edit button renders
only when there is no preview). A sentence pointing at Edit would point
at nothing, so view mode passes no reason. The seat accepted this shape
before code.
## Tests
- **New: `ResourceEditPage.inspectorReadOnlyReason-29079.test.tsx`, 6
cases.** The real page, gates and `FlowInspector` → `FlowNodeInspector`;
only the canvases (to emit a selection) and the data reads are stubbed.
Each case opens the item, selects on the canvas and reads the accessible
description of the node inspector's reason group:
- a writable flow: no reason group, and Remove node is enabled;
- a read-only package's area, a caller without `manage_metadata`, a
locked item with a served reason, and a flow a code package ships: each
shows its own sentence;
- the walled catalog: a host inspector registered for `position`
receives `readOnly` and the wall's sentence.
- **Red on main:** the same file on `87d6baef` reads 5 failed, 1 passed
(only the writable control passes).
- **Ablation:** deleting the `readOnlyReason={inspectorReadOnlyReason}`
line through `scripts/ablation-replace.mjs` reads 5 failed, 1 passed;
restored, blob equals `HEAD` and `git diff HEAD` is empty.
## Verification
All readings on head `162f85c0`, base `87d6baef`.
<details><summary>Tests</summary>
- `pnpm exec vitest run` (from `ui/`) on
`ResourceEditPage.inspectorReadOnlyReason-29079.test.tsx`: 6 of 6
passed. The same file on `87d6baef`: 5 failed, 1 passed.
- Ablation of the `readOnlyReason={inspectorReadOnlyReason}` line
(`scripts/ablation-replace.mjs`, anchor 1 to 0, blob `9e74e863` to
`5d2abee0`): 5 failed, 1 passed; restored to the `HEAD` blob, `git diff
HEAD` empty.
- Sweep of the 120 ui test files that `git grep` finds naming
`ResourceEditPage`, `MetadataResourceEditPage` or `readOnlyReason`, in
three locked batches at `--maxWorkers=2`: 40/40 files (364 tests), 40/40
(204), 40/40 (547). Narrowed on purpose: CI's Test UI runs the rest of
app-shell.
- `pnpm exec turbo run type-check --filter=@object-ui/app-shell`: 65 of
65 tasks successful.
- `eslint` on the two changed ui files: 0 errors; 51 warnings, the same
count `ResourceEditPage.tsx` carries on `main`, none in the new test.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 34 families;
all 34 ran with exit 0: the 33 unlocked ones with this body as the PR
event (`check-adr-0087-registration`, `check-changeset-no-major`,
`check-closing-keyword-parity` and `check-sdui-manifest` among them),
and `pnpm --dir ui exec vitest run scripts/` locked: 169 files passed, 2
skipped (4,900 tests).
- `dispatch-gates --ran`: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.
- `check:new-line-citations`: 0 new citations.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUgMp6a6PrErVUDx8h)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent e66e309 commit 47ee57f
3 files changed
Lines changed: 281 additions & 0 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 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 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2570 | 2570 | | |
2571 | 2571 | | |
2572 | 2572 | | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
2573 | 2596 | | |
2574 | 2597 | | |
2575 | 2598 | | |
| |||
3490 | 3513 | | |
3491 | 3514 | | |
3492 | 3515 | | |
| 3516 | + | |
3493 | 3517 | | |
3494 | 3518 | | |
3495 | 3519 | | |
| |||
0 commit comments