Repository navigation
feat(app-shell): Delete Behavior row in the Studio field panel on lookup, user and master_detail fields - #29853
Merged
Conversation
…kup, user and master_detail fields Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jS7iTtMx3iqedtUAyz
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jS7iTtMx3iqedtUAyz
…ehavior suite Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jS7iTtMx3iqedtUAyz
Contributor
Author
|
domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m 席位核对 · ACCEPT · 2026-11-03T07:50ZHead-sha:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Steedos · project thread
Fixes #29807
Clause-②: no
Metadata-protocol: none
Claim: 6596731216 (amended 6596763338)
维护者速读
ObjectFieldInspector)在 lookup、user 与 master_detail 字段上新增「删除行为」下拉框(deleteBehavior)。lookup 与 user 可选 置空 / 级联 / 限制;master_detail 只有 级联 / 限制(规范拒绝在主从字段上写set_null)。首项「— 无 —」把该键从字段定义里删掉。字段改成没有该行的类型时删除该键,改成 master_detail 时删除已写的set_null。ObjectFieldInspector.tsx的offeredDeleteBehaviors(哪种类型给哪些值)、changeType里的dropsDeleteBehavior、DeleteBehaviorField的onCommit(选值写入 / 选「无」走unsetDefKey)。pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx,预期 54 个用例全部通过(其中 9 个是本 PR 新增的删除行为用例)。What changes
The Studio object designer's field panel can now set and clear
FieldSchema.deleteBehavior. Until now only the genericfield/objectmetadata forms (PR #29712) offered it, and the object editor draws the designer and its inspectors, not those forms.lookupusermaster_detailset_nullthere)text,treeand every other typefield.form.ts): all three onlookupanduser,cascade/restrictonmaster_detail. One helper,offeredDeleteBehaviors(type), decides both the row and its values.InspectorSelectField's''option mapped tounsetDefKey, the shape thevalueDomainrow already uses. The field then carries nodeleteBehaviorat all, never''ornull. On alookupthat means the spec default; on auserfield it keeps the field out of the delete walk.changeTypenow removesdeleteBehaviorwhen the next type draws no row,treeincluded, and removes an authoredset_nullon a retype tomaster_detail.cascadeandrestrictsurvive a retype tomaster_detail.designer.field.deleteBehavior,.help,.set_null,.cascade,.restrict) inenandzh, the two locales that namespace carries. The label and help text match the form row; the Cascade and Restrict labels arefield.form.ts'smaster_detailoption labels.Tests
ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx, a new top-level describe in the shared harness (9 cases, over the real inspector with a host that feeds each patch back as Studio's draft does):lookupanduserwith None plus three values, and onmaster_detailwith None plus two.textor atreefield.userfield writesdeleteBehavior: 'cascade'.lookupholdingrestrictleaves the key absent (hasOwnPropertyfalse), withreferencekept.lookupto Text drops the key.lookupto Master-Detail dropsset_null, and keepscascade.Ablations through
scripts/ablation-replace.mjs, each restored to the HEAD blob withgit diff HEADempty, each red:false &&delete nextDef.deleteBehaviorremovedAcceptance notes
ObjectFieldInspector.tsx(a type helper,changeType, the row and its component), its shared test harness,ui/packages/i18n/src/namespaces/studio/{en,zh}.ts(five keys each), and.changeset/29807-field-panel-delete-behavior.md(patches for@object-ui/app-shelland@object-ui/i18n). The Studio namespace table is a plain string-to-string record outside the locale packs, so the new keys widen no published type and the claim'sClause-②: noholds.deleteBehavioron auserfield cannot be cleared #29733) does not touch this file; its "— None —" item is private toSchemaForm. This row reuses the field panel's own absent-key path instead, so the two PRs share no code (claim amendment 6596763338). fix(app-shell): optional choice rows in Studio metadata forms can be cleared again #29805 has since merged and is in this branch through the main merge.set_nullon amaster_detail) is drawn flagged byInspectorSelectField, as every select in the panel does, so the author sees what the save refuses.InspectorSelectFieldtakes no description, so it is not wired as the control's accessible description, unlike the name toggle's checkbox.designer.field.deleteBehavior.among the dynamic prefixes it keeps alive (3 keys, one call site), the same asdesigner.field.summary.fn..Verification
Real backend (
objectstack dev --seed-admin --freshinexamples/app-crm) and the source Console on Vite, as the admin, on heade646fdc1(this PR's code is unchanged by the later main merge). Screenshots and scripts are in the project folderissue-29807/(shots/,setup.mjs,measure.cjs,read.mjs), not on GitHub.Before, set, publish, unset: the definition carries the key, then drops it
com.example.dbxover REST:dbx_account, anddbx_ticketwithtitle(text),parent_ticket(lookup),assignee(user) andaccount(master_detail), none declaring the key.ObjectFieldInspector.tsxfromorigin/mainswapped in under the same Vite server, then restored to the HEAD blob): no Delete Behavior row on any of the four fields (before-*.png)./apps/setup/metadata/object/dbx_ticket: the row is onparent_ticketandassigneewith — None —, Set Null (clear the reference), Cascade (delete children), Restrict (block the delete), and onaccountwith — None —, Cascade, Restrict;titlehas none (set-*.png). Picking Cascade, Restrict and Restrict autosaved the draft (PUT /api/v1/meta/object/dbx_ticket?mode=draft200, three times), Publish answeredPOST …/dbx_ticket/publish200, andGET /api/v1/meta/object/dbx_ticketthen servedparent_ticket.deleteBehaviorcascade,assigneerestrict,accountrestrict, and no key ontitle. After a reload the selects read those values (set-reloaded-*.png).parent_ticketandassignee: the last draft PUT body carried neither key on those two fields (accountkeptrestrict), Publish answered 200, and the served definition had nodeleteBehavioronparent_ticketorassignee(unset-*.png).Local gates and suites
dispatch-gates --commandsderives no tier mandate (default tier). Changed lines 229 (+228 / -1), 5 files.eab8960c(main merged, which brought in PR fix(app-shell): optional choice rows in Studio metadata forms can be cleared again #29805), afterpnpm install --frozen-lockfileand a fullpnpm build(117/117):turbo run type-checkfor@object-ui/app-shelland@object-ui/i18n66/66; 128 test files (all 31ObjectFieldInspector*files, the zh base-term census,block-config-i18n, the whole@object-ui/i18npackage) at 2 workers under the verify lock, 128/128 files, 1800 passed, 13 skipped.eab8960c: the derived set, 35 commands, every one exit 0, includingcheck-sdui-manifest(manifest intact, 106 components) andpnpm --dir ui exec vitest run scripts/under the lock (170 files passed, 2 skipped);--ranreconciles 35 derived, 35 run, 0 NOT-MEASURED. The same set was also all exit 0 one646fdc1before the merge.check:i18n-keys,check:i18n-drift,check:i18n-dead-keys,check:designer-field-key-parity,check:phantom-deps,check:spec-symbolsexit 0 oneab8960c;eslinton the four touched source files exit 0 (warnings only, all on lines this PR does not touch).Generated by Claude Code