Repository navigation
Commit 91e4652
fix(console): a served form row marked required holds Save when left empty (#28293)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao7dmZQQ1tpabFMJS1Pf1uTi)_
Fixes #28179
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:元数据新建/编辑页现在认服务端表单行上的 `required: true`:这类行留空时,该字段下显示「This field is
required.」,点保存不发请求;适用于所有元数据类型,不是权限集特例。
- 为什么改:#28152 之后新建权限集的「Label」带必填星号,但 `PermissionSetSchema.label`
仍是可选,页面只按 Zod 校验、服务端也接受,所以留空照样保存成功,星号只是装饰。
- 风险与回滚:只拦表单当前提供且可编辑的行(隐藏、只读、谓词隐藏的行不算),作者总能填上解锁;schema
自己要求的字段维持原判定,服务端接受集不变;回滚即 revert 本 PR。
-
先看:`ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx`(`requiredRowIssues`
与 `doSave` 中紧随 Name 拦截的那段),`SchemaForm.tsx`(`SectionedSchemaForm` 的
`visibleFields` /
`requiredRowKey`),`ResourceEditPage.requiredRow-28179.test.tsx`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/ResourceEditPage.requiredRow-28179.test.tsx`,预期
3 个用例全绿;或在 Console 设置 › 权限集 › 新建,只填 Name 点保存,Label 下出现必填提示且没有保存。
- 需要你做的:无,席位落地。
## What changes
- **`SchemaForm`** gains an optional `onRequiredRowFieldsChange(fields)`
prop. `SectionedSchemaForm` reports the top-level rows it offers whose
served row says `required: true`: in a visible section (collapsed
sections and other tabs count), not hidden, with a schema property, and
editable (not `readonly`, not `immutable` outside create, not a
read-only form). The row visibility filter is now one local function
(`visibleFields`) that the rendered rows, the tab list and this report
all read, so the hold and what is on screen cannot disagree. The
callback is keyed on the joined field names, never on an array identity,
and reports an empty set on unmount. Any non-sectioned face reports
nothing.
- **`ResourceEditPage`** keeps those fields beside the existing
`inlineIssueFields` state and derives `requiredRowIssues` from the
draft: a reported field that is empty (absent, null, blank string, empty
array) is a located issue with the new `engine.validation.fieldRequired`
message. It is skipped where the served schema already requires the
field (that field keeps its own verdict) or gives it a default. The
issues join `displayIssues`, and `doSave` returns before any request
while one stands, right after the existing Name hold, on create and on
edit.
- **i18n**: `engine.validation.fieldRequired` in the studio `en` and
`zh` packs (the only two the namespace ships), one block each.
## Why
A served form row's `required` is a layout override
(`FormFieldSchema.required`, "Required override"). PR #28152 made the
permission set's Label row required while `PermissionSetSchema.label`
stays `z.string().optional()`, so the live Zod pass, the save-time
checks and the server all accepted an empty Label: the star was the only
thing that said otherwise.
Why this predicted verdict may hold Save when the live Zod pass may not:
the advisory ruling at `blockingReport` guards against a client stricter
than the server dead-bolting a draft the author cannot fix. Only rows
the form on screen offers and lets the author edit report, so the author
can always fill what holds the save, the same bound the Name hold
(#27865) relies on.
## Tests
- `ResourceEditPage.requiredRow-28179.test.tsx` (real page, real
`MetadataClient` over an in-memory server, real served form from
`METADATA_FORM_REGISTRY.permission`):
- (a) New Permission Set, Label empty, Name `sales_ops`, Save: the
inline issue is on the Label row and nowhere else, no `PUT` leaves;
typing a Label clears it and Save sends `{ name: 'sales_ops', label:
'Sales Ops' }`.
- (b) CONTROL: the same served form with the Label row's `required`
removed: an empty Label saves.
- (c) a served schema that requires `label`: the page gives the verdict
it gave before (the create seed's placeholder refusal, objectui#12810),
and the new message is not added.
- `SchemaForm.requiredRows-28179.test.tsx`: which rows are reported: an
offered required row (also in a collapsed section); a predicate-hidden
row only once its predicate shows it; `readonly`, `immutable` outside
create and a read-only form are left out; a host-hidden row is left out;
the flat fallback reports nothing; unmount reports an empty set.
## Acceptance notes
- Measured first (order step 1), as the page test on current `main`
(`6285203d`): with the served permission form, the Label row draws the
star and no issue appears after Save (reverse leg below). The page on
`main` never reads a row's `required` outside the star, so Save takes
the same path as CONTROL (b): the `PUT` goes out with no `label` and the
page lands. The server accepting it follows from
`PermissionSetSchema.label` being optional; not measured live against a
running server.
- Zod-required rows behave as before by design: the rule only adds a
verdict where the row is stricter than the served schema. A field both
require keeps one message (the schema's) and the old refusal path.
- A required row in an inactive tab draws its issue only when its tab is
mounted; until then it is named through the existing summary banner,
which leaves out only fields drawn inline. Not separately pinned.
- `ui/AGENTS.md` #2 (docs): no README or `content/docs/frontend/` page
describes the metadata editor's save checks, so no doc page changed.
- The order placed the client-validation region at about L940 to L970;
that range is the advisory-ruling comment. The hold sits in `doSave`
beside the #27865 Name hold, as the claim's file surface records. No
line in #28239's regions (import block, references code, item-tool
sheets) changed.
## Verification
All local readings on head `75f14a8c` unless stated.
<details><summary>New tests, and the reverse leg on main's
sources</summary>
- Fix: `pnpm --dir ui exec vitest run` on the two new files: `Test Files
2 passed (2)`, `Tests 9 passed (9)`.
- Reverse leg: `ResourceEditPage.tsx` and `SchemaForm.tsx` restored to
base `6285203d` (marker counts after the restore: `fieldRequired` 0,
`onRequiredRowFieldsChange` 0), same command: `Tests 6 failed | 3 passed
(9)`; the 6 are the five SchemaForm report cases and page case (a)
(`Unable to find an element by: [data-testid="schema-form-issue"]`
inside the Label row, which shows only its star). (b) and (c) pass on
both trees. Restore proven by an empty `git diff HEAD`.
</details>
<details><summary>Neighbouring suites, type-check, lint</summary>
- Every `ResourceEditPage.*.test.tsx` and `SchemaForm*.test.tsx` in
`metadata-admin` plus
`packages/i18n/src/__tests__/studio-namespace.test.ts`: `Test Files 78
passed (78)`, `Tests 568 passed (568)`.
- `pnpm --filter @object-ui/app-shell --filter @object-ui/i18n run
type-check` (after a dts build of `@object-ui/app-shell^...`): exit 0.
- `eslint` on the changed files: 0 errors (warnings pre-existing). With
`--no-inline-config` it reports the three
`react-hooks/static-components` lines main already disables inline; none
is in this diff.
- `pnpm --dir ui run check:new-line-citations`: `0 new citation(s)`,
exit 0.
</details>
<details><summary>Derived gates (dispatch-gates --commands, 34
families)</summary>
All 34 exit 0, including `node scripts/check-sdui-manifest.mjs` (and
`--self-test`), `pnpm --dir ui exec vitest run scripts/`,
`check:adr-0087-registration`, `check:changeset-no-major`,
`check:empty-changeset`, `check:published-files`,
`check:type-check-coverage`, `check:type-check-debt`,
`check:test-source-alias`, `check:cross-package-test-inputs`,
`check:undeclared-dep-imports`, `check:nul-bytes`. `dispatch-gates
--ran`: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN, exit 0. The full
farm is CI's.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(untouched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (changed files linted
locally; the repo-wide run is CI's)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibzECC3G6Nyga7Ysbjd
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibzECC3G6Nyga7Ysbjd)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5374967 commit 91e4652
7 files changed
Lines changed: 412 additions & 19 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 | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
642 | 647 | | |
643 | 648 | | |
644 | 649 | | |
| |||
838 | 843 | | |
839 | 844 | | |
840 | 845 | | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
841 | 867 | | |
842 | 868 | | |
843 | 869 | | |
844 | | - | |
845 | | - | |
| 870 | + | |
| 871 | + | |
846 | 872 | | |
847 | 873 | | |
848 | 874 | | |
| |||
1894 | 1920 | | |
1895 | 1921 | | |
1896 | 1922 | | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1897 | 1934 | | |
1898 | 1935 | | |
1899 | 1936 | | |
| |||
3460 | 3497 | | |
3461 | 3498 | | |
3462 | 3499 | | |
| 3500 | + | |
3463 | 3501 | | |
3464 | 3502 | | |
3465 | 3503 | | |
| |||
3486 | 3524 | | |
3487 | 3525 | | |
3488 | 3526 | | |
| 3527 | + | |
3489 | 3528 | | |
3490 | 3529 | | |
3491 | 3530 | | |
| |||
0 commit comments