Skip to content

Commit c23eafa

Browse files
fix(plugin-list): offer the In a queue filter only where the platform provisions the storage (#30528)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuXpPPZiBKyj1HzrdQ6La3ZH)_ domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2 Fixes #30372 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:外部(联邦)对象的列表不再显示「在队列中」筛选;普通的 `ownership: user` 对象照旧显示。 - 为什么改:外部对象虽然被注入了平台的 `queue` 列,但表结构归远端数据库,该列没有存储,任何一行都不可能进入队列,这个筛选只是噪音。 - 风险与回滚:风险低,只多了一个前置判断,读的是 spec 已有的 `platformProvisionsStorage`;回滚即还原 `ListView.tsx` 中那一行。 - 先看:`ui/packages/plugin-list/src/ListView.tsx` 的 `objectHasOwnershipQueue`(新增首行判断),再看同目录测试文件末尾新增的 describe 块。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-list/src/__tests__/ListView.queueSittingFilter-25769.test.tsx`,预期 15 个测试全部通过。 - 需要你做的:无,席位落地。 ## What changes - `objectHasOwnershipQueue` (plugin-list `ListView.tsx`) now also requires `platformProvisionsStorage(objectDef)` from `@objectstack/spec/data`. On an ADR-0015 `external` object the remote database owns the schema, so the injected `queue` column has no storage and no row can ever sit in a queue (assignment rules skip such objects through `carriesQueueColumn` already). The toggle `queueFilterOffered` therefore stays hidden there. - The import joins the module's existing static `@objectstack/spec/data` import (`resolveInjectedSystemColumns`, `resolveSearchFieldResolution`), so it opens no new subpath in the Console's eager closure. `check:eager-closure` is CI's (Build and E2E UI); not measured locally. - No `packages/**` change: per the server seat's measurement on the card, `/meta/object/...` already serves the `external` block, so the console can read the signal. ## Tests Three pins as a new top-level `describe` in the existing harness `ListView.queueSittingFilter-25769.test.tsx`: - `objectHasOwnershipQueue` is false on an external object carrying the injected column, in map and array `fields` form; - a mounted list of an external object with the injected `queue` column and `hasAnyQueue: true` renders no toggle; - an ordinary `ownership: 'user'` object still renders it. The external fixture is spec-shaped (`datasource: 'legacy_erp'`, `external: { remoteName, writable: false }`). ## Acceptance notes - The fix covers every federated object, not only read-only ones: the injected column is unprovisioned on all of them (server seat's reading on the card). ## Verification All readings at head `9a22376034`, worktree on `origin/main` `a1d0b1ee9e`. <details><summary>Positive control (ablation of the new guard)</summary> Fix committed first; `node scripts/ablation-replace.mjs --delete` on the anchor `if (!platformProvisionsStorage(objectDef)) return false;` (anchor 1 to 0, blob 24b6311 to 1945b6c6c1e4). plugin-list resolves to `src` through the ui vitest alias, so no build is between the edit and the run. - Mutated: `Tests 2 failed | 13 passed (15)`; the two external pins red, the ordinary-object pin green. - Restored: blob equals HEAD (24b6311), `git diff HEAD` empty; `Tests 15 passed (15)`. - A first attempt never acquired the verification lock (`queue-timeout (exit 99)`), restored by the tool, and counts as not run. </details> <details><summary>Package tests and type-check</summary> - `pnpm --filter '@object-ui/plugin-list^...' build`: lock VERDICT command-exit 0. - `pnpm --dir ui exec vitest run packages/plugin-list/`: `Test Files 189 passed (189)`, `Tests 1816 passed (1816)`, exit 0. - `pnpm --filter @object-ui/plugin-list type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): exit 0. </details> <details><summary>Derived gates</summary> `node scripts/pm/dispatch-gates.mjs --ran`: 35 derived families accounted for, 35 run, 0 NOT-MEASURED (all with an exit code recorded, all 0). Includes `pnpm --dir ui exec vitest run scripts/` (`Tests 4985 passed | 2 skipped`). Also run: `pnpm check:changeset-fixed` exit 0 (roster under `.changeset`), `pnpm check:new-line-citations` 0 new citations. Type-check lanes and repo-wide families are CI's. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUR8Nu4M7tbtgES7q2 <!-- signed: domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2 --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 35a8f08 commit c23eafa

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/plugin-list': patch
3+
---
4+
5+
fix(plugin-list): the list's 在队列中 ("In a queue") filter is no longer offered on an external (federated) object
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
An ADR-0015 `external` object is served with the platform's injected `queue` column like any `ownership: 'user'` object, but the remote database owns its schema, so the column has no storage behind it and no row of that table can ever sit in a queue. `objectHasOwnershipQueue` now also requires `platformProvisionsStorage(objectDef)` from `@objectstack/spec/data`, so the toggle appears only on objects whose storage the platform provisions. Ordinary `ownership: 'user'` objects are unchanged.

‎ui/packages/plugin-list/src/ListView.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { useObjectLabel, useSafeFieldLabel, createSafeTranslation, useDisplayLoc
5050
// (objectui#5134).
5151
import { resolveI18nLabel as resolveInlineI18nLabel, normalizeFilterOperator, PaginationConfigSchema } from '@objectstack/spec/ui';
5252
import type { GroupingConfig } from '@objectstack/spec/ui';
53-
import { resolveInjectedSystemColumns, resolveSearchFieldResolution, type SearchFieldMeta } from '@objectstack/spec/data';
53+
import { platformProvisionsStorage, resolveInjectedSystemColumns, resolveSearchFieldResolution, type SearchFieldMeta } from '@objectstack/spec/data';
5454
import { SystemFieldName } from '@objectstack/spec/system';
5555
import { usePermissions } from '@object-ui/permissions';
5656
import { RecordDetailPanel } from '@object-ui/plugin-detail';
@@ -999,8 +999,16 @@ const NO_QUEUE_SITTING_CONDITIONS: ReadonlyArray<QueueSittingCondition> = [];
999999
* records can sit in a queue (the `ownership: 'user'` tier) and refuses an
10001000
* author's own `queue` field on. The filter is offered only there: anywhere
10011001
* else it would name a column the object does not have.
1002+
*
1003+
* The column must also have storage behind it. On an ADR-0015 `external`
1004+
* (federated) object the remote database owns the schema, so the injected
1005+
* `queue` column exists in the registered definition and nowhere else, and no
1006+
* row of that table can ever sit in a queue (assignment rules skip such
1007+
* objects too). The spec's `platformProvisionsStorage` is the one spelling of
1008+
* that verdict, read here rather than re-derived.
10021009
*/
10031010
export function objectHasOwnershipQueue(objectDef: unknown): boolean {
1011+
if (!platformProvisionsStorage(objectDef)) return false;
10041012
const raw = (objectDef as { fields?: unknown } | null | undefined)?.fields;
10051013
const queue = Array.isArray(raw)
10061014
? raw.find((f) => (f as { name?: unknown } | null)?.name === 'queue')

‎ui/packages/plugin-list/src/__tests__/ListView.queueSittingFilter-25769.test.tsx‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* the column, or with an author's own non-system `queue` field, gets no
1919
* toggle, and neither does any object while `hasAnyQueue` is false or
2020
* unknown (no permission provider, or an anonymous answer);
21+
* - storage: an ADR-0015 `external` (federated) object serves the injected
22+
* column too, but the remote database owns its schema, so no row can sit
23+
* in a queue and the toggle is not offered (`platformProvisionsStorage`);
2124
* - the cost: the flag rides the permissions answer the session already
2225
* holds, so a list mount makes the same data-source calls and no other
2326
* request whether or not a queue exists;
@@ -43,14 +46,14 @@ const OBJECT = 'support_ticket';
4346
/** The injected column, as `/meta` serves it on an ownership-queue object. */
4447
const INJECTED_QUEUE = { name: 'queue', type: 'text', system: true, hidden: true };
4548

46-
function dataSourceServing(fields: Record<string, unknown>) {
49+
function dataSourceServing(fields: Record<string, unknown>, extra: Record<string, unknown> = {}) {
4750
return {
4851
find: vi.fn().mockResolvedValue([]),
4952
findOne: vi.fn(),
5053
create: vi.fn(),
5154
update: vi.fn(),
5255
delete: vi.fn(),
53-
getObjectSchema: vi.fn().mockResolvedValue({ name: OBJECT, fields: { subject: { name: 'subject', type: 'text' }, ...fields } }),
56+
getObjectSchema: vi.fn().mockResolvedValue({ name: OBJECT, ...extra, fields: { subject: { name: 'subject', type: 'text' }, ...fields } }),
5457
};
5558
}
5659

@@ -217,3 +220,27 @@ describe('ListView "In a queue" toggle — offered only when the organization ha
217220
}
218221
});
219222
});
223+
224+
describe('ListView "In a queue" toggle — offered only where the platform provisions the storage', () => {
225+
/** An ADR-0015 federated binding, as `/meta` serves it on an external object. */
226+
const EXTERNAL = { ownership: 'user', datasource: 'legacy_erp', external: { remoteName: 'tickets', writable: false } };
227+
228+
it('objectHasOwnershipQueue is false on an external object, even with the injected column', () => {
229+
expect(objectHasOwnershipQueue({ ...EXTERNAL, fields: { queue: INJECTED_QUEUE } })).toBe(false);
230+
expect(objectHasOwnershipQueue({ ...EXTERNAL, fields: [INJECTED_QUEUE] })).toBe(false);
231+
});
232+
233+
it('an external object with the injected queue column: no toggle, though the organization has a queue', async () => {
234+
const ds = dataSourceServing({ queue: INJECTED_QUEUE }, EXTERNAL);
235+
mount(ds, session(true));
236+
await settled(ds);
237+
expect(screen.queryByTestId('queue-sitting-filter')).toBeNull();
238+
expect(JSON.stringify(lastFilter(ds) ?? null)).not.toContain('owner_id');
239+
});
240+
241+
it('an ordinary ownership: user object still offers it', async () => {
242+
const ds = dataSourceServing({ queue: INJECTED_QUEUE }, { ownership: 'user' });
243+
mount(ds, session(true));
244+
expect(await screen.findByTestId('queue-sitting-filter')).toBeTruthy();
245+
});
246+
});

0 commit comments

Comments
 (0)