Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/35399-handover-follows-transfer-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@objectstack/core': minor
'@objectstack/client': minor
'@objectstack/rest': minor
'@object-ui/app-shell': minor
'@object-ui/i18n': minor
---

fix(core, console): a banned user's hand-over follows each object's Change Owner switch, and the ban dialog says why a record stays

Clause-②: no
Metadata-protocol: semantic

An object's Change Owner switch (`userActions.transfer`) now also decides whether the offboarding hand-over (`POST /api/v1/security/users/USER_ID/assigned-work/transfer`) moves the object's `owner_id`, and how the count (`GET /api/v1/security/users/USER_ID/assigned-work`) reports it. The hand-over reads the same resolution the Change Owner action refuses by (`resolveUserActionTransfer`), so the two never disagree:

- An object that turns the switch off keeps its records' owners where they are. Before, the hand-over moved them.
- A `controlled_by_parent` detail that leaves the switch out keeps its owner (the default is off there), as before. A detail that sets `userActions.transfer: true` now has its owner handed over like any other object. Before, every detail's owner was skipped.
- The object's own user fields (an approver, an assignee) are handed over whatever the switch says.

A kept owner is still counted. Before, a detail's owner was left out of the count; now its row answers `transferable: false` with `reason: 'transfer_off'`. A multi-valued user field answers `reason: 'multi_valued'`. `reason` is a new optional member of each `objects[]` row in `security.assignedWork.count`'s answer (`UserAssignedWorkSummary` in `@objectstack/client`, `UserAssignedWorkHoldReason` in `@objectstack/core`). It is present exactly when `transferable` is false.

The ban dialog words each kept row by its reason. A kept owner reads "Not handed over: this object keeps the owner of each record (Change Owner is off for it)." (zh: 不会交接:该对象的记录负责人保持不变(该对象已关闭“更改负责人”)。). A multi-valued row keeps its own sentence ("Lists several people, so it cannot be handed over here."), and a kept owner never shows it. The new `console.assignedWork.ownerKept` key is in all eleven UI locales.

To keep the old hand-over of an object you switched off, set `userActions.transfer` back on for it. Before this change the switch gated only the Change Owner action; it now gates that action and the hand-over, and nothing else: a plain `owner_id` write (an import, a hook, a `PATCH`) still needs only the transfer grant.
6 changes: 4 additions & 2 deletions content/docs/api/data-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ Offered only on an object the platform gives a reassignable owner and whose
`userActions.transfer` switch is on. The switch defaults to on, and to off on a
`controlled_by_parent` detail. Any other object is refused as a whole with
`403 CHANGE_OWNER_DISABLED`, whoever asks, a `modifyAllRecords` holder
included. The switch gates this action only: a plain `owner_id` update (an
import, a hook, a `PATCH`) still needs the transfer grant and nothing else.
included. The same switch decides whether a banned user's hand-over
(`/api/v1/security/users/USER_ID/assigned-work`) moves the object's owners.
It gates these two actions only: a plain `owner_id` update (an import, a hook,
a `PATCH`) still needs the transfer grant and nothing else.

**Body**: exactly one target, and an optional notification.

Expand Down
38 changes: 23 additions & 15 deletions content/docs/permissions/administrator-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,29 @@ hand:
validation rules and hooks apply. It answers what moved, what failed and how
many remain; call it again until `remaining` is 0.

The owner field of a detail object (`sharingModel: 'controlled_by_parent'`)
is neither counted nor moved. On a detail the owner records who did the work
(the person on a timesheet, the spender on an expense line), not who holds
it; handing it over would make the successor appear to have done that work.
A detail row that names its master is reached through that master, so hand
over the master record instead. The detail's other user fields, such as an
approver, are counted and moved as usual.

One row class has no master to hand over: a detail row whose master reference
is empty, on a detail whose master is optional (declared `required: false`).
Its owner reads and writes it, beside holders of View All / Modify All on the
detail. Its owner is not counted or moved either, so after the ban only View
All / Modify All holders reach it. To give such rows to someone else, a holder
of Modify All on the detail filters the detail by owner and edits the owner by
hand.
Some holdings are counted but not moved, and the count says why on each row
(`transferable: false` with a `reason`):

- `multi_valued`: a user field that lists several people. Replacing one person
in a list is a different edit from reassigning a record.
- `transfer_off`: the owner field of an object whose Change Owner switch,
`userActions.transfer`, is off. The hand-over follows the same switch as the
Change Owner action, so an object that turns it off keeps its records'
owners where they are. The switch defaults to off on a detail object
(`sharingModel: 'controlled_by_parent'`): there the owner usually records
who did the work (the person on a timesheet, the spender on an expense
line), and a detail row that names its master is reached through that
master, so hand over the master record instead. A detail whose owner really
holds the record (a contact under an account) sets `userActions.transfer:
true`, and the hand-over then moves its owner like any other. The rule is
per object: on a switched-off detail whose master is optional (declared
`required: false`), a row with an empty master reference keeps its owner
too, and after the ban only holders of View All / Modify All on the detail
reach it; a holder of Modify All moves it by filtering the detail by owner
and editing the owner by hand.

The switch governs only the platform owner field: an object's other user
fields, such as an approver, are counted and moved as usual.

The hand-over is optional and never delays the ban. Once a user is banned, a
new record or edit that sets a user field to them is refused with the field
Expand Down
22 changes: 17 additions & 5 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,21 @@ export interface MetaItemsListOptions {

/**
* [#30205] `security.assignedWork.count`'s answer: per object and user field,
* how many records hold the user, as the caller can read them.
* how many records hold the user, as the caller can read them. A row with
* `transferable: false` is counted but never handed over, and `reason` says
* why: `multi_valued` (a multi-valued user field) or `transfer_off` (the owner
* field of an object whose Change Owner switch, `userActions.transfer`, is off).
*/
export interface UserAssignedWorkSummary {
userId: string;
objects: Array<{ object: string; field: string; count: number; transferable: boolean }>;
objects: Array<{
object: string;
field: string;
count: number;
transferable: boolean;
/** Why the row is not handed over; present exactly when `transferable` is false. */
reason?: 'multi_valued' | 'transfer_off';
}>;
total: number;
truncated: boolean;
unreadable: string[];
Expand Down Expand Up @@ -7042,9 +7052,11 @@ export class ObjectStackClient {
assignedWork: {
/**
* Per object and user field (the owner field and every app user
* field), how many records hold `userId`. Objects the caller cannot
* read are named in `unreadable`; `truncated` says more fields exist
* than were counted.
* field), how many records hold `userId`, each with whether
* `transfer` moves them and, when it does not, why (`reason`): a
* multi-valued field, or the owner field of an object whose Change
* Owner switch is off. Objects the caller cannot read are named in
* `unreadable`; `truncated` says more fields exist than were counted.
*/
count: async (userId: string): Promise<UserAssignedWorkSummary> => {
const res = await this.fetch(
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ export {
type UserAssignedWorkField,
type UserWorkEngine,
type UserAssignedWorkCount,
type UserAssignedWorkHoldReason,
type UserAssignedWorkSummary,
type UserWorkFailureDescriber,
type UserWorkTransferFailure,
Expand Down
Loading
Loading