Repository navigation
Commit 0fd2d08
fix(console): a metadata create form says so next to Name when the label cannot fill it (#28366)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoPVve4Xc2Nd78tQUar4agBb)_
Fixes #28232
Refs #28180
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:新建元数据(权限集、视图、流程、页面、动作、钩子、仪表板、文档)时,如果显示名称里没有拉丁字母或数字(例如全中文、全日文),API
名称框下会多一行提示「无法从此显示名称生成名称,请手动输入(snake_case)」;英文界面是 "This label can't be
turned into a name; type one in snake_case."。用户填了名称,这行提示就消失。
- 为什么改:Console
只用显示名称里的拉丁字母和数字自动生成名称;中文或日文名称生成的是空值,名称框空着且必填,旁边却没有任何话说明原因(#28232,从
#28180 拆出的可选半边)。
- 风险与回滚:只加一行提示文字;名称怎么生成、保存怎么校验、服务端都不变。回滚即 revert 本 PR。
-
先看:`ui/packages/app-shell/src/views/metadata-admin/createDerive.ts`(`underivableTargets`:什么时候算「生成不了」);`ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx`(新可选属性
`fieldNotes`,画在字段说明下面);`ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx`(把提示交给两处
`SchemaForm`)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/ResourceEditPage.underivableName-28232.test.tsx`,预期
2 个用例全绿;或在中文界面的 Console 新建权限集,显示名称填「销售运营」,名称下出现这行橙色提示,填入名称后消失。
- 需要你做的:无,席位落地。
## What changes
**When the line shows** (`underivableTargets` in `createDerive.ts`): for
each `createDerive` rule whose transform is `slugify`, the target is
listed when the source holds non-blank text, `slugify` of that text is
empty, and the target is empty. A typed Name drops it at once; clearing
Name again brings it back while the label still gives nothing. `slugify`
itself is unchanged (no transliteration). `useCreateDerive` returns the
list as `underivable` (empty when derivation is suspended, i.e. outside
create mode).
**Where it shows.** `SchemaForm` gains an optional `fieldNotes` prop:
one host-supplied line per top-level field, drawn under the field's help
text in both the flat and the sectioned layouts (and on boolean rows),
never deferred like an issue. `ResourceEditPage` maps `underivable` to
the translated line and passes it to both of its `SchemaForm` call
sites: the create form, and the designer's inspector fallback (the `doc`
type's create page). The hunks sit in the `useCreateDerive` block and on
the two `SchemaForm` prop lists, away from what #28296 moved; `main`
with #28296 is merged in.
**Copy.** New key `engine.create.nameNotDerived` in the `studio`
namespace: en "This label can't be turned into a name; type one in
snake_case.", zh "无法从此显示名称生成名称,请手动输入(snake_case)。" (the form's zh label
for `label` is 显示名称). The namespace ships `en` and `zh` only; the other
eight locales fall back to English there, as for every Studio string.
**Rider from the #28229 review** (help length at `colSpan: 1`): measured
on the live Console (backend `--fresh` + the Console dev server from
this branch, Chromium, permission-set create form) in en and zh-CN at
1280 px and 820 px wide. The help wraps onto a second or third line
(`white-space: normal`, `overflow: visible`, `scrollWidth ==
clientWidth` on the help element) and is never truncated, so nothing
changes there. Screenshots: `en0.png`, `en1.png`, `zh1.png`,
`en-820.png`, `zh-820.png` in the project folder
`ui-seat-1/r2026-10-30/out/28232/`.
## Tests
New:
`ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.underivableName-28232.test.tsx`
(2), the real page with the live registrations
(`registerBuiltinAnchors`) and the real served permission form from
`METADATA_FORM_REGISTRY`:
- (a) an all-Chinese label: exactly one line, in the Name row (not the
Label row), Name empty; typing a Name removes it; clearing Name brings
it back;
- (b) CONTROL: a label with Latin letters fills Name (`Sales 运营` →
`sales`) with no line; a pristine form and a cleared label show none.
**Ablation** (through `scripts/ablation-replace.mjs`, each mutation
proved on disk and restored to the HEAD blob):
- the page hands `SchemaForm` no notes (`underivable.length > 0` → `<
0`) → (a) red, (b) green;
- `underivableTargets` ignores a typed Name (the target-holds-a-value
line deleted) → (a) red at "goes away once a Name is typed", (b) green.
## Acceptance notes
- The object and report designers keep their own Name input in their
curated home panels (`ObjectDefaultInspector`,
`ReportDefaultInspector`), so their create pages do not show this line;
that is outside the order's file surface (the create form and
`createDerive`).
- Seen while measuring, not changed: on the same form with an
all-Chinese label, the page's summary banner already lists Name's two
schema errors in English ("Identifier must be at least 2 characters",
"Identifier must be lowercase snake_case, …") in the zh-CN UI too, and
the second one is cut with an ellipsis at 820 px. That banner text and
its width are not this card's.
- `Clause-②: no` follows the precedent of #28293 (#28179), which added
the optional `SchemaForm` prop `onRequiredRowFieldsChange` under
`Clause-②: no`; `fieldNotes` is the same shape of change. The seat may
judge otherwise.
## Verification
<details><summary>Local runs</summary>
Head `74a406d6` (branch merged with `main` `92120357`, which carries
#28296).
- `OS_SKIP_DTS=1 pnpm turbo run build
--filter='@object-ui/app-shell^...' --filter='!@object-ui/*'` (under the
verify lock) → VERDICT command-exit 0; after the merge, `env -u
OS_SKIP_DTS pnpm turbo run build --filter='@object-ui/app-shell^...'` →
`Tasks: 64 successful, 64 total`.
- `type-check` of `@object-ui/app-shell` and `@object-ui/i18n` (each
`tsc --noEmit` and `tsc -p tsconfig.test.json`) after that dts build →
VERDICT command-exit 0.
- New file alone → `Test Files 1 passed (1)`, `Tests 2 passed (2)`.
- Before the merge, under the verify lock: `pnpm --dir ui exec vitest
run --maxWorkers=2 packages/app-shell/src/views/metadata-admin/
packages/i18n/` → `Test Files 781 passed (781)`, `Tests 8693 passed | 14
skipped (8707)`, VERDICT command-exit 0. After the merge (scoped to the
overlap with #28296): `ResourceEditPage*`, `SchemaForm*`, `createBody*`
and `packages/i18n/` → `Test Files 173 passed (173)`, `Tests 2023 passed
| 13 skipped (2036)`, VERDICT command-exit 0. The whole
`packages/app-shell/` suite was not run locally (CI's Test UI runs it).
- `pnpm --dir ui exec eslint` on the six changed `ts` / `tsx` files → 0
errors (the warnings are on lines this diff does not touch). `pnpm --dir
ui run check:new-line-citations` → 0 new citations, exit 0.
- Live Console: `pnpm --filter @objectstack/example-showcase dev --
--fresh -p 38231` (the root `pnpm dev` preflight refused on unbuilt
`ui/` dist entries the Console dev server does not use) plus
`ui/apps/console` `vite --port 5291 --strictPort` against it; Chromium
via Playwright; servers stopped by their own ports afterwards.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `74a406d6` → 34 commands, each run with
stdin from /dev/null and its exit code captured before any pipe (`pnpm
--dir ui exec vitest run scripts/` under the verify lock: `Test Files
169 passed | 2 skipped (171)`, `Tests 4901 passed | 2 skipped (4903)`).
`--ran` reconcile: `34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN`, exit
0.
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:pm-changeset-deadline-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibzY3yWKQ3Yxq1YdCDq)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 02d6507 commit 0fd2d08
7 files changed
Lines changed: 221 additions & 7 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views/metadata-admin
- i18n/src/namespaces/studio
| 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 | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
| 684 | + | |
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
690 | 696 | | |
691 | 697 | | |
692 | 698 | | |
| |||
3443 | 3449 | | |
3444 | 3450 | | |
3445 | 3451 | | |
| 3452 | + | |
3446 | 3453 | | |
3447 | 3454 | | |
3448 | 3455 | | |
| |||
3470 | 3477 | | |
3471 | 3478 | | |
3472 | 3479 | | |
| 3480 | + | |
3473 | 3481 | | |
3474 | 3482 | | |
3475 | 3483 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1143 | 1143 | | |
1144 | 1144 | | |
1145 | 1145 | | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
1146 | 1153 | | |
1147 | 1154 | | |
1148 | 1155 | | |
| |||
1158 | 1165 | | |
1159 | 1166 | | |
1160 | 1167 | | |
| 1168 | + | |
1161 | 1169 | | |
1162 | 1170 | | |
1163 | 1171 | | |
| |||
1283 | 1291 | | |
1284 | 1292 | | |
1285 | 1293 | | |
| 1294 | + | |
1286 | 1295 | | |
1287 | 1296 | | |
1288 | 1297 | | |
| |||
1309 | 1318 | | |
1310 | 1319 | | |
1311 | 1320 | | |
| 1321 | + | |
1312 | 1322 | | |
1313 | 1323 | | |
1314 | 1324 | | |
| |||
1595 | 1605 | | |
1596 | 1606 | | |
1597 | 1607 | | |
| 1608 | + | |
1598 | 1609 | | |
1599 | 1610 | | |
1600 | 1611 | | |
| |||
1611 | 1622 | | |
1612 | 1623 | | |
1613 | 1624 | | |
| 1625 | + | |
1614 | 1626 | | |
1615 | 1627 | | |
1616 | 1628 | | |
| |||
1712 | 1724 | | |
1713 | 1725 | | |
1714 | 1726 | | |
| 1727 | + | |
1715 | 1728 | | |
1716 | 1729 | | |
1717 | 1730 | | |
| |||
1854 | 1867 | | |
1855 | 1868 | | |
1856 | 1869 | | |
| 1870 | + | |
1857 | 1871 | | |
1858 | 1872 | | |
1859 | 1873 | | |
| |||
1873 | 1887 | | |
1874 | 1888 | | |
1875 | 1889 | | |
| 1890 | + | |
| 1891 | + | |
1876 | 1892 | | |
1877 | 1893 | | |
1878 | 1894 | | |
| |||
2015 | 2031 | | |
2016 | 2032 | | |
2017 | 2033 | | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
2018 | 2039 | | |
2019 | 2040 | | |
2020 | 2041 | | |
| |||
2071 | 2092 | | |
2072 | 2093 | | |
2073 | 2094 | | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
2074 | 2100 | | |
2075 | 2101 | | |
2076 | 2102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
114 | 136 | | |
115 | 137 | | |
116 | 138 | | |
| |||
132 | 154 | | |
133 | 155 | | |
134 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
135 | 162 | | |
136 | 163 | | |
137 | 164 | | |
| |||
178 | 205 | | |
179 | 206 | | |
180 | 207 | | |
181 | | - | |
182 | | - | |
| 208 | + | |
| 209 | + | |
183 | 210 | | |
184 | 211 | | |
185 | 212 | | |
| |||
196 | 223 | | |
197 | 224 | | |
198 | 225 | | |
199 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
200 | 231 | | |
201 | 232 | | |
202 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1716 | 1716 | | |
1717 | 1717 | | |
1718 | 1718 | | |
| 1719 | + | |
| 1720 | + | |
1719 | 1721 | | |
1720 | 1722 | | |
1721 | 1723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1527 | 1527 | | |
1528 | 1528 | | |
1529 | 1529 | | |
| 1530 | + | |
1530 | 1531 | | |
1531 | 1532 | | |
1532 | 1533 | | |
| |||
0 commit comments