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 61de599
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-list): offer the In a queue toggle only when the organization has a queue (#28889)
Fixes#28428
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:列表工具栏的「在队列中」开关现在只在两个条件都成立时出现:对象带平台注入的 `queue` 字段,且当前会话的
`/auth/me/permissions` 回答 `hasAnyQueue:
true`(组织至少有一个队列)。`@object-ui/permissions` 的上下文新增一个可选成员
`hasAnyQueue`,把服务端这个布尔值原样传下去。
- 为什么改:平台给每个归属用户的对象都注入 `queue` 字段,所以没有任何队列的组织(如
app-crm、HotCRM)每个列表都显示这个开关,点了永远是空列表。按 #28428 的裁定 A,服务端已在 #28508 提供该布尔值。
-
风险与回滚:会话没有这个答案时(没有权限提供者、基于角色的提供者、匿名会话)开关隐藏;控制台的提供者在答案到达前不渲染列表,所以控制台里不会出现"加载中"的状态。服务端的队列行为(认领、释放、读取规则)不变。回滚即还原本
PR,无数据或协议变更。
-
先看:`ui/packages/plugin-list/src/ListView.tsx`(`queueFilterOffered`)、`ui/packages/permissions/src/MePermissionsProvider.tsx`(`hasAnyQueue`)、`ui/packages/permissions/src/PermissionContext.ts`。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/plugin-list/src/__tests__/ListView.queueSittingFilter-25769.test.tsx
packages/permissions/src/__tests__/hasAnyQueue-28428.test.tsx`,预期 18
个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- **`@object-ui/permissions`:** `PermissionContextValue` gains one
optional member, `hasAnyQueue?: boolean`. `MePermissionsProvider` sets
it from the authenticated `/auth/me/permissions` answer (#28508). It is
`undefined` with no answer: the anonymous answer, the role-based
`PermissionProvider`, and no provider at all (`usePermissions`'
no-provider literal). `ServerReadScope` and `RecordFieldAccessScope`
spread their parent, so they forward it unchanged.
- **`@object-ui/plugin-list`:** `queueFilterOffered` is now `hasAnyQueue
=== true && objectHasOwnershipQueue(objectDef)`. The flag rides the
permissions answer the console already holds, so opening a list reads no
queue list and sends no new request.
- **Unknown flag = hidden** (claim amendment 6567840348). Under the
console, `MePermissionsProvider` renders its loading fallback until the
payload arrives, so a list never sees a pending flag there. Elsewhere
(no provider, the role-based provider, an anonymous session) nothing can
show a queue exists, so the toggle stays hidden.
- Turning the toggle on filters exactly as before. Nothing on the server
changes.
## Why
Route A ruling 6553134732 on #28428: offer the toggle when the object
carries the `queue` field AND the session's has-queues boolean is true.
In an organization with no queue, the toggle could only return an empty
list.
## Tests
- `ListView.queueSittingFilter-25769.test.tsx`: the existing cases now
mount under a session double (`MePermissionsProvider` with `hasAnyQueue:
true`) and still pass. New cases: no queue gives no toggle even on an
object with the injected column; one queue gives the toggle; an unknown
answer (no provider, anonymous) gives no toggle; a list mount makes the
same data-source calls with and without a queue, every `find` targets
the listed object, and `fetch` is never called.
- New `hasAnyQueue-28428.test.tsx` in `@object-ui/permissions`: the
truth table (served `true` and `false`, anonymous, forwarded through
`ServerReadScope`, role-based provider, no provider).
- Ablations, each run through `scripts/ablation-replace.mjs` with the
blob restored to HEAD afterwards:
- Gate removed (`(hasAnyQueue === true || true) && …`): 2 red, "no
queue" and "unknown answer".
- Provider member removed (`hasAnyQueue: undefined`): 3 red, served
`true`, served `false`, scope forwarding.
## Acceptance notes
Measured on a production console build (`turbo run build`, `pnpm
console:build`), `pnpm dev:crm -- --fresh`, admin, at head `c0b35cd6`:
| State | `/auth/me/permissions` `hasAnyQueue` | `crm_account` list |
`crm_contact` list |
|---|---|---|---|
| app-crm as shipped (no queue) | `false` | no toggle | no toggle |
| one `sys_queue` row inserted (201) | `true` | toggle shown | toggle
shown |
| row deleted again | `false` | no toggle | no toggle |
- `crm_account` serves the injected `queue` column (`system: true`,
hidden), so the old rule would have shown the toggle there.
- Pressing the toggle with one queue sends `GET
/api/v1/data/crm_account?…&filter=["and",["owner_id","is_empty",true],["queue","is_not_empty",true]]`,
the same filter as before.
- Network: a list load made 31 or 32 API requests in both states, over
two runs each. The distinct endpoint sets were identical. The
one-request difference is a `sys_user_preference` PATCH that comes and
goes with timing in either state. No request in any run named a queue.
- Acceptance 1 says HotCRM too. HotCRM declares no queue (card reading),
so it gets `hasAnyQueue: false` and the same result. It was not run
here: it lives in another repository.
- Screenshots are in the project files under `issue-28428/`.
## Verification
<details><summary>Local runs at head c0b35cd</summary>
- `pnpm exec vitest run packages/plugin-list/` (from `ui/`): Test Files
179 passed, Tests 1727 passed.
- `pnpm exec vitest run packages/permissions/`: Test Files 16 passed,
Tests 172 passed.
- `pnpm --dir ui exec vitest run scripts/`: Test Files 169 passed, 2
skipped; Tests 4900 passed, 2 skipped.
- `turbo run type-check --filter=@object-ui/plugin-list
--filter=@object-ui/permissions`: 51 of 51 tasks successful.
- `node scripts/pm/dispatch-gates.mjs --commands`: 34 commands, all exit
0 (33 in one loop, plus the ui `scripts/` suite above), including
`check-sdui-manifest.mjs`, `check-changeset-no-major.mjs --base
origin/main`, `check-adr-0087-registration.mjs`,
`check:published-files`, `check:nul-bytes`.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` not touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is CI's run.
- [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: not applicable.
- [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 (the 维护者速读 section is
the Chinese summary the repo asks for).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jUddMTB1CyxjzoKGxi
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUddMTB1CyxjzoKGxi)_
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-list): the list toolbar offers the "In a queue" toggle only when the organization has at least one queue
7
+
8
+
Clause-②: yes (widening)
9
+
Metadata-protocol: none
10
+
11
+
The "In a queue" toggle showed on every list of an owned object, because the platform adds the `queue` column to every such object. In an organization with no queue it could only ever return an empty list. It now appears when both of these hold:
12
+
13
+
-**The object carries the platform's `queue` column**, as before.
14
+
-**The session says the organization has a queue.**`GET /auth/me/permissions` answers `hasAnyQueue` (true when the organization has a declared queue or a `sys_queue` row). The console already reads that answer once per session, so opening a list sends no new request and reads no queue list.
15
+
16
+
When the answer is unknown (no permission provider is mounted, the role-based `PermissionProvider` is used, or the session is anonymous), the toggle stays hidden. Turning the toggle on filters exactly as before, and the server's queue behaviour (claim, release, the read rule) does not change.
17
+
18
+
`@object-ui/permissions`: `PermissionContextValue` gains one optional member, `hasAnyQueue?: boolean`. `MePermissionsProvider` sets it from the authenticated answer. It is `undefined` with no answer.
0 commit comments