Skip to content

Commit 6d86b43

Browse files
fix(studio): offer Customize only on a list view the read-only base ships (#35620)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuRBPAufqjfhippCo9VshjZw)_ Fixes #35600 repo:objectstack#1 · os-sales · session_01L6bhgWTpQUNTBdBhmJtCzk Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 在 Studio 里打开只读软件包的对象页面时,在应用中新建的列表视图不再出现「定制」按钮,属性面板改为说明它是本部署自建的视图、应在应用的「管理视图」里编辑;安装包自带的视图照旧可以定制。 - 替中文客户解决「控制台新建的视图到 Studio 定制、加一列后保存报 403」的问题,这是「视图按岗位分配」那张需求卡里拆出来的第二项。 - 万一判断有误,管理员只会在 Studio 里看不到某个视图的「定制」按钮,视图只读、不写入任何数据;直接撤回本改动即可恢复原状。 - 无 ## What changes On a read-only base, an `object` leaf's page in Studio lists every list view of the object: the base's, views created in the app (the console's New view, a package-less row), and views the pair adds. Customize declares an override of the BASE's view (ADR-0146 D2), and the server refuses that declaration for a view the base does not ship (`NOT_OVERRIDABLE`, 403, "declares an override of …, which ships no view named …"). Studio offered Customize on every listed view, so the first saved edit of a console-made view answered 403. - `useServedOverride` (StudioCustomizeControls.tsx) already reads the layered read at the base for the item. It now also reports what that read served (`shipped`): `base` (a code layer: the base ships the item), `environment` (no code layer, a row stored in this environment: an item no package ships, ADR-0146 D11 environment metadata), `none`, or `null` (not read, or failed). No new request. - The object page's list-view gate (StudioDesignSurface.tsx, `listViewCustomizable`) offers Customize only when the pair already declares an override of the view or the base ships it. Otherwise the view stays read-only and nothing is written. - The list-view panel (ObjectListViewInspector.tsx) takes a `readOnlyNote` in place of the package-read-only sentence: for an `environment` view it says the view was created in this deployment and is edited in the app (Manage views, then the view's menu, Edit view config — measured in the console); for `none` it says the base does not ship the view. - Two new Studio strings, en and zh (`engine.studio.inspector.listView.environmentView`, `…notShipped`). Route taken: the card's second arm ("does not offer Customize on it and says where it is edited"). The first arm (edit in place at the package-less address) was measured and not taken: the server's package-less draft door admits the write (200, env-wide draft), but Studio's Publish on a read-only base publishes the pair's drafts, so such a draft would sit unpublishable from Studio, and ADR-0146 records "No package-less authoring destination survives". The server refusal is unchanged. Branch: `claude/project-thread-5bri48` is harness-assigned (the repo convention would be `claude/issue-35600-…`); noted for the Duplicate Fix Guard. ## Tests New `ui/packages/app-shell/src/views/studio-design/InterfacesPillar.customizePackagelessView-35600.test.tsx`, through the mounted pillar, the real header controls and the real ensure-door client; the metadata double's layered read answers as the server measured for each kind of row, and its draft door refuses an override of a view the base does not ship (403 `NOT_OVERRIDABLE`): - a view created in the app: no Customize, nothing asked or sent, the panel note carries reason `environment` and its sentence; - a view nothing at the base serves (a pair-added view): no Customize, nothing sent, reason `none`; - CONTROL: the base's own view is customized into the pair with `overrides: { package, basedOn }`, and the save is not refused. <details><summary>Test and typecheck readings (head 229fe86)</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/studio-design/InterfacesPillar.customizePackagelessView-35600.test.tsx packages/i18n/` → Test Files 105 passed (105), Tests 1959 passed, 13 skipped (at 229fe86) - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/studio-design/` → Test Files 350 passed (350), Tests 2727 passed (2727) (at e0ccaad; the later commits are the changeset and one module-top import in the new test file) - `pnpm --filter @object-ui/i18n run type-check && pnpm --filter @object-ui/app-shell run type-check` → VERDICT command-exit 0; `tsc -p tsconfig.test.json --listFilesOnly` lists the new test file (1 hit) - Ablation (committed fix, `scripts/ablation-replace.mjs`, source imported directly so no dist build): gate replaced by `listViewAsked;` (anchor 1 → 0, blob 0d83f69 → d407def9) → the `environment` case went red (1 failed, 2 passed); restored blob == HEAD, `git diff HEAD` empty. The `none` case and the CONTROL stay green under the ablation: the pair-added view has no row read at the base, so its header offers no Customize either way; that case pins the note. </details> ## Acceptance notes - Measured on a running server (examples/app-crm, booted code package `com.example.crm` as the read-only base): the console's New view sends `PUT /api/v1/meta/view/NAME?mode=draft` with no package; the published view is served with no `_packageId`; `?package=com.example.crm` lists it not; the object's merged `listViews` in the console carry no `_packageId` (the entry is the flattened config), so they cannot answer the question. The layered read at the base answers it: code layer for the base's views (also when the pair overrides them), `code: null` plus the environment row for the console-made view, 404 for a pair-added view and for a default view the base does not ship. - The same 403 path held for two more views on the object page, and the same predicate covers them: a default view the base does not ship (Customize on it would declare an override of nothing) and a view the pair adds (its own item, which the rail's "Form and list views" entry opens and saves in the pair). On the object page both are now read-only with the `none` note. Whether the object page should edit a pair-added view in the pair (no declaration): the seat answered A, it stays read-only on the object page and the rail entry edits it. - Re-declared (claim correction on #35600, seat-directed): the two new strings widen the published `@object-ui/i18n` key set, so this PR is `Clause-②: yes (widening)`; the claim's file surface adds `ui/packages/i18n/src/namespaces/studio/{en,zh}.ts`. The changeset is `patch` (`Metadata-protocol: none`). - Not a regression: a default list view the read-only base does not ship (the synthesized all-records view) can no longer be customized from the object page; before this PR its first save answered the same 403, and making one would be a new pair item, a product choice not taken here. - Observation, filed as #35624 (measure first): right after the console's New view, the console's draft preview bar read "no unpublished changes" while the drafts feed listed the new package-less draft; read once, not reproduced. ## Verification - Read first: StudioDesignSurface.tsx `listViewCustomizable` / `listViewNotShipped` (the gate; risk: a base view the layered read fails to serve loses Customize, read-only, nothing written); StudioCustomizeControls.tsx `useServedOverride` (`shipped` from the same read; the leaf, navigation and page callers ignore it); the new test file. - Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/studio-design/InterfacesPillar.customizePackagelessView-35600.test.tsx` → 3 passed. - Browser, before and after (examples/app-crm, console Vite dev server on this branch): before, Studio offered Customize on "Verified domestic accounts" (created through the console's Add new view) and adding a column answered `PUT …?package=com.example.crm.custom` 403 `NOT_OVERRIDABLE`; after, no Customize, the panel says where the view is edited; CONTROL "All Opportunities" (the base's) still customizes, `PUT …?package=com.example.crm.custom` 200. <details><summary>Local gates (the --commands derivation for this diff, plus check:changeset-fixed)</summary> Every command below exited 0, at 8157dc1 (`check:test-source-alias` first exited 1 on the new test file, which then took the module-top `import '@objectstack/lint'` it prescribes, and re-ran exit 0): check-adr-0087-registration (base, self-test), check-changeset-no-major, check-closing-keyword-parity (scan, self-test), check-comment-mask-corpus, check-empty-changeset (base, self-test), check-sdui-manifest (scan, self-test), snapshot-next self-test, check-governed-queue-guard self-test, release-rehearsal-clone self-test, release-pending-publish self-test, spec check:duration-unit-keys, check:adr-anchors, check:changeset-gate-self-tests, check:closed-ceremony-text, check:cross-package-test-inputs, check:dispatcher-error-vocabulary, check:driver-memory-census, check:engine-double-contract, check:gitlink-declared, check:nul-bytes, check:published-files, check:query-options-erasure, check:refd-timer-probe, check:registry-log-declared, check:rest-log-spy-declared, check:skill-identifier-liveness, check:test-source-alias, check:tier-file-adoption, check:type-check-coverage, check:type-check-debt, check:undeclared-dep-imports, check:watch-hint-literal, check:where-matcher, check:changeset-fixed; and `pnpm --dir ui exec vitest run --maxWorkers=2 scripts/` → Test Files 171 passed, 2 skipped (173). `overlap-check.mjs` → VERDICT clean exit 0 (origin/main and the one open PR sharing StudioDesignSurface.tsx merge cleanly). The type-check lanes and the wide-population families are CI's. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgWTpQUNTBdBhmJtCzk <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgWTpQUNTBdBhmJtCzk --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3ce6b65 commit 6d86b43

7 files changed

Lines changed: 417 additions & 8 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(studio): Customize is offered only on a list view the read-only base ships
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
On a read-only base, an object's page in Studio lists every list view of the object, including views created in the app (the console's New view) and views the customization package adds. Customize declares an override of the base's view, and the server refuses that declaration for a view the base does not ship, so the first saved edit of such a view answered 403 ("declares an override of …, which ships no view named …"). Studio now reads whether the base ships the view from the layered read at the base (its code layer) and offers Customize only then. A view created in the app is read-only in Studio, and its panel says it is edited in the app, from Manage views › Edit view config; a view the base serves nothing of says the base does not ship it. Two new Studio strings carry those sentences, in English and Chinese.
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35600 (ADR-0146 D2, D11) — on a read-only base, an `object`
5+
* leaf's page lists every list view of the object, and Customize declares an
6+
* override of the BASE's view. The server refuses that declaration for a view
7+
* the base does not ship (`NOT_OVERRIDABLE`, 403). So Customize is offered
8+
* only on a view the base ships, read from the layered read at the base (its
9+
* code layer):
10+
*
11+
* - a view created in the app (a package-less row: no code layer, an
12+
* environment row) offers no Customize, sends nothing, and the panel says
13+
* it is edited in the app;
14+
* - a view nothing at the base serves (a view the pair adds) offers no
15+
* Customize and sends nothing either;
16+
* - CONTROL: the base's own view is still customized into the pair,
17+
* declaring the override.
18+
*
19+
* Through the mounted pillar, the real header controls and the real
20+
* ensure-door client over a fetch stub. The metadata client is a server
21+
* double whose layered read answers as the server does for each kind of row,
22+
* and whose draft door refuses an override of a view the base does not ship
23+
* as the server does.
24+
*/
25+
26+
// Paid at collection, not inside a clocked case (check:test-source-alias).
27+
import '@objectstack/lint';
28+
import '@testing-library/jest-dom/vitest';
29+
import * as React from 'react';
30+
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
31+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
32+
import { MemoryRouter } from 'react-router-dom';
33+
import { ComponentRegistry } from '@object-ui/core';
34+
import { MetadataCtx, type MetadataContextValue } from '@object-ui/react';
35+
36+
const BASE = 'com.example.hotcrm';
37+
const PAIR = 'com.example.hotcrm.custom';
38+
39+
const calendarConfig = (startDateField: string) => ({
40+
type: 'calendar',
41+
data: { provider: 'object', object: 'opportunity' },
42+
columns: ['name', 'stage'],
43+
calendar: { startDateField, titleField: 'name' },
44+
});
45+
46+
/** The base's view: its layered read at the base serves a code layer. */
47+
const BASE_VIEW = {
48+
name: 'opportunity.default',
49+
object: 'opportunity',
50+
viewKind: 'list',
51+
label: 'Close dates',
52+
isDefault: true,
53+
config: calendarConfig('close_date'),
54+
};
55+
/** A view created in the app (the console's New view): bound to no package, so no code layer and an environment row. */
56+
const ENV_VIEW = {
57+
name: 'opportunity.console_made',
58+
object: 'opportunity',
59+
viewKind: 'list',
60+
label: 'Console made',
61+
config: calendarConfig('close_date'),
62+
};
63+
/** A view the pair adds: the layered read at the base answers 404, which the client reads as all layers empty. */
64+
const PAIR_VIEW = {
65+
name: 'opportunity.pair_added',
66+
object: 'opportunity',
67+
viewKind: 'list',
68+
label: 'Pair added',
69+
config: calendarConfig('close_date'),
70+
};
71+
72+
/** The object as the shell's metadata serves it, its views merged in (`mergeViewsIntoObjects`). */
73+
const flat = (v: typeof BASE_VIEW | typeof ENV_VIEW) => ({
74+
...v.config,
75+
name: v.name,
76+
label: v.label,
77+
isDefault: 'isDefault' in v ? v.isDefault : false,
78+
});
79+
const OBJECT_DEF = {
80+
name: 'opportunity',
81+
label: 'Opportunity',
82+
fields: {
83+
name: { name: 'name', label: 'Name', type: 'text' },
84+
stage: { name: 'stage', label: 'Stage', type: 'text' },
85+
close_date: { name: 'close_date', label: 'Close date', type: 'date' },
86+
start_date: { name: 'start_date', label: 'Start date', type: 'date' },
87+
},
88+
listViews: {
89+
[BASE_VIEW.name]: flat(BASE_VIEW),
90+
[ENV_VIEW.name]: flat(ENV_VIEW),
91+
[PAIR_VIEW.name]: flat(PAIR_VIEW),
92+
},
93+
};
94+
95+
const APP = { name: 'crm_app', label: 'CRM', navigation: [{ id: 'nav_opps', type: 'object', label: 'Opportunities', objectName: 'opportunity' }] };
96+
97+
const srv = vi.hoisted(() => ({
98+
ensure: [] as number[],
99+
saves: [] as Array<{ type: string; name: string; body: Record<string, unknown>; opts: Record<string, unknown> }>,
100+
refused: [] as Array<{ name: string; code: string; status: number }>,
101+
}));
102+
103+
const clone = <T,>(v: T): T => JSON.parse(JSON.stringify(v)) as T;
104+
105+
const mockClient = vi.hoisted(() => ({
106+
list: vi.fn(async (type: string) => {
107+
if (type === 'app') return [{ name: 'crm_app', label: 'CRM' }];
108+
if (type === 'object') return [{ name: 'opportunity', label: 'Opportunity' }];
109+
return [];
110+
}),
111+
listDrafts: vi.fn(async () => []),
112+
get: vi.fn(),
113+
references: vi.fn(async () => []),
114+
layered: vi.fn(),
115+
getDraft: vi.fn(async () => null),
116+
save: vi.fn(),
117+
reset: vi.fn(async () => ({ success: true })),
118+
withPreviewDrafts() {
119+
return this;
120+
},
121+
}));
122+
123+
vi.mock('../metadata-admin/useMetadata', async (importOriginal) => {
124+
const mod = await importOriginal<typeof import('../metadata-admin/useMetadata')>();
125+
return {
126+
...mod,
127+
useMetadataClient: () => mockClient,
128+
useMetadataTypes: () => ({ loading: false, error: null, entries: [{ type: 'view', allowEnvironmentOverlay: true }] }),
129+
};
130+
});
131+
132+
vi.mock('@object-ui/react', async (importOriginal) => {
133+
const mod = await importOriginal<typeof import('@object-ui/react')>();
134+
return { ...mod, useAdapter: () => ({}) };
135+
});
136+
137+
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn() } }));
138+
139+
import { InterfacesPillar, type StudioBaseCustomization } from './StudioDesignSurface';
140+
import { ensureCustomizationPackage } from './packages-io';
141+
import { tFormat } from '../metadata-admin/i18n';
142+
import type { PackageCustomizationsState } from './CustomizationMark';
143+
144+
/** Stands in for `plugin-view`'s `object-view`. */
145+
function ObjectViewRecorder({ schema }: { schema: Record<string, unknown> }) {
146+
return <pre data-testid="object-view-schema">{JSON.stringify(schema)}</pre>;
147+
}
148+
149+
const METADATA: MetadataContextValue = {
150+
apps: [],
151+
objects: [OBJECT_DEF],
152+
dashboards: [],
153+
reports: [],
154+
pages: [],
155+
loading: false,
156+
error: null,
157+
refresh: async () => {},
158+
invalidate: () => {},
159+
ensureType: async () => [],
160+
getItem: async () => null,
161+
getItemsByType: () => [],
162+
};
163+
164+
function json(body: unknown, status = 200): Response {
165+
return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });
166+
}
167+
168+
beforeAll(() => {
169+
ComponentRegistry.register('object-view', ObjectViewRecorder as never, { namespace: 'plugin-view' });
170+
});
171+
172+
beforeEach(() => {
173+
srv.ensure.length = 0;
174+
srv.saves.length = 0;
175+
srv.refused.length = 0;
176+
for (const fn of Object.values(mockClient)) (fn as unknown as { mockClear?: () => void }).mockClear?.();
177+
mockClient.get.mockImplementation(async (type: string) => (type === 'object' ? OBJECT_DEF : undefined));
178+
// The layered read at the base, as the server answers it for each kind of row (measured on a running server).
179+
mockClient.layered.mockImplementation(async (type: string, name: string) => {
180+
if (type === 'app') return { code: APP, overlay: null, overlayScope: null, effective: APP };
181+
if (type === 'object') return { code: OBJECT_DEF, overlay: null, overlayScope: null, effective: OBJECT_DEF };
182+
if (name === BASE_VIEW.name) return { code: clone(BASE_VIEW), overlay: null, overlayScope: null, effective: clone(BASE_VIEW) };
183+
if (name === ENV_VIEW.name) return { code: null, overlay: clone(ENV_VIEW), overlayScope: 'env', effective: clone(ENV_VIEW) };
184+
return { code: null, overlay: null, overlayScope: null, effective: null };
185+
});
186+
// The draft door: an override of a view the base does not ship is refused as the server refuses it.
187+
mockClient.save.mockImplementation(async (type: string, name: string, item: unknown, opts: Record<string, unknown> = {}) => {
188+
const body = clone(item) as Record<string, unknown>;
189+
srv.saves.push({ type, name, body, opts: clone(opts) });
190+
if (body.overrides && name !== BASE_VIEW.name) {
191+
srv.refused.push({ name, code: 'NOT_OVERRIDABLE', status: 403 });
192+
throw Object.assign(new Error(`'view/${name}' declares an override of '${BASE}', which ships no view named '${name}'.`), {
193+
status: 403,
194+
code: 'NOT_OVERRIDABLE',
195+
});
196+
}
197+
return { success: true, version: `v${srv.saves.length}`, state: 'draft' };
198+
});
199+
vi.stubGlobal(
200+
'fetch',
201+
vi.fn(async (input: unknown, init?: RequestInit) => {
202+
const path = new URL(String(input), 'http://localhost').pathname;
203+
if (path === `/api/v1/packages/${BASE}/ensure-customization` && init?.method === 'POST') {
204+
const created = srv.ensure.length === 0;
205+
srv.ensure.push(created ? 201 : 200);
206+
return json(
207+
{
208+
success: true,
209+
data: { basePackageId: BASE, packageId: PAIR, namespace: 'hotcrm_custom', dependencyRange: '^4', created, writable: true },
210+
},
211+
created ? 201 : 200,
212+
);
213+
}
214+
return json([]);
215+
}) as unknown as typeof fetch,
216+
);
217+
});
218+
219+
afterEach(() => {
220+
cleanup();
221+
vi.unstubAllGlobals();
222+
});
223+
224+
const MARKS_OFF: PackageCustomizationsState = { status: 'off' };
225+
226+
/** What the Studio surface hands the pillar on a read-only base. */
227+
function Host() {
228+
const [pairId, setPairId] = React.useState<string | null>(null);
229+
const ensurePackage = React.useCallback(async () => {
230+
const answer = await ensureCustomizationPackage(BASE);
231+
setPairId(answer.packageId);
232+
return answer;
233+
}, []);
234+
const ensure = React.useCallback(async () => (await ensurePackage()).packageId, [ensurePackage]);
235+
const customization = React.useMemo<StudioBaseCustomization>(
236+
() => ({ base: BASE, baseLabel: 'HotCRM', basedOn: '4.0.0', walled: false, pairId, ensure, ensurePackage, marks: MARKS_OFF }),
237+
[pairId, ensure, ensurePackage],
238+
);
239+
return <InterfacesPillar packageId={BASE} readOnly customization={customization} />;
240+
}
241+
242+
function mount() {
243+
return render(
244+
<MemoryRouter initialEntries={[`/studio/${BASE}/interfaces`]}>
245+
<MetadataCtx.Provider value={METADATA}>
246+
<Host />
247+
</MetadataCtx.Provider>
248+
</MemoryRouter>,
249+
);
250+
}
251+
252+
const header = () => screen.getByTestId('if-item-header');
253+
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
254+
255+
function setting(key: string): HTMLElement {
256+
const control = document.getElementById(`mdf-studio-list-view-calendar.${key}`);
257+
if (!control) throw new Error(`no calendar.${key} setting`);
258+
return control;
259+
}
260+
261+
async function pick(key: string, text: string) {
262+
await waitFor(() => expect(setting(key)).toBeEnabled(), { timeout: 8000 });
263+
fireEvent.keyDown(setting(key), { key: 'ArrowDown' });
264+
const listbox = await screen.findByRole('listbox');
265+
const hit = within(listbox)
266+
.getAllByRole('option')
267+
.find((o) => (o.querySelector('code')?.previousElementSibling?.textContent ?? o.textContent) === text);
268+
if (!hit) throw new Error(`calendar.${key} lists no "${text}"`);
269+
fireEvent.click(hit);
270+
}
271+
272+
/** The Opportunities page open on its entry's view (the base's default). */
273+
async function openOpportunities(): Promise<void> {
274+
await screen.findByTestId('studio-list-view-inspector', undefined, { timeout: 8000 });
275+
await waitFor(() => expect(setting('startDateField')).toHaveTextContent('Close date'), { timeout: 8000 });
276+
}
277+
278+
/** Pick the view labelled `label` in the header's view switcher. */
279+
async function pickView(label: string, viewId: string): Promise<void> {
280+
fireEvent.click(within(header()).getByTestId('list-view-switcher'));
281+
const menu = await screen.findByTestId('list-view-switcher-menu');
282+
const hit = Array.from(menu.querySelectorAll<HTMLElement>('[data-testid^="view-switcher-row-"]'))
283+
.map((row) => within(row).getAllByRole('button')[0]!)
284+
.find((b) => b.textContent === label);
285+
if (!hit) throw new Error(`the view switcher lists no "${label}"`);
286+
fireEvent.click(hit);
287+
await waitFor(
288+
() => expect(screen.getByTestId('studio-list-view-inspector')).toHaveAttribute('data-view-id', viewId),
289+
{ timeout: 8000 },
290+
);
291+
}
292+
293+
describe('Customize is offered only on a list view the read-only base ships (objectstack#35600)', () => {
294+
it('a view created in the app: no Customize, nothing sent, and the panel says where it is edited', async () => {
295+
mount();
296+
await openOpportunities();
297+
await pickView('Console made', ENV_VIEW.name);
298+
299+
const note = await screen.findByTestId('list-view-read-only');
300+
await waitFor(() => expect(note).toHaveAttribute('data-reason', 'environment'), { timeout: 8000 });
301+
expect(note).toHaveTextContent(tFormat('engine.studio.inspector.listView.environmentView', 'en', { package: 'HotCRM' }));
302+
expect(within(header()).queryByTestId('studio-customize')).toBeNull();
303+
expect(setting('startDateField')).toBeDisabled();
304+
305+
await sleep(1500);
306+
expect(srv.ensure).toEqual([]);
307+
expect(srv.saves).toEqual([]);
308+
expect(srv.refused).toEqual([]);
309+
});
310+
311+
it('a view nothing at the base serves (one the pair adds): no Customize, nothing sent', async () => {
312+
mount();
313+
await openOpportunities();
314+
await pickView('Pair added', PAIR_VIEW.name);
315+
316+
const note = await screen.findByTestId('list-view-read-only');
317+
await waitFor(() => expect(note).toHaveAttribute('data-reason', 'none'), { timeout: 8000 });
318+
expect(note).toHaveTextContent(tFormat('engine.studio.inspector.listView.notShipped', 'en', { package: 'HotCRM' }));
319+
expect(within(header()).queryByTestId('studio-customize')).toBeNull();
320+
321+
await sleep(1500);
322+
expect(srv.ensure).toEqual([]);
323+
expect(srv.saves).toEqual([]);
324+
});
325+
326+
it('CONTROL: the base’s own view is customized into the pair, declaring the override, and the save is not refused', async () => {
327+
mount();
328+
await openOpportunities();
329+
expect(screen.getByTestId('list-view-read-only')).not.toHaveAttribute('data-reason');
330+
331+
fireEvent.click(await within(header()).findByTestId('studio-customize', undefined, { timeout: 8000 }));
332+
await pick('startDateField', 'Start date');
333+
await waitFor(() => expect(srv.saves).toHaveLength(1), { timeout: 8000 });
334+
expect(srv.ensure).toEqual([201]);
335+
const [saved] = srv.saves;
336+
expect(saved).toMatchObject({ type: 'view', name: BASE_VIEW.name, opts: { mode: 'draft', packageId: PAIR } });
337+
expect(saved!.body.overrides).toEqual({ package: BASE, basedOn: '4.0.0' });
338+
expect(srv.refused).toEqual([]);
339+
});
340+
});

‎ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,13 +1277,20 @@ function KanbanCardSection({
12771277
export function ObjectListViewInspector({
12781278
listView,
12791279
readOnly,
1280+
readOnlyNote = null,
12801281
locale,
12811282
selection,
12821283
onSelectionChange,
12831284
onBlockingIssuesChange,
12841285
}: {
12851286
listView: ObjectListViewDraft;
12861287
readOnly: boolean;
1288+
/**
1289+
* objectstack#35600 — why a read-only panel is read-only, when it is not
1290+
* the package's being read-only (a view the base does not ship): shown in
1291+
* that sentence's place, with its reason on the note.
1292+
*/
1293+
readOnlyNote?: { reason: string; text: string } | null;
12871294
locale: string;
12881295
/**
12891296
* objectui#12725 — the column selection, held by the host so a click on a
@@ -1440,8 +1447,12 @@ export function ObjectListViewInspector({
14401447
panel names the view by its label alone; the name stays an attribute. */}
14411448
<div data-testid="studio-list-view-inspector" data-view-id={target.viewId} className="space-y-3">
14421449
{readOnly ? (
1443-
<p className="rounded-md border bg-muted/40 px-2 py-1.5 text-[11px] leading-snug text-muted-foreground" data-testid="list-view-read-only">
1444-
{t('engine.studio.inspector.listView.readOnly', locale)}
1450+
<p
1451+
className="rounded-md border bg-muted/40 px-2 py-1.5 text-[11px] leading-snug text-muted-foreground"
1452+
data-testid="list-view-read-only"
1453+
data-reason={readOnlyNote?.reason}
1454+
>
1455+
{readOnlyNote?.text ?? t('engine.studio.inspector.listView.readOnly', locale)}
14451456
</p>
14461457
) : (
14471458
<p className="text-[11px] leading-snug text-muted-foreground">

0 commit comments

Comments
 (0)