Repository navigation
Commit 0892a94
fix(app-shell): allowed-visualization chips read the view-type select's words in zh-CN (#30433)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgUUWEuUZxPmGPaLux5Dfpsr)_
domain:ui#2 · os-bill · session_01Utp6Cb5R6JDdfyvtj3dPR2
Fixes #30358
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:中文界面下,视图设置「外观」里的「允许的可视化」选项(chip)改读视图类型下拉框的同一套中文词:表格 /
列表、看板、画廊、日历、时间线、甘特图、地图、图表、树形。两处共用一个取词函数,不会再说两套话。
- 为什么改:中文管理员在 Studio 编辑列表视图时,同一面板上的视图类型下拉已是中文,这排要他勾选的选项却是
Grid、Kanban、Gallery 等英文。
- 风险与回滚:只动 ui 的 metadata-admin 三个文件,不动 spec、服务端、元数据、i18n 词条。英文界面的 9 个
chip 词保持原样(仍是 Grid,不跟下拉的 Table / List),其它非视图类型的多选不变。回滚即 revert 本 PR。
- 先看:`ui/packages/app-shell/src/views/metadata-admin/widgets.tsx` 的
`enumOptionLabel` → `viewTypeLabels.ts`(从 `ViewVariantInspector.tsx`
挪出的取词函数)→ 新测试 `MultiSelectWidget.viewTypeLabels-30358.test.tsx`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/MultiSelectWidget.viewTypeLabels-30358.test.tsx`,预期
3/3 通过(main 源码上 zh-CN 一条失败,读到 Grid…Tree)。
- 需要你做的:无,席位落地。
## What changes
The 允许的可视化 chips (`appearance.allowedVisualizations`) are the
`multiselect` widget in `widgets.tsx`. With no `fieldSpec.options`, it
named each enum value with `humanizeOption(v)` (`grid` → `Grid`) in
every locale. The view-type select a few rows up names the same values
through `typeLabel` in `ViewVariantInspector.tsx` (the
`engine.inspector.view.type.*` keys, then an English fallback map).
- `typeLabel` and its fallback map move to a shared module,
`metadata-admin/viewTypeLabels.ts` (`viewTypeLabel`, `isKnownViewType`).
`ViewVariantInspector` imports it, so the select is unchanged. The
fallback map gains `tree`, the one view type it lacked (the catalog
already has `engine.inspector.view.type.tree` in en and zh).
- The widget names a bare enum's values through `enumOptionLabel`: when
every value is a view type and the console is not en-US, a chip reads
`viewTypeLabel(v, locale)`, the select's own word. Otherwise it keeps
`humanizeOption`.
- **en-US keeps its chip names (the seat's ruling on the card's "en
unchanged").** I kept `humanizeOption` for en-US rather than routing en
through the shared helper with a `grid` override: the en catalog word
for `grid` is "Table / List", so routing en through the helper would
need a per-value exception to keep "Grid". Keeping en on its existing
path is the smaller change and leaves all nine en names byte-identical
by construction. The console's locale is `zh-CN` or `en-US`
(`useMetadataLocale`), so "not en-US" is zh-CN today.
- The widget is told nothing about which field it draws (no field path
in `WidgetProps`), so it recognises the view-type enum by its values,
not by the field's name. A mixed enum (`['grid', 'start_date']`) keeps
the humanised names in zh-CN too, so a list is never half translated.
- No i18n key is added. `fieldSpec.options` labels still win when a form
supplies them.
## Tests
- New `MultiSelectWidget.viewTypeLabels-30358.test.tsx`, over the spec's
real `appearance.allowedVisualizations` JSONSchema (from
`getListVariantSchema()`, not a copied enum) and the shipped `studio`
catalogue:
- zh-CN: the chips equal `t('engine.inspector.view.type.' + v, 'zh-CN')`
for every enum value, in enum order, and none of them is Latin text.
- en-US: the nine chips read `Grid, Kanban, Gallery, Calendar, Timeline,
Gantt, Map, Chart, Tree`.
- zh-CN, mixed enum: `['Grid', 'Start Date']`.
- Red first on main's source (test file only): `Tests 1 failed | 2
passed (3)`. The zh-CN case failed with `expected [ 'Grid', 'Kanban',
'Gallery', …(6) ] to deeply equal [ '表格 / 列表', '看板', '画廊', '日历', …(5)
]`. Both en and mixed passed on main, which pins that they are
unchanged. Green after the fix: `Tests 3 passed (3)`. The red run on
main's source is the ablation leg; the fix is the only source change and
the tests import `src`.
- The changed test plus the files that render the touched code, on the
merged head `6daec651`: the existing `MultiSelectWidget.test.tsx`, four
`ViewVariantInspector.*.test.tsx`, `unknownValueFlag.i18n-9652.test.tsx`
(the select's unknown-type label), and four
`SchemaForm`/`ResourceEditPage` suites that render the multiselect.
`Test Files 11 passed (11)`, `Tests 170 passed (170)`.
- `pnpm exec turbo run type-check --filter=@object-ui/app-shell
--concurrency=2`: `Tasks: 68 successful, 68 total`.
- `eslint` on the four changed ui files: 0 errors (42 warnings, all on
lines this PR does not touch in `widgets.tsx`).
## Live probe
Example CRM (`examples/app-crm`, `objectstack dev --seed-admin --fresh`)
with the branch's console (vite dev). Studio → `crm_activity.all` →
终端用户控制 → 外观 → 允许的可视化, read from the DOM (`[role=group]
[role=checkbox]`):
- zh-CN, main's widget source: `Grid, Kanban, Gallery, Calendar,
Timeline, Gantt, Map, Chart, Tree`.
- zh-CN, this branch: `表格 / 列表, 看板, 画廊, 日历, 时间线, 甘特图, 地图, 图表, 树形`. The
view-type select on the same page reads 表格 / 列表.
- en-US, this branch: `Grid, Kanban, Gallery, Calendar, Timeline, Gantt,
Map, Chart, Tree`.
The card's before-shot path is not in this project's folder, so the
before leg was taken here, on main's widget source.
## Acceptance notes
- On the same zh-CN panel, the labels and help text of the nested
`appearance` / `userActions` keys still read English (`Allowed
Visualizations`, `Show Description`, `Sort`, `Search`, and the
quick-filter element's labels). These come from the spec's `.describe()`
and the metadata-forms catalogs, which this card leaves to the catalog
channel (#30164). Not changed here.
## Verification
<details><summary>Derived gates (dispatch-gates --commands, final tree
`6daec651`)</summary>
- `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:published-files` :: exit 0
- `pnpm check:query-options-erasure` :: exit 0
- `pnpm check:refd-timer-probe` :: exit 0
- `pnpm check:registry-log-declared` :: exit 0
- `pnpm check:rest-log-spy-declared` :: 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
`node scripts/pm/dispatch-gates.mjs --ran`: 35 derived, 35 run, 0
NOT-MEASURED, 0 UNRUN. `check:type-check-debt` ran under the verify lock
(VERDICT command-exit 0). `check:sdui-manifest` (standing ui gate) is in
the list.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZxcXXabvxgwiUDTa3)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3461420 commit 0892a94
5 files changed
Lines changed: 162 additions & 26 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin
- inspectors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | 143 | | |
164 | 144 | | |
165 | 145 | | |
| |||
203 | 183 | | |
204 | 184 | | |
205 | 185 | | |
206 | | - | |
| 186 | + | |
207 | 187 | | |
208 | 188 | | |
209 | 189 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
1709 | 1710 | | |
1710 | 1711 | | |
1711 | 1712 | | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
1712 | 1727 | | |
1713 | 1728 | | |
1714 | 1729 | | |
| |||
1719 | 1734 | | |
1720 | 1735 | | |
1721 | 1736 | | |
| 1737 | + | |
1722 | 1738 | | |
1723 | 1739 | | |
1724 | 1740 | | |
| |||
1733 | 1749 | | |
1734 | 1750 | | |
1735 | 1751 | | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
1739 | | - | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1740 | 1756 | | |
1741 | 1757 | | |
1742 | 1758 | | |
| |||
0 commit comments