Repository navigation
Commit f558e14
fix(app-shell): a locked metadata item's designer canvas is read-only (#27035)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8TMV42aHkwWJ3enBd3HQn32)_
Fixes #26888
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:Setup 元数据编辑页对"不可写"的条目(被包锁定,或调用者无权编写)不再把 onPatch 交给设计器画布,画布随之只读。
- 为什么改:锁定对象的画布仍可加字段、移动/删除分区并显示"Unsaved",但页面没有保存按钮,离开即静默丢失。
- 风险与回滚:只改一个 prop;可写条目行为不变。回滚即还原该 prop,无数据或协议影响。
- 先看:ResourceEditPage.tsx 中预览组件的 onPatch 三元表达式;其次新测试文件
lockedCanvas-26888。
- 两分钟验证:pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/ResourceEditPage.lockedCanvas-26888.test.tsx,预期
2 passed。
- 需要你做的:无,席位落地。
## What changes
`MetadataResourceEditPage` passes the registered designer preview
`onPatch={readOnly ? undefined : …}` instead of an unconditional
`onPatch`. `readOnly` is the page's existing `!canWrite && !createMode`,
so it covers a locked item (`layered.editable === false`), a caller
without `manage_metadata`, and a walled catalog. Per the preview
contract (`MetadataPreviewProps.onPatch`), a canvas with no `onPatch` is
read-only; `ObjectFormCanvas` derives `readOnly = !onPatch`, which hides
Add field, Add section, Add field to this section, Move section up/down
and Remove section. This mirrors Studio's read-only package handling
(objectui#11136, `onPatch={readOnly ? undefined : onPatch}` in
`StudioDesignSurface`). The fix is at the page, so every Setup designer
type goes read-only on a locked item, not only Object;
`ObjectPreview.tsx` needed no change.
The Description box (`ObjectDefaultInspector`) was already
`disabled={readOnly}` through the page's `formReadOnly`: measured,
already done.
## Tests
New `ResourceEditPage.lockedCanvas-26888.test.tsx` mounts the real page
with the built-in designers registered:
- control: a writable object shows Add field, Add field to this section,
Move section up/down, Remove section;
- a locked object (`editable: false`, `lock: 'full'`) shows the lock
banner, none of those controls, and no "Unsaved".
Ablation (restore the unconditional `onPatch` via
`scripts/ablation-replace.mjs`, anchor hit 1 → 0, blob 6cd1fb3 →
256b0123): the locked case goes red (the found Move/Remove BUTTON list
did not deeply equal `[]`), control stays green; restore verified blob
== HEAD and `git diff HEAD` empty.
## Acceptance notes
- None.
## Verification
All local readings on head `a512197f` (base `7eb613c3`).
- Closure build `pnpm --workspace-concurrency=2 --filter
'@object-ui/app-shell^...' build` under the lock: exit 0 (6m16s).
- New test: 2/2 passed. Nearby suites `ResourceEditPage*` +
`ObjectFormCanvas`: 44 files, 224 tests passed.
- `pnpm --filter @object-ui/app-shell run type-check`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands`: 34 derived families,
all exit 0; `--ran` reconciliation: 34 run, 0 NOT-MEASURED, 0 UNRUN.
Includes `node scripts/check-sdui-manifest.mjs` and `pnpm --dir ui exec
vitest run scripts/` (176 files passed, 2 skipped).
- Also run: `pnpm check:changeset-fixed` (roster under `.changeset`)
exit 0; `pnpm --dir ui run check:new-line-citations` exit 0.
- Type-check lanes, artifact rosters and wide-population families: left
to this PR's CI check-runs.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbajUhBue1th6Leba9E)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5866877 commit f558e14
3 files changed
Lines changed: 163 additions & 2 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3081 | 3081 | | |
3082 | 3082 | | |
3083 | 3083 | | |
3084 | | - | |
3085 | | - | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
3086 | 3095 | | |
3087 | 3096 | | |
3088 | 3097 | | |
| |||
0 commit comments