You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d88c41e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-grid): the row menu offers no Delete on a line whose master is held (#37296)
Fixes#37231
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:列表页和相关列表里,主单正在审批中的明细行(如费用报销明细),行菜单和选中栏不再出现「删除」;自身在审批中的记录仍可删除。
- 为什么做:审批锁定的列表收口工作的一部分,服务端早已拒绝这种删除,界面现在提前不提供。
- 出错会怎样:最坏情况是某行该删的「删除」被隐藏或仍然出现;只影响按钮显示,不写数据,可直接撤回。
- 要你做什么:无
## What changes
- `useRowApprovalLocks` now keeps the batch lock door's `lockSource`
(`'record'` or `'master'`) for a row answered `locked: true`, and
exposes `heldByMaster(recordId)`. It answers `true` only for a row a
read answered `lockSource: 'master'`. A 501, a `null` entry, a failed or
unasked read, and a record-held row all answer `false`.
- The grid's row CRUD verdict (`objectGridActionsColumn.tsx`) ANDs
`!heldByMaster` into `canDelete`. The row menu, the row context menu and
the list page's single-row selection bar all read the same
`rowActionMenuProps`, so they all drop Delete on a master-held line. A
record-held row keeps Delete and loses Edit, as before (#13568).
- `ObjectGrid.tsx`: the lock hook is also enabled, and the demand probe
also sent, on a grid whose rows offer Delete but no Edit
(`rowMenuReadsLocks = (canEdit && onEdit) || (canDelete && onDelete)`).
Without this, a Delete-only grid never read the lock and kept Delete on
a master-held line. The read is still sent only on demand, never on
first paint.
- The column docblock and the `ObjectGrid.tsx` hook comment no longer
say that a master-held line keeps Edit and Delete.
- One `patch` changeset for `@object-ui/plugin-grid`.
Read first, in order of risk:
1. `ui/packages/plugin-grid/src/ObjectGrid.tsx`, the `rowMenuReadsLocks`
hunk: a Delete-only grid now sends a lock read when a row's actions are
reached for.
2. `ui/packages/plugin-grid/src/hooks/useRowApprovalLocks.ts`, the
`answered.set` hunk: `lockSource` is kept only on a `locked: true`
entry, and only for one of the two values.
3. `ui/packages/plugin-grid/src/objectGridActionsColumn.tsx`, the
`canDelete` line.
Two-minute check: `cd ui && pnpm exec vitest run
packages/plugin-grid/src/__tests__/rowMenuApprovalLock-36911.test.tsx`
should report 10 passed, including the three tests under
`objectstack#37231`.
## Tests
The new pins are a top-level `describe` in the existing harness
`rowMenuApprovalLock-36911.test.tsx`:
- A master-held line offers neither Edit nor Delete. A record-held
sibling offers no Edit and keeps Delete. An open sibling offers both
(the control).
- A grid with `onDelete` and no `onEdit` reads the lock on demand and
drops Delete on the master-held line. The open row keeps Delete.
- On the list page selection bar, a master-held line offers neither. A
record-held sibling keeps Delete, and there is one lock read in total.
- The 501, `null` and failed-read controls now include a master-held
line, and each leaves its menu unchanged.
## Acceptance notes
- The cell-select path (`describeCell` → `approvalLocked`) still reads
only the boolean. Both lock kinds refuse an update, so the boolean is
enough there.
- A `locked: true` entry with no `lockSource` (an older server) reads as
record-held, which is the behaviour before this PR.
- Not measured in a browser against the showcase expense lines. The pins
drive the real `ObjectGrid` against a fake lock door.
- The ablation proves only the master arm in the column verdict. The
`rowMenuReadsLocks` widening has no ablation of its own. Its pin is the
Delete-only test, which went red under the column ablation only because
that ablation removes the downstream effect.
## Verification
All readings below were taken at commit 929d5f0 in objectstack.
<details><summary>Harness file, plugin-grid suite, type-check</summary>
```text
harness: cd ui && vitest run packages/plugin-grid/src/__tests__/rowMenuApprovalLock-36911.test.tsx
Test Files 1 passed (1)
Tests 10 passed (10)
os-verify-lock: VERDICT command-exit 0
plugin-grid suite: cd ui && vitest run --maxWorkers=2 packages/plugin-grid/
Test Files 313 passed (313)
Tests 2786 passed (2786)
os-verify-lock: VERDICT command-exit 0
pnpm --filter @object-ui/plugin-grid type-check
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation: drop the master arm</summary>
```text
node scripts/ablation-replace.mjs --file ui/packages/plugin-grid/src/objectGridActionsColumn.tsx --anchor " && !heldByMasterAnswered(row)" --delete -- (vitest on the harness file)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob d9d2a54 -> 2fcebc3668cf
x a master-held line offers neither Edit nor Delete; a record-held sibling offers no Edit and keeps Delete
x a grid whose rows offer Delete but no Edit still reads the lock, and drops Delete on the master-held line
x the list page selection bar: a selected master-held line offers neither; a selected record-held sibling keeps Delete
Tests 3 failed | 7 passed (10)
ablation-replace: ok restored: blob == HEAD (d9d2a54) and `git diff HEAD` is empty
```
Two earlier attempts were refused or invalid and are not counted. The
first used the anchor with a trailing comma and the replacement `,`: the
tool refused it as a no-op and restored the file before any test ran.
The second deleted the comma along with the anchor: that broke the
syntax, so the file collected no tests.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-grid): the row menu offers no Delete on a line whose master is held
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The grid row menu reads the batch approval-lock door (`POST /api/v1/approvals/records/:object/locks`) when a row's actions are reached for, and a row the door answers as locked offers no Edit. The door also says which approval holds the row, in `lockSource`: `'record'` (its own approval) or `'master'` (for a master-detail line, its master's approval). The menu read only the boolean, so a line whose master is held kept Delete, and the server refused that delete with `RECORD_LOCKED`.
11
+
12
+
The menu now reads `lockSource`. A row answered `lockSource: 'master'` offers neither Edit nor Delete. A row answered `lockSource: 'record'` offers no Edit and keeps Delete, as before: the server deletes such a record and cancels its request. The list page's single-row selection bar reads the same row props, so it follows. A 501, a `null` entry, a failed read or a read not yet asked leaves the menu as it was.
13
+
14
+
A grid whose rows offer Delete but no Edit now also reads the locks when a row's actions are reached for, so the rule holds there too. The read is still never sent on first paint.
0 commit comments