Skip to content

Commit 6a35635

Browse files
feat(console): Change Owner on the record page, the list selection bar and the edit form (#35403) (#36343)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP3RHGWUG7UH3fNa4tBa9UC)_ Fixes #35403 Clause-②: yes (widening) — new published `@object-ui` surface, measured on the export lists (merge base `b3bcfefcb` against head): `onBulkChangeOwner` and `bulkChangeOwnerOffered` props on `ObjectGrid` / `ListView`; `CHANGE_OWNER_BULK_ACTION` (plugin-grid); `FormOwnerLine`, `FormOwnerLineProps`, `FormOwnerLineContext`, `FormOwnerActionTarget`, `FormOwnerLineHost` (plugin-form; the last three also from `/core`); `'transfer'` in `RecordOperation` (plugin-detail); `grid.changeOwner` and `console.changeOwner.*` keys in every locale (i18n); nothing removed or renamed Metadata-protocol: none Seat reading 2026-11-22 08:01Z: Q1 A, Q2 A ## 维护者速读 - 控制台用户在记录页、列表批量选择栏和编辑表单上能看到「更改负责人」操作;编辑表单里负责人以只读显示,操作就在旁边。 - 这是「更改负责人」三张卡里的最后一张(控制台界面);服务端接口和规则判断已经在前两张卡里合并。 - 出错时最坏的情况是该显示的按钮没显示,或者在服务端本会拒绝的地方多显示了一个按钮;不改服务端,也不改任何数据规则,撤回这次合并即可。 - 无。 ## What changes **The record page.** The header gets a **Change Owner** entry in its `⋯` menu (`sys_change_owner`, in `RecordDetailView`'s built-in header entries). It is drawn only when all three facts hold, as ruled: 1. The object is structurally eligible. 2. Its switch `userActions.transfer` is on. Facts 1 and 2 come from the spec's one resolution, `resolveUserActionTransfer` in `@objectstack/spec/data`. 3. The explain engine's `transfer` verdict for this record is a definite allow. The verdict comes from the record page's existing single read. Its `explain` list now asks `transfer` wherever facts 1 and 2 hold. `seedRecordPageReaders` seeds that answer into the same verdict cache `useRecordVerdict` reads, so there is no second per-record request. The queue Claim shares the same answer. If `disabledWhen` holds for the record, the entry is drawn disabled with the reason beside it, as the CRUD entries are. **One dialog** (`ChangeOwnerDialog`), used by the record action, the form action and the bulk action: - The picker is labelled with the object's own label for `owner_id`. The served label is passed through `fieldLabel`, and "Owner" (i18n) is used only when the object serves none. - You can pick a person, or a queue where the object carries the ADR-0142 `queue` column. Queues are read from `sys_queue` only once the queue target is chosen. - An optional notify checkbox sends `notify: true` only when ticked. - One record calls `data.changeOwner`; two or more call `data.changeOwnerMany`, both from `@objectstack/client`. There is no server, spec, SDK or REST change. - A refusal shows the server's own sentence. - A bulk answer ends in a report: moved, already had this owner, did not move. Every row that did not move is listed with the server's sentence, unsampled. **The list.** `ObjectGrid`'s selection bar (and its row context menu's bulk section) offers **Change Owner** where the host wires the new optional `onBulkChangeOwner` prop, unless the new optional `bulkChangeOwnerOffered` is `false`; `ListView` forwards both. Wiring `onBulkChangeOwner` makes the rows selectable, as a bulk action does. The Console wires it wherever facts 1 and 2 hold (read client-side, no request), so a user with no bulk Delete, on a view with no authored bulk actions, still gets checkboxes. It passes `bulkChangeOwnerOffered` as the explain engine's `transfer` verdict for the OBJECT, which must be a definite allow (`POST /security/explain` with no `recordId`, one question per object and principal, shared by every list). **The question is asked once a selection is open in the page's list, not when the list opens** (`useListChangeOwnerOffered(objectDef, listSelecting)`, reading the page's existing `useListPageSelecting`). Opening a list therefore costs the server no explain read, the posture the grid's row verdicts already take (`useRecordCrudVerdicts`). Rows that the switch's `visibleWhen` excludes are left out of the request with the same fail-closed fold the bulk Delete runs, and the dialog says how many it left out. The server judges every remaining row again. **The default edit form.** `owner_id` is still dropped from the form's fields by `filterSystemFields` / `SERVER_OWNED_FIELD_NAMES` and never written by the form. It is now shown read-only on its own line above the fields, with the host's action beside it. The line appears only under a host that mounts `FormOwnerLineContext` (exported from `@object-ui/plugin-form` and its `/core` entry). The Console mounts it around its global edit dialog and the page-mode form. An embedded form without the context is unchanged. **Strings.** All new strings are in all 11 console locales: `grid.changeOwner` and the `console.changeOwner.*` block. The two counted strings are plural families with a base key in every pack. ## Tests **Rework round (L1 REWORK 7077241523, L2 FAIL 7077265450), head `7a1cdd56`:** - **M1.** The changeset's `Clause-②:` line reads `yes (widening)`; its body lists the new surface per package. Measured with the TypeScript checker (`getExportsOfModule` and the members of each exported interface and type) on each entry, merge base `b3bcfefcb` against head. Added names: plugin-grid `CHANGE_OWNER_BULK_ACTION`; plugin-form `FormOwnerActionTarget`, `FormOwnerLine`, `FormOwnerLineContext`, `FormOwnerLineHost`, `FormOwnerLineProps` (root) and `FormOwnerActionTarget`, `FormOwnerLineContext`, `FormOwnerLineHost` (`/core`); plugin-list, plugin-detail (root and `/core`) and i18n add no name. Added members: `ObjectGridComponentProps` / `ObjectGridProps` `onBulkChangeOwner`, `bulkChangeOwnerOffered`; `ListViewProps` `onBulkChangeOwner`, `bulkChangeOwnerOffered`; `RecordOperation` `"delete"|"update"` to `"delete"|"transfer"|"update"`. Removed: none. Re-read on the BUILT declarations of head `7a1cdd56` (the five packages' `dist/*.d.ts`, built under `os-verify-lock`): the same added names on every entry, and the same added members (`ObjectGridComponentProps` / `ObjectGridProps` / `ListViewProps` `onBulkChangeOwner` and `bulkChangeOwnerOffered`, `RecordOperation` with `'transfer'`, the `FormOwner*` members). The built and source lists differ only in declarations this diff does not touch (`ColumnSummarySetting`, `ActivityFilterType`, `RecordStageMenuProps`, a symbol id). The i18n surface is the locale packs' new keys: `grid.changeOwner` and the `console.changeOwner.*` block, in all 11. - **S1.** `ObjectGrid` turns multi-select on where `onBulkChangeOwner` is wired, and draws the entry only while `bulkChangeOwnerOffered !== false`; the Console wires the prop from facts 1 and 2 and passes the verdict asked once a selection is open. New pin `ObjectView.bulkChangeOwnerReach-35403.test.tsx`, through the real `ObjectView` and grid, for a user who may edit but not delete (`can(…, 'delete')` false) on an object with no authored bulk actions: checkboxes on open and no object-level `transfer` request; ticking both rows asks once and the bar carries `sys_change_owner` and no `delete`. A refused verdict leaves the rows selectable and the bar without Change Owner. Control: an `ownership: 'none'` object draws no checkboxes and asks nothing. 3/3. - Ablations on committed `7a1cdd56`, through `scripts/ablation-replace.mjs`, each restore proved by blob == HEAD and an empty `git diff HEAD`. Dropping `|| onBulkChangeOwner` from the multi-select arm (blob `ba88537d73a0` to `1d7490f81be0`) gave 2 failed, 1 passed: the transfer case and the refused case found no checkboxes, and the control stayed green. Dropping `&& bulkChangeOwnerOffered !== false` (to `9d540e94f35b`) gave 1 failed, 2 passed: the refused case drew Change Owner. - **N3.** The `onBulkChangeOwner` doc now says when the entry is drawn: at any count, except on a list page, where one selected record shows that record's own actions and the bulk entries start at two. That is what the bar does (`singleRowMenu` for one row on a list page); the code is unchanged. - Re-runs on `7a1cdd56`, under `os-verify-lock`: every app-shell suite naming `ObjectView` or `AppContent`, plus `changeOwner-35403`, `bulkChangeOwner-35403` and the payload pin: Test Files 289 passed (289), Tests 2639 passed (2639). **Earlier round, head `5d4ddea3`:** Final head `5d4ddea3`. - **The six suites the object-level read had turned red, cause read.** `ObjectView.sharedViewSave-35955`, `ObjectView.objectBoundActions-7234`, `ObjectView.footerCalculationDraft-36194`, `ObjectView.readOnlyPackageViewSaves-35974`, `ObjectView.viewRefusal-12112` and `AppContent.draftSaveKeepsList-35932` failed with the network-escape guard's `Network escape: this test reached a REAL socket at http://localhost:3000/api/v1/security/explain`. Every list open asked the explain engine. That was a product cost, not a missing double: the list now asks only once a selection is open, and these suites pass unchanged. - `RecordDetailView.recordPagePayload-27627`: the pin on the page request's `explain` list now reads `['update', 'delete', 'transfer']`; the fixture object carries an owner, so the transfer verdict rides the same single read. The pin's intent (one request opens a record page) is unchanged. - `ObjectView.phoneFabSelecting-35883` opens a selection, so it now gets an explain double answering no; any other request throws. - Runs, all under `os-verify-lock`: - every `ObjectView.*` suite plus AppContent, the payload pin and the card file, on `0e97ce47`: Test Files 105 passed, 1 failed (the phone selection suite, fixed in `df44c1a3`); - every other app-shell suite naming `ObjectView` or `AppContent`, plus the phone selection suite, on `df44c1a3`: Test Files 188 passed (188), Tests 1720 passed (1720); - the whole `@object-ui/i18n` suite (with `count-families-11445`, `de-quote-pairing-3876`, `untranslated-identity-4376`, `zh-hant-generated`, `all-locales-key-parity`), the plugin-form `affordanceGrantMap-12082` census, `bulkChangeOwner-35403` and `changeOwner-35403`, on `5d4ddea3`: Test Files 109 passed (109), Tests 2065 passed, 13 skipped. The first run of this set on `a37c0ac5` was red in `all-locales-key-parity` (the two counted families had no base key in any of the 11 packs); `5d4ddea3` adds them. - Card pins, all in `changeOwner-35403.test.tsx` and `bulkChangeOwner-35403.test.tsx`: no action on `ownership: 'none'`, `managedBy` and `sys_*` objects even for a platform admin; a `controlled_by_parent` detail shows none by default and shows it with `userActions.transfer: true`; a switched-off `private` object shows none for a `modifyAllRecords` holder; edit without transfer sees `owner_id` read-only and no action; the bulk report renders per-row failures. The five list-gate cases (allow asked once at object grain, refusal, refused read, no open selection asks nothing, ineligible object asks nothing) pass. - Ablation on committed `5d4ddea3`, through `scripts/ablation-replace.mjs`: `const asks = enabled && !!name && wanted;` changed to drop `&& wanted`, anchor 1 to 0, blob `293da7c28c7d` to `8cae616fd61b`; `changeOwner-35403.test.tsx` went 1 failed, 29 passed (the no-open-selection case); restore proved by blob `293da7c28c7d` == HEAD and an empty `git diff HEAD`. The earlier visibility-leg ablations are on the previous dev's heads (structural 3 red, switch 2 red, verdict 3 red). - Type-check on `5d4ddea3`: `@object-ui/app-shell` and `@object-ui/i18n` `type-check` (after building the `@object-ui/app-shell^...` closure): VERDICT command-exit 0. ## Acceptance notes - L2 S2 and N2 carried by #36395. - **Seat reading 2026-11-22 08:01Z: Q1 A, Q2 A.** The list reads the explain engine's object-level `transfer` verdict, as the ruling words it. The #30205 row cap stays server-only: over 500 rows the dialog shows the server's own `VALIDATION_ERROR` sentence. - **N1 (the echo): a row whose owner already was the person picked reads "already had this owner", not "moved".** On one record the dialog leaves the current owner out of the picker and refuses it with the reason shown. In a bulk report the unchanged count is capped at what the server counted updated. A queue target has no person to compare, so every admitted row reads as moved. - **Change Owner is drawn on a definite allow only**, on the record page, the form and the list. A deployment whose explain engine answers nothing shows no Change Owner anywhere, as the queue Claim beside it does. - **On the list, Change Owner appears a moment after the selection bar the first time a selection opens for an object** (one round trip); later selections read the kept answer at once. - **Rows of an object that offers Change Owner are selectable for every user**, the price of asking the verdict only on a selection. A user the verdict refuses, with no other bulk action, gets a selection bar with nothing but its count and its clear button. - On a list page, one ticked record shows that record's own actions, so the bulk Change Owner starts at two ticked records; that record's page offers Change Owner itself. - Not wired here (carrier: none; noted, not filed): the non-grid `ListView` bulk surfaces. `onBulkChangeOwner` reaches the grid only. - A dirty edit form saved after a Change Owner may meet the record's version check (the form re-reads in place only while pristine). Unchanged here. ## Verification Read first, by risk: 1. `ui/packages/plugin-grid/src/ObjectGrid.tsx`: `changeOwnerDrawn` and the multi-select arm `hasBulkActions || onBulkChangeOwner`. 2. `ui/packages/app-shell/src/views/changeOwner.ts`, `useListChangeOwnerOffered` (the `wanted` hold) and `useRecordChangeOwnerOffer` (the three-fact gate, `verdict === true`). 3. `ui/packages/app-shell/src/views/recordPagePayload.ts`: `transfer` now seeds the record verdict as well as the Claim reader. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView.bulkChangeOwnerReach-35403.test.tsx packages/app-shell/src/views/changeOwner-35403.test.tsx`. Expected: 33 passed. --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds)_ <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jUc3qp6bHKSWijbjds --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 24366ff commit 6a35635

40 files changed

Lines changed: 2318 additions & 20 deletions
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/plugin-grid': patch
5+
'@object-ui/plugin-form': patch
6+
'@object-ui/plugin-detail': patch
7+
'@object-ui/plugin-list': patch
8+
'@object-ui/i18n': patch
9+
---
10+
11+
feat(console): Change Owner on the record page, in a list's selection bar, and beside the read-only owner of the edit form
12+
13+
Clause-②: yes (widening)
14+
Metadata-protocol: none
15+
16+
A record whose object offers Change Owner now shows a **Change Owner** action in its page header. The action appears only where three things hold: the object can have its owner changed (it has a per-person owner that is not pinned read-only), the object's `userActions.transfer` switch is on, and the server's explain engine allows this user to transfer this record. A `controlled_by_parent` detail offers the action only once its author turns the switch on. Objects with `ownership: 'none'`, `managedBy` objects and `sys_*` objects never offer it, even to a platform admin.
17+
18+
The action opens one dialog. You pick the new owner under the object's own label for its owner field. Where the object has an ownership queue, you can pick a queue instead. You can also ask that the new owner be notified. The dialog sends the change through `data.changeOwner` for one record and `data.changeOwnerMany` for several. Picking the record's current owner is refused in the dialog with the reason shown. A bulk change ends with a report: how many records moved, how many already had that owner, how many did not move, and each row that did not move with the server's own reason.
19+
20+
A list's selection bar offers **Change Owner** for the selected rows, where the object's switch is on and the explain engine allows this user to transfer the object's records (one question per object, not per row, asked once a selection is open rather than when the list opens). The rows of such an object take a selection even when the user has no bulk Delete and the view authors no bulk actions, so the entry can be reached at all; where the verdict refuses, the bar draws no Change Owner. The server judges every row again. Rows that the switch's `visibleWhen` excludes are left out of the request, and the dialog says how many were left out.
21+
22+
The Console's edit form now shows the owner, read-only, above the form's fields, with Change Owner beside it when it is offered. The owner field is still not part of what the form saves. Forms embedded outside the Console are unchanged: the owner line appears only where a host mounts `FormOwnerLineContext` (exported from `@object-ui/plugin-form` and `@object-ui/plugin-form/core`).
23+
24+
New public surface, all additive:
25+
26+
- `@object-ui/plugin-grid`: `ObjectGrid` takes two new optional props, `onBulkChangeOwner` (wiring it makes the rows selectable and adds the entry) and `bulkChangeOwnerOffered` (`false` holds the entry back while the rows stay selectable); the package exports the action name `CHANGE_OWNER_BULK_ACTION`.
27+
- `@object-ui/plugin-list`: `ListView` takes and forwards both props.
28+
- `@object-ui/plugin-form`: new exports `FormOwnerLine`, `FormOwnerLineProps`, `FormOwnerLineContext`, `FormOwnerActionTarget` and `FormOwnerLineHost`; `@object-ui/plugin-form/core` exports `FormOwnerLineContext`, `FormOwnerActionTarget` and `FormOwnerLineHost`.
29+
- `@object-ui/plugin-detail`: `RecordOperation` gains `'transfer'`, so `useRecordVerdict` and `seedRecordVerdict` accept it.
30+
- `@object-ui/i18n`: every console locale gains `grid.changeOwner` and the `console.changeOwner.*` block.

‎ui/apps/console/vite.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ export default defineConfig({
15411541
// `core.ts` closure belongs in its list.
15421542
{
15431543
name: 'plugin-form-core',
1544-
test: /[\\/]packages[\\/]plugin-form[\\/]src[\\/](core|autoLayout|sanitize|deriveMasterDetail|schemaDefaults|sectionGroups|fieldGroups|initialFieldFocus)\.tsx?$/,
1544+
test: /[\\/]packages[\\/]plugin-form[\\/]src[\\/](core|autoLayout|sanitize|deriveMasterDetail|schemaDefaults|sectionGroups|fieldGroups|initialFieldFocus|formOwnerLineContext)\.tsx?$/,
15451545
priority: 71,
15461546
includeDependenciesRecursively: false,
15471547
},

‎ui/packages/app-shell/src/console/AppContent.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Routes, Route, Navigate, matchRoutes, useNavigate, useLocation, usePara
1212
import { useState, useEffect, useLayoutEffect, useCallback, useRef, lazy, Suspense, useMemo, createElement, type ComponentType, type ReactNode } from 'react';
1313
import { useAssistant } from '../assistant/assistantBus.js';
1414
import { LazyModalForm } from '../views/lazyFormSurfaces.js';
15+
import { ConsoleFormOwnerLine } from '../views/consoleFormOwnerLine.js';
1516
import { Empty, EmptyTitle, EmptyDescription, Button, DataErrorState } from '@object-ui/components';
1617
import { toast } from 'sonner';
1718
import { useActionRunner, useGlobalUndo, useMutationInvalidationBridge, notifyDataChanged, FilterScopeProvider, resolveApprovalLock, claimAnswerWarnings, toastRecordSave, type AnswerWarningClaim, type AnsweredLoadFailure, type RecordSaveFeedback } from '@object-ui/react';
@@ -1722,6 +1723,9 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
17221723
</Suspense>
17231724
</ErrorBoundary>
17241725
{formObjectDef && (
1726+
// objectstack#35403 — an edit draws the record's owner read-only,
1727+
// with Change Owner beside it where the caller may transfer it.
1728+
<ConsoleFormOwnerLine>
17251729
<LazyModalForm
17261730
key={`${formObjectDef.name}:${editingRecord?.id || 'new'}`}
17271731
lockedBy={formApprovalLocked ? 'approval' : undefined}
@@ -1824,6 +1828,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
18241828
}}
18251829
dataSource={formDataSource ?? undefined}
18261830
/>
1831+
</ConsoleFormOwnerLine>
18271832
)}
18281833
</ConsoleLayout>
18291834
</RecordPageDrawerOpenProvider>

0 commit comments

Comments
 (0)