Skip to content

Commit 9f352e8

Browse files
feat(studio): the main area adapts when the Studio right slot opens (#35128)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8EYLLcfPhnAg83bCHa7wckF)_ Fixes #35061 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:Studio 右栏打开时主区域自适应——左侧对象 / 流程 / 导航 / 权限集列表在中间区域(列表加内容,右栏与控制台框架之间)不足 900 时收成 52 宽窄栏(每项一个字、悬停显示全名、顶部「»」浮层展开);权限矩阵窗格不足 1000 时只平铺新建 / 查看 / 编辑 / 删除,其余 6 项收进每行「更多权限」(已开 N 项),批量按钮收成「批量」菜单;记录表横向滚动条常显,选中的列自动滚进可见区;右栏可在 320–560 间拖宽,「属性」「AI 助手」各记宽度(默认 360 / 420)。 - 为什么改:右栏打开时主区域被挤到不能用(#35061,方向「挤压但让主区域自适应、不用浮层」已获「同意」)。 - 风险与回滚:只动 Studio 界面与浏览器本地偏好,不碰元数据与接口;收窄全靠 CSS 容器查询,右栏关闭或窗口够宽即恢复原样;旧的共用右栏宽度作废,每栏回到默认一次;回滚即还原本 PR。 - 先看:`StudioRail.tsx` 与 `studio-tokens.ts`(窄栏与浮层,四个栏共用)、`PermissionMatrixEditor.tsx`(矩阵折叠)、`studioRightSlotState.ts`(每栏宽度与 320–560 夹取)。 - 两分钟验证:1280×800 打开 Studio 并打开 AI 助手(420):左侧列表成窄栏,点「»」浮出完整列表、Esc 收回;1440 宽同样打开 AI 助手,列表保持完整;权限页一屏内可勾两个对象的增删改查、「更多权限」点开可改;关掉右栏,列表与 10 列矩阵恢复。 - 需要你做的:无,席位落地。 ## What changes One draft PR for the four items of #35061, on one branch. Items 4 and 1 are this dev's; items 2 and 3 came from a second dev and were merged in with a real merge commit (`0be07d82`). After the merge: `c18a8193` moves item 1's threshold to the pillars host (rail and content together) under 900 px, per the seat's reading of 「中间内容区」, and `d4174efd` brings the permission field-panel e2e in line with item 2's fold (the red `Build & E2E UI` at `0be07d82`). | Item | What | Commit(s) | Tests | |:--|:--|:--|:--| | 1 · left rails narrow | the four rails draw 52 px while the slot is open and the middle region (rail + content) is under 900 px; 「»」 floats the full rail | `007014ce`, `50fedf06`, `6eaa56dc`, `f422b0d4`, `c18a8193` | `StudioRail.noMatches-26733.test.tsx` → describe `the rails' narrow form (objectstack#35061)`; `StudioDesignSurface.rightSlot-12725.test.tsx` → describe `…the rails read whether it squeezes the pillars (objectstack#35061)` | | 2 · permission matrix | under a 1000 px matrix pane: four CRUD columns flat, six behind 「更多权限」, one 「批量」 menu | `b90c8c6e`, `c65c7a66`, `3712d751`, `d4174efd` | `PermissionMatrixEditor.fold-35061.test.tsx` (6 tests); `ui/e2e/permission-field-panel-scroll.spec.ts` Studio 720 px case reads the folded form | | 3 · records table | scrollbar at rest; a selected field's column scrolls into view | `279f7c4c`, `7d6da261` | `DataPillar.recordsScroll-35061.test.tsx` (8 tests) | | 4 · right slot resizable | 320–560 range; properties and copilot each remember their own width (defaults 360 / 420) | `22185a4f`, `1be92568`, `18f0da4f` | `studioRightSlot-12725.test.tsx` → describe `StudioRightSlot pane widths (objectstack#35061)` | **Item 1** (`ui/packages/app-shell/src/views/studio-design/`): while the right slot shows beside the pillars and the middle region it leaves them, the pillars host (rail and content together, between the console chrome and the slot), is under 900 px, every Studio rail (Data, Automations, Interfaces, Access) draws 52 px wide. Each row shows one character of its name (`railAbbreviation`, a whole grapheme, upper-cased in the display locale) as generated content, so the row's text and accessible name are unchanged; the full name is the row's hover. Groups show as a rule; anything that is not a row or a group (empty notes, the nav editor) leaves the narrow list. A 「»」 bar floats the full rail over the content column until a row is picked, Escape (focus back on 「»」) or a click outside. The rule is the `dataTabsFold.ts` way: a CSS container query on the pillars' host (`STUDIO_PILLARS_HOST`, `@max-[900px]`, `STUDIO_RAIL_NARROW_HOST_WIDTH`), plus the host's `data-studio-slot` marker, which the surface sets only while the slot squeezes the pillars (not under `md`). No JS width read, nothing reads an edit mode, and the rail keeps `STUDIO_RAIL_WIDTH` in every pillar and mode (objectui#12519). Phones keep the rail's own overlay. **Item 2** (`views/metadata-admin/PermissionMatrixEditor.tsx`, `permissionMatrixFold.ts`): below a 1000 px matrix pane each Access-pillar object row keeps Create / Read / Edit / Delete flat; the other six (Export, Transfer, View all, Modify all, read and write scope) move behind the row's 「更多权限」 button, which shows 「已开 N 项」 and opens them in a row beneath; the All · Read only · None · Read & write strip becomes one 「批量」 menu. At 1000 px and wider the matrix is the full flat grid. Setup's permission page is a different table and does not fold. **Item 3** (`views/studio-design/recordsGridChrome.ts`, the Data pillar's Records tab): the grid's horizontal scrollbar shows at rest, and a field selected by its column header or from the field list scrolls its column into view, clear of the frozen name column. Column widths, the frozen column and the 400 px long-text ceiling are the runtime grid's, unchanged. **Item 4**: `clampStudioSlotWidth` keeps the slot within 320–560 px and, as before, never so wide that the canvas drops under `DOCK_CONTENT_MIN_WIDTH` (520); the console drawer's `clampDockWidth` is untouched. `useStudioSlotWidth(mode)` keeps one width per pane under `studio-right-slot-width-props` / `studio-right-slot-width-copilot`. The width both panes used to share (`studio-right-slot-width`) is removed on first read, not migrated: carrying it into either pane would override the default the card names for it. The copilot's in-place widen keeps its own width outside the range, and the phone overlay keeps its own fixed width with no handle (card: 「不改手机端」). ## Tests New pins go into each component's existing harness file as a new top-level describe where one exists (the repository rule for a component with a shared harness), and into new files named for #35061 where none does. Existing pins my change made false were updated in place: the slot's old width pin moved to a 1000 px viewport (a 643 px slot is now outside the range), and the Objects rail's row collector in `DataPillar.draftObjectLabel-11843.test.tsx` skips the new 「»」 control. ## Acceptance notes - objectui#12519 read as left-rail only; per-pane widths per #35061 item 4 (maintainer 「同意」 2026-11-17) - Item 1 threshold, the seat's reading: 「中间内容区」 is the middle region between the console chrome and the right slot, the pillars host (rail + content). The rail narrows while the slot is open and that host is under 900 px: with the copilot at 420 px, 1280 narrows (host 860) and 1440 keeps the full rail (host 1020), as the card's acceptance lines read. With the properties pane at its 360 px default a 1280 px window leaves a 920 px host, so the rail stays 240 px there. The slot-open marker stays an input, so a narrow window with the slot closed keeps the full rail. - `Build & E2E UI` was red at `0be07d82` (run 44264198825): `permission-field-panel-scroll.spec.ts`, Studio rendering at a 720 px pane, expected the matrix to scroll past its 1304 px floor and read 720. Root cause is this PR: item 2 drops that floor for the Studio rendering under 1000 px (`PERM_MATRIX_TABLE_FLOOR = '@min-[1000px]:min-w-[1304px]'`), so nothing scrolls there by design. That one case now asserts the folded form (the row's More permissions toggle shows, the matrix fits the pane, every Read and Edit box answers at its centre); the Studio 1000 px and both metadata-admin cases keep the sideways sweep. No test skipped or quarantined. - Item 1: the pillars' host is now a size container, so an unnamed container query inside a pillar with no nearer container answers the host's width (before, it matched nothing). The Studio's own unnamed queries all sit under a nearer container (the item header row, the Data content column, the form designer sections, the matrix pane). - Item 1: the narrow rows' character is generated content with an empty alternative, so a screen reader keeps the row's own name (checked in Chromium: the narrow rail's accessibility tree names each row by its full label). - Clause-② measured no: the `studio` namespace's built declarations type each catalogue as `Record<string, string>`, so no key is published in a type. ## Verification <details><summary>Head d4174ef: the threshold rework and the e2e fix</summary> - Affected tests (`StudioRail.noMatches-26733`, `StudioDesignSurface.rightSlot-12725`, `InterfacesPillar.editRailWidth-12519`, `studioRightSlot-12725`, `DataPillar.draftObjectLabel-11843`): Test Files 5 passed (5), Tests 66 passed (66). `pnpm --filter @object-ui/app-shell type-check`: VERDICT command-exit 0. `tsc -p ui/tsconfig.e2e.json`: exit 0. - `permission-field-panel-scroll.spec.ts` (chromium): at `c18a8193` 1 failed, 5 passed, with CI's reading (`Expected: >= 1304`, `Received: 720`); at `d4174efd` 6 passed, studio-720 reading `scrollWidth 720 / clientWidth 720, covered []`. One-time mutation: `PERM_MATRIX_TABLE_FLOOR` made unconditional (`ablation-replace` anchor 1 to 0) turns the new case red (`Expected length: 1, Received length: 9`, the pane scrolls 720/1304); restored, blob `f11c748f` matches HEAD, `git diff HEAD` empty. The spec bundles from source, so no build was in the path. - `dispatch-gates --commands` at d4174ef: the same 39 families, each run in the foreground with its exit code recorded, all 0; `--ran`: 39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN. `overlap-check` against origin/main `99a0e4fb`: VERDICT clean exit 0. </details> <details><summary>Merged head 0be07d8: type-check, tests, gates</summary> - `pnpm --filter @object-ui/i18n run type-check && pnpm --filter @object-ui/app-shell run type-check`: VERDICT command-exit 0. - The four items' 35061 files, the slot and rail harnesses, `PermissionMatrixEditor.*`, `StudioDesignSurface.access*`: Test Files 62 passed (62), Tests 451 passed (451). - `DataPillar.*`, `StudioDesignSurface.grid*`: Test Files 42 passed (42), Tests 213 passed (213). - Rail-reading suites (`railLabels`, `flowRegistration-12349`, `flowStatusTruth-11779`, `oneSurface-28572`, `railUnboundReason-11281`, `InterfacesPillar.offNav*`), `packages/i18n/`, the product-neutral ratchet: Test Files 112 passed (112), Tests 2109 passed, 13 skipped. - Before the merge, at `6eaa56dc`: all of `views/studio-design/` plus `packages/i18n/`: Test Files 452 passed (452), Tests 4695 passed, 13 skipped. - `dispatch-gates --commands` at 0be07d8: 39 families, each run with its exit code recorded, all 0; `--ran` reconciliation: 39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN. `check:new-line-citations`: 0 new. </details> <details><summary>Item 1 in Chromium (the real StudioRail, server-rendered, its Tailwind classes compiled)</summary> Host width / rail / content, at `c18a8193` (narrow below a 900 px host): 1280 with slot 420 → 860 / 52 / 808; 1280 with slot 360 → 920 / 240 / 680; 1280 slot closed → 1280 / 240 / 1040; 1440 with slot 420 → 1020 / 240 / 780; 1600 with slot 420 → 1180 / 240 / 940; 1024 slot closed → 1024 / 240 / 784. In the narrow form the heading, search, footer, group headers and non-row notes are not displayed and each row's generated content is its first character; floating (1280/420), the panel is 240 px over the content with everything shown. </details> NOT MEASURED: the full console at 1280×800 against a running backend (all four items), reason: no dev stack was started in this container; the layout readings above are from the real rail markup and its compiled CSS, and the matrix and grid layouts from jsdom pins only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbXYKPekZAeSQcgVzBN <!-- signed: repo:objectstack#1 · os-warren · session_01JQwxbXYKPekZAeSQcgVzBN --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent d053c7d commit 9f352e8

20 files changed

Lines changed: 1423 additions & 126 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(studio): the main area adapts when the Studio right slot opens: narrow left rails, a four-column permission matrix, a Records grid that shows its scrollbar, and a resizable right slot
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
- **Left rails narrow.** While the right slot shows beside the Studio pillars and the middle region they leave, list and content together, is under 900 px, the Data, Automations, Interfaces and Access lists draw 52 px wide: each row shows the first character of its name, with the full name on hover. The 「»」 button at the top shows the whole list over the content until a row is picked, Escape or a click outside. Closing the slot or a wider window brings the full list back. Phones are unchanged.
12+
- **Permission matrix (Access pillar, Objects tab).** When the matrix's pane is narrower than 1000 px, each object row keeps Create / Read / Edit / Delete as flat checkboxes. Export, Transfer, View all, Modify all and the read and write scopes move behind the row's "More permissions" button, which shows how many of those six are on ("2 on" / 「已开 2 项」) and opens them in a row beneath. The "All · Read only · None · Read & write" strip folds into one "Bulk" menu with the same four actions. At 1000 px and wider the matrix is the full flat grid it was. The folded controls are the same checkboxes and pickers as the flat columns, so a read-only set locks them the same way. The width rule is a CSS container query on the matrix pane, so it follows the right slot opening, closing or being dragged wider. Setup's permission set page draws a different table and does not fold.
13+
- **Records tab (Data pillar).** The grid's horizontal scrollbar is drawn at rest instead of only under the pointer, so a pane the right slot narrows still shows there are more columns. Selecting a field by its column header, or from the field list, scrolls that column into view, clear of the frozen name column. Column widths, the frozen name column and the 400 px ceiling of a long text column are the runtime grid's, unchanged.
14+
- **Right slot width.** The slot is resized from its left edge within 320–560 px, and the properties pane and the AI copilot each remember their own width in the browser (360 px and 420 px by default). A width both panes shared before this release is not carried over: each pane starts from its default once. The in-place widen of the copilot and the phone overlay keep their own widths.
15+
- New `studio` namespace strings, in en and zh: `engine.studio.rail.expand`, `engine.studio.rail.collapse`, `perm.more.col` and `perm.more.count`.

‎ui/e2e/permission-field-panel-scroll.spec.ts‎

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ import { uiRoot } from '../scripts/ui-root.mjs';
2626
* The whole field panel is now pinned at the cell's inset and no wider than
2727
* the pane shows (`FIELD_PANEL` in `PermissionMatrixEditor.tsx`).
2828
*
29+
* objectstack#35061 (item 2): below a 1000 px pane the Studio rendering folds
30+
* to the four CRUD columns and drops the floor (`permissionMatrixFold.ts`), so
31+
* it no longer scrolls sideways there. The Studio 720 px case reads that
32+
* form: the matrix fits the pane and every box answers at scrollLeft 0. The
33+
* metadata-admin rendering does not fold and keeps its 720 px sweep.
34+
*
2935
* ## Why a Playwright spec and not a vitest test
3036
*
3137
* jsdom and happy-dom have no layout engine: no rect, no sticky offset, no
@@ -412,23 +418,40 @@ test.beforeAll(async () => {
412418
test.describe('an expanded object’s field boxes stay reachable while the matrix scrolls sideways (objectstack#29677)', () => {
413419
test.setTimeout(120_000);
414420

415-
for (const host of ['studio', 'environment'] as const) {
416-
for (const width of [1000, 720]) {
417-
test(`${host} rendering, ${width} px pane: every Read and Edit box answers at its centre at every scroll offset`, async ({
418-
page,
419-
}, testInfo) => {
420-
const readings = await sweep(page, { name: `${host}-${width}`, host, width }, testInfo);
421-
// The pane really scrolls, and far past the card's 80 px.
422-
expect(readings[0].pane.scrollWidth).toBeGreaterThanOrEqual(FLOOR);
423-
expect(readings.at(-1)!.scrollLeft).toBeGreaterThan(80);
424-
expectAllReachable(readings);
425-
// The panel holds its place at the cell's inset whatever the offset.
426-
const lefts = new Set(readings.map((r) => r.panel.left));
427-
expect([...lefts], 'the field panel moved with the scroll').toHaveLength(1);
428-
});
429-
}
421+
// The Studio rendering under 1000 px is folded, not scrolled: its own case below.
422+
const scrolled = [
423+
{ host: 'studio', width: 1000 },
424+
{ host: 'environment', width: 1000 },
425+
{ host: 'environment', width: 720 },
426+
] as const;
427+
for (const { host, width } of scrolled) {
428+
test(`${host} rendering, ${width} px pane: every Read and Edit box answers at its centre at every scroll offset`, async ({
429+
page,
430+
}, testInfo) => {
431+
const readings = await sweep(page, { name: `${host}-${width}`, host, width }, testInfo);
432+
// The pane really scrolls, and far past the card's 80 px.
433+
expect(readings[0].pane.scrollWidth).toBeGreaterThanOrEqual(FLOOR);
434+
expect(readings.at(-1)!.scrollLeft).toBeGreaterThan(80);
435+
expectAllReachable(readings);
436+
// The panel holds its place at the cell's inset whatever the offset.
437+
const lefts = new Set(readings.map((r) => r.panel.left));
438+
expect([...lefts], 'the field panel moved with the scroll').toHaveLength(1);
439+
});
430440
}
431441

442+
test('studio rendering, 720 px pane: the matrix folds to fit the pane (objectstack#35061), nothing scrolls and every Read and Edit box answers', async ({
443+
page,
444+
}, testInfo) => {
445+
const readings = await sweep(page, { name: 'studio-720', host: 'studio', width: 720 }, testInfo);
446+
// The folded form: the row's More permissions toggle is drawn, and the
447+
// matrix is no wider than the pane, so there is no offset to sweep.
448+
await expect(page.getByTestId(`perm-more-toggle-${OBJECT}`)).toBeVisible();
449+
expect(readings).toHaveLength(1);
450+
expect(readings[0].scrollLeft).toBe(0);
451+
expect(readings[0].pane.scrollWidth).toBeLessThanOrEqual(readings[0].pane.clientWidth);
452+
expectAllReachable(readings);
453+
});
454+
432455
test('CONTROL: where the pane holds the whole floor, nothing scrolls and every box answers at scrollLeft 0, as on main', async ({
433456
page,
434457
}, testInfo) => {
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35061 (item 2) — the Studio Objects matrix under a narrow pane:
5+
* below 1000 px only Create / Read / Edit / Delete stay flat; the other six
6+
* permissions sit behind each row's "More permissions" (which counts the ones
7+
* on) and open in a row beneath; the bulk strip folds into one "Bulk" menu.
8+
*
9+
* jsdom applies no CSS, so both forms are in the DOM here and every control is
10+
* reachable: the tests pin which form each element belongs to (the classes the
11+
* pane's container query reads, `permissionMatrixFold.ts`) and that the folded
12+
* controls write and lock exactly as their flat twins do.
13+
*/
14+
15+
import '@testing-library/jest-dom/vitest';
16+
// The source under test reaches these through dynamic imports: their first load is paid at collection.
17+
import '@objectstack/formula';
18+
import '@objectstack/lint';
19+
import '@objectstack/spec/identity';
20+
import { afterEach, describe, expect, it, vi } from 'vitest';
21+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
22+
import { MemoryRouter } from 'react-router-dom';
23+
import { t } from './i18n';
24+
import {
25+
PERM_BULK_COLUMN_WIDTH,
26+
PERM_FLAT_ONLY_CELL,
27+
PERM_FLAT_ONLY_FLEX,
28+
PERM_FOLDED_ONLY,
29+
PERM_MATRIX_FLAT_KEYS,
30+
PERM_MATRIX_FOLD_WIDTH,
31+
PERM_MATRIX_TABLE_FLOOR,
32+
} from './permissionMatrixFold';
33+
34+
type FakeClient = Record<string, (...args: never[]) => unknown>;
35+
36+
let clientImpl: FakeClient;
37+
38+
vi.mock('./useMetadata', () => ({
39+
useMetadataClient: () => clientImpl,
40+
useMetadataTypes: () => ({
41+
loading: false,
42+
error: null,
43+
entries: [{ type: 'permission', label: 'Permission', allowEnvironmentOverlay: true }],
44+
}),
45+
}));
46+
47+
vi.mock('./AssignedUsersSection', () => ({ AssignedUsersSection: () => null }));
48+
49+
import { PermissionMatrixEditPage } from './PermissionMatrixEditor';
50+
51+
afterEach(cleanup);
52+
53+
const en = (k: string) => t(k, 'en');
54+
55+
function makeClient(): FakeClient {
56+
return {
57+
layered: async () => ({
58+
effective: {
59+
name: 'project_editor',
60+
label: 'Project editor',
61+
// a_project: two of the six folded permissions on (Export, a read scope).
62+
objects: {
63+
a_project: { allowRead: true, allowExport: true, readScope: 'own' },
64+
b_task: { allowRead: true },
65+
},
66+
fields: {},
67+
},
68+
code: null,
69+
overlay: null,
70+
overlayScope: null,
71+
}),
72+
getDraft: async () => null,
73+
withPreviewDrafts() {
74+
return this;
75+
},
76+
list: async (type: string) =>
77+
type === 'object' ? [{ item: { name: 'a_project', label: 'Project' } }, { item: { name: 'b_task', label: 'Task' } }] : [],
78+
get: async () => null,
79+
save: async (_type: string, _name: string, payload: Record<string, unknown>) => payload,
80+
};
81+
}
82+
83+
async function renderStudio(readOnly = false) {
84+
clientImpl = makeClient();
85+
render(
86+
<MemoryRouter>
87+
<PermissionMatrixEditPage
88+
type="permission"
89+
name="project_editor"
90+
packageId="app.a"
91+
readOnly={readOnly}
92+
studio={{ tab: 'objects', onTabChange: () => {} }}
93+
/>
94+
</MemoryRouter>,
95+
);
96+
await screen.findByTestId('perm-row-a_project', undefined, { timeout: 5000 });
97+
}
98+
99+
const classesOf = (el: Element) => (el.getAttribute('class') ?? '').split(/\s+/);
100+
const hasAll = (el: Element, cls: string) => cls.split(' ').every((c) => classesOf(el).includes(c));
101+
102+
const FOLDED_ACTIONS = ['export', 'transfer', 'viewAll', 'modifyAll'] as const;
103+
const box = (scope: HTMLElement, obj: string, action: string) =>
104+
within(scope).getByRole('checkbox', { name: `${obj} ${en(`perm.action.${action}`)}` });
105+
106+
async function openBulkMenu(obj: string) {
107+
const trigger = screen.getByTestId(`perm-bulk-menu-${obj}`);
108+
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: 'mouse' });
109+
return screen.findByRole('menu');
110+
}
111+
112+
describe('the fold rule (objectstack#35061)', () => {
113+
it('every class string names the fold width, and the flat four are the CRUD columns', () => {
114+
for (const cls of [PERM_FLAT_ONLY_CELL, PERM_FOLDED_ONLY, PERM_FLAT_ONLY_FLEX, PERM_MATRIX_TABLE_FLOOR, PERM_BULK_COLUMN_WIDTH]) {
115+
expect(cls).toContain(`@min-[${PERM_MATRIX_FOLD_WIDTH}px]:`);
116+
}
117+
expect(PERM_MATRIX_FOLD_WIDTH).toBe(1000);
118+
expect([...PERM_MATRIX_FLAT_KEYS]).toEqual(['allowCreate', 'allowRead', 'allowEdit', 'allowDelete']);
119+
});
120+
});
121+
122+
describe('the Studio Objects matrix, folded under 1000 px (objectstack#35061)', () => {
123+
it('draws only the four CRUD columns in both forms; the other six and the More column belong to one form each', async () => {
124+
await renderStudio();
125+
const table = screen.getByTestId('perm-studio-matrix');
126+
// The 1304 px floor is the flat form's alone.
127+
expect(hasAll(table, PERM_MATRIX_TABLE_FLOOR)).toBe(true);
128+
expect(classesOf(table)).not.toContain('min-w-[1304px]');
129+
130+
const headers = Array.from(table.querySelectorAll('thead th'));
131+
const flatOnly = headers.filter((th) => th.getAttribute('data-perm-fold') === 'flat-only');
132+
expect(flatOnly).toHaveLength(6);
133+
for (const th of flatOnly) expect(hasAll(th, PERM_FLAT_ONLY_CELL)).toBe(true);
134+
for (const key of ['create', 'read', 'edit', 'delete']) {
135+
const th = headers.find((h) => h.getAttribute('title') === en(`perm.action.${key}`));
136+
expect(th).toBeDefined();
137+
expect(th!.getAttribute('data-perm-fold')).toBeNull();
138+
expect(classesOf(th!)).not.toContain('hidden');
139+
}
140+
const more = screen.getByTestId('perm-more-col');
141+
expect(more).toHaveTextContent(en('perm.more.col'));
142+
expect(hasAll(more, PERM_FOLDED_ONLY)).toBe(true);
143+
144+
const row = screen.getByTestId('perm-row-a_project');
145+
const rowFlatOnly = Array.from(row.querySelectorAll('td[data-perm-fold="flat-only"]'));
146+
expect(rowFlatOnly).toHaveLength(6);
147+
for (const td of rowFlatOnly) expect(hasAll(td, PERM_FLAT_ONLY_CELL)).toBe(true);
148+
});
149+
150+
it('the row button counts the folded permissions that are on, and opens them in a row beneath', async () => {
151+
await renderStudio();
152+
const toggle = screen.getByTestId('perm-more-toggle-a_project');
153+
expect(toggle).toHaveTextContent(en('perm.more.count').replace('{count}', '2'));
154+
expect(screen.getByTestId('perm-more-toggle-b_task')).toHaveTextContent(en('perm.more.count').replace('{count}', '0'));
155+
expect(toggle).toHaveAttribute('aria-expanded', 'false');
156+
expect(screen.queryByTestId('perm-more-row-a_project')).toBeNull();
157+
158+
fireEvent.click(toggle);
159+
const moreRow = await screen.findByTestId('perm-more-row-a_project');
160+
expect(toggle).toHaveAttribute('aria-expanded', 'true');
161+
expect(hasAll(moreRow, PERM_FOLDED_ONLY)).toBe(true);
162+
// Directly under its object row.
163+
expect(screen.getByTestId('perm-row-a_project').nextElementSibling).toBe(moreRow);
164+
// The six: four boxes, two scope pickers.
165+
for (const a of FOLDED_ACTIONS) expect(box(moreRow, 'a_project', a)).toBeInTheDocument();
166+
expect(within(moreRow).getAllByRole('checkbox')).toHaveLength(4);
167+
expect(within(moreRow).getByTestId('perm-scope-read-a_project')).toHaveTextContent(en('perm.scope.value.own'));
168+
expect(within(moreRow).getByTestId('perm-scope-write-a_project')).toBeInTheDocument();
169+
expect(box(moreRow, 'a_project', 'export')).toBeChecked();
170+
});
171+
172+
it('a folded box writes the same grant as its flat twin, and the count follows', async () => {
173+
await renderStudio();
174+
fireEvent.click(screen.getByTestId('perm-more-toggle-b_task'));
175+
const moreRow = await screen.findByTestId('perm-more-row-b_task');
176+
const row = screen.getByTestId('perm-row-b_task');
177+
expect(box(row, 'b_task', 'transfer')).not.toBeChecked();
178+
fireEvent.click(box(moreRow, 'b_task', 'transfer'));
179+
await waitFor(() => expect(box(row, 'b_task', 'transfer')).toBeChecked());
180+
expect(box(moreRow, 'b_task', 'transfer')).toBeChecked();
181+
expect(screen.getByTestId('perm-more-toggle-b_task')).toHaveTextContent(en('perm.more.count').replace('{count}', '1'));
182+
});
183+
184+
it('the strip is the flat form, the Bulk menu the folded one; the menu holds the strip four, in order, and writes what they write', async () => {
185+
await renderStudio();
186+
expect(hasAll(screen.getByTestId('perm-bulk-b_task'), PERM_FLAT_ONLY_FLEX)).toBe(true);
187+
const trigger = screen.getByTestId('perm-bulk-menu-b_task');
188+
expect(hasAll(trigger, PERM_FOLDED_ONLY)).toBe(true);
189+
expect(trigger).toHaveTextContent(en('perm.col.bulk'));
190+
191+
const menu = await openBulkMenu('b_task');
192+
expect(within(menu).getAllByRole('menuitem').map((m) => m.textContent)).toEqual([
193+
en('perm.bulk.all'),
194+
en('perm.bulk.read'),
195+
en('perm.bulk.none'),
196+
en('perm.bulk.crud'),
197+
]);
198+
fireEvent.click(within(menu).getByRole('menuitem', { name: en('perm.bulk.crud') }));
199+
const row = screen.getByTestId('perm-row-b_task');
200+
await waitFor(() => {
201+
for (const a of ['create', 'read', 'edit', 'delete']) expect(box(row, 'b_task', a)).toBeChecked();
202+
});
203+
});
204+
205+
it('on a read-only set the folded controls are locked exactly as their flat twins, and the folded row still opens to show them', async () => {
206+
await renderStudio(true);
207+
expect(screen.getByTestId('perm-bulk-menu-a_project')).toBeDisabled();
208+
const toggle = screen.getByTestId('perm-more-toggle-a_project');
209+
expect(toggle).toBeEnabled();
210+
fireEvent.click(toggle);
211+
const moreRow = await screen.findByTestId('perm-more-row-a_project');
212+
const row = screen.getByTestId('perm-row-a_project');
213+
for (const a of FOLDED_ACTIONS) {
214+
expect(box(moreRow, 'a_project', a)).toBeDisabled();
215+
expect(box(row, 'a_project', a)).toBeDisabled();
216+
}
217+
expect(within(moreRow).getByTestId('perm-scope-read-a_project')).toBeDisabled();
218+
expect(within(row).getByTestId('perm-scope-read-a_project')).toBeDisabled();
219+
});
220+
});

0 commit comments

Comments
 (0)