Skip to content

Commit 3f5c947

Browse files
committed
fix(app-shell): a read-only package's view keeps Rename in the options menu; tests follow ruling B
Rename lands in the package's customization pair through updateView (ensure-customization, then PUT ...?package=BASE.custom -> 200, read back after reload), so the options-menu Rename hidden for such a view is offered again. The calculation-menu gate is unchanged. Tests: the factory row offers rename, pin and set default, not Delete; View config opens the panel read-only; custom rows and the unread or failed package list keep every action. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgW85kwjGaz7HqsmEuv
1 parent ec9e7de commit 3f5c947

4 files changed

Lines changed: 101 additions & 82 deletions

File tree

‎ui/packages/app-shell/src/views/ObjectView.readOnlyPackageView-35933.test.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
/**
44
* objectstack#35933 — a view a read-only package ships offers an admin no save
5-
* of its own: no footer calculation menu (objectstack#35702) and no Rename in
6-
* the list's options menu. A shared view the console saved into the
5+
* of its own: no footer calculation menu (objectstack#35702). Its Rename in
6+
* the list's options menu stays (objectstack#35974): the label is written into
7+
* the package's customization pair. A shared view the console saved into the
78
* customization package, and the reader's own view, still offer the menu.
89
*
910
* A dotted view name cannot tell the two apart: every stored view is named
@@ -176,12 +177,14 @@ afterEach(() => {
176177
});
177178

178179
describe('objectstack#35933 — a read-only package\'s view offers no save of its own', () => {
179-
it('a view a read-only package ships: no calculation menu, no Rename', async () => {
180+
it('a view a read-only package ships: no calculation menu; Rename stays (objectstack#35974)', async () => {
180181
mount(SHIPPED.name);
181182
await settle();
182183
await waitFor(() => expect(listProps.current).not.toBeNull());
183184
expect(offersMenu()).toBe(false);
184-
expect(listProps.current?.onRenameView).toBeUndefined();
185+
// objectstack#35974 — the rename lands in the package's customization
186+
// pair (`updateView`), so it is offered.
187+
expect(typeof listProps.current?.onRenameView).toBe('function');
185188
});
186189

187190
it('a shared view saved into the customization package keeps the menu and Rename', async () => {

‎ui/packages/app-shell/src/views/ObjectView.readOnlyPackageViewSaves-35974.test.tsx‎

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

33
/**
4-
* objectstack#35974 — on a list view a read-only package ships, the admin's
5-
* "configure view" panel is read-only (no Save) and Manage views offers no
6-
* pin, no set-as-default and no delete for it: the server refuses each of
7-
* those writes ("save it into the customization package"). A shared view the
8-
* console saved into the customization package and the reader's own view are
9-
* unchanged, and while the package's `writable` verdict is unknown (unread,
10-
* failed read) everything stays offered as before.
4+
* objectstack#35974 (ruling record 7058654416) — on a list view a read-only
5+
* package ships, Manage views hides only Delete and offers its configuration
6+
* as "View config", which opens the panel read-only (no Save): the server
7+
* refuses that view's delete and its panel save. Rename, pin and set as
8+
* default stay: `updateView` writes them into the package's customization
9+
* pair. A shared view the console saved into the customization package and
10+
* the reader's own view are unchanged, and while the package's `writable`
11+
* verdict is unknown (unread, failed read) everything stays offered as before.
1112
*
1213
* The verdict is objectstack#35933's: the package the row was served under
1314
* (`listViews()` carries `_packageId`) and the session-held package list
@@ -175,14 +176,43 @@ function mount(viewId: string) {
175176

176177
const settle = () => act(() => new Promise<void>((resolve) => setTimeout(resolve, 300)));
177178

178-
/** The write affordances Manage views draws on a row: pin, set default, the ⋯ menu (rename, delete). */
179-
const rowOffers = (id: string) => ({
180-
pin: screen.queryByTestId(`manage-views-pin-${id}`) !== null,
181-
setDefault: screen.queryByTestId(`manage-views-default-${id}`) !== null,
182-
menu: screen.queryByTestId(`manage-views-actions-${id}`) !== null,
183-
});
179+
/** The row's own affordances (pin, set default star, lock) and its `…` menu's entries, read by opening it. */
180+
async function rowOffers(id: string) {
181+
const row = {
182+
pin: screen.queryByTestId(`manage-views-pin-${id}`) !== null,
183+
setDefault: screen.queryByTestId(`manage-views-default-${id}`) !== null,
184+
lock: screen.queryByTestId(`manage-views-readonly-${id}`) !== null,
185+
};
186+
const trigger = screen.getByTestId(`manage-views-actions-${id}`);
187+
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });
188+
fireEvent.click(trigger);
189+
await waitFor(() => expect(screen.getByRole('menu')).toBeTruthy());
190+
const entries = ['rename', 'config', 'default', 'pin', 'delete']
191+
.filter((key) => screen.queryByTestId(`manage-views-action-${key}-${id}`) !== null);
192+
const configLabel = screen.queryByTestId(`manage-views-action-config-${id}`)?.textContent?.trim() ?? null;
193+
fireEvent.keyDown(screen.getByRole('menu'), { key: 'Escape' });
194+
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
195+
return { ...row, entries, configLabel };
196+
}
184197

185-
const OFFERED = { pin: true, setDefault: true, menu: true };
198+
/** A row as every savable view is offered: everything, Delete included, "Edit view config". */
199+
const OFFERED = {
200+
pin: true, setDefault: true, lock: false,
201+
entries: ['rename', 'config', 'default', 'pin', 'delete'], configLabel: 'Edit view config',
202+
};
203+
/** A factory row of a read-only package: everything but Delete, "View config", no lock. */
204+
const FACTORY_OFFERS = {
205+
pin: true, setDefault: true, lock: false,
206+
entries: ['rename', 'config', 'default', 'pin'], configLabel: 'View config',
207+
};
208+
209+
/** Open a row's `…` and click its configuration entry. */
210+
async function clickConfig(id: string) {
211+
const trigger = await waitFor(() => screen.getByTestId(`manage-views-actions-${id}`));
212+
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });
213+
fireEvent.click(trigger);
214+
fireEvent.click(await waitFor(() => screen.getByTestId(`manage-views-action-config-${id}`)));
215+
}
186216

187217
beforeEach(() => {
188218
panelProps.current = null;
@@ -194,45 +224,30 @@ afterEach(() => {
194224
cleanup();
195225
});
196226

197-
describe('objectstack#35974 — a read-only package\'s view: read-only panel, no Manage views writes', () => {
198-
it('Manage views offers no pin, set default or delete on the shipped view, and keeps them on the custom one', async () => {
227+
describe('objectstack#35974 — a read-only package\'s view: no Delete, a read-only panel', () => {
228+
it('Manage views: the shipped row offers everything but Delete and "View config"; the custom row is unchanged', async () => {
199229
mount(CUSTOM.name);
200230
await settle();
201231
await waitFor(() => expect(screen.getByTestId(`manage-views-row-${SHIPPED.name}`)).toBeTruthy());
202-
// The ⋯ menu stays, holding only "View config" (next case).
203-
await waitFor(() => expect(rowOffers(SHIPPED.name)).toEqual({ pin: false, setDefault: false, menu: true }));
204-
expect(screen.getByTestId(`manage-views-readonly-${SHIPPED.name}`)).toBeTruthy();
205-
expect(rowOffers(CUSTOM.name)).toEqual(OFFERED);
232+
await waitFor(async () => expect(await rowOffers(SHIPPED.name)).toEqual(FACTORY_OFFERS));
233+
expect(await rowOffers(CUSTOM.name)).toEqual(OFFERED);
206234
});
207235

208-
it('the shipped row\'s "View config" entry opens the panel on that view, read-only', async () => {
236+
it('the shipped row\'s "View config" opens the panel on that view, read-only', async () => {
209237
mount(CUSTOM.name);
210238
await settle();
211-
const trigger = await waitFor(() => screen.getByTestId(`manage-views-actions-${SHIPPED.name}`));
212-
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });
213-
fireEvent.click(trigger);
214-
const entry = await waitFor(() => screen.getByTestId(`manage-views-action-config-${SHIPPED.name}`));
215-
expect(entry.textContent).toContain('View config');
216-
// Nothing else of the row's menu: no rename, set default, pin or delete.
217-
for (const key of ['rename', 'default', 'pin', 'delete']) {
218-
expect(screen.queryByTestId(`manage-views-action-${key}-${SHIPPED.name}`)).toBeNull();
219-
}
220-
fireEvent.click(entry);
239+
await waitFor(async () => expect((await rowOffers(SHIPPED.name)).configLabel).toBe('View config'));
240+
await clickConfig(SHIPPED.name);
221241
await waitFor(() => expect(panelProps.current?.open).toBe(true));
222242
await waitFor(() => expect(panelProps.current?.activeView?.id).toBe(SHIPPED.name));
223243
await waitFor(() => expect(panelProps.current?.readOnly).toBe(true));
224244
expect(panelProps.current?.mode).toBe('edit');
225245
});
226246

227-
it('the custom row\'s entry still reads "Edit view config" and opens the panel savable', async () => {
247+
it('the custom row\'s "Edit view config" opens the panel savable', async () => {
228248
mount(SHIPPED.name);
229249
await settle();
230-
const trigger = await waitFor(() => screen.getByTestId(`manage-views-actions-${CUSTOM.name}`));
231-
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });
232-
fireEvent.click(trigger);
233-
const entry = await waitFor(() => screen.getByTestId(`manage-views-action-config-${CUSTOM.name}`));
234-
expect(entry.textContent).toContain('Edit view config');
235-
fireEvent.click(entry);
250+
await clickConfig(CUSTOM.name);
236251
await waitFor(() => expect(panelProps.current?.activeView?.id).toBe(CUSTOM.name));
237252
await waitFor(() => expect(panelProps.current?.open).toBe(true));
238253
expect(panelProps.current?.readOnly).toBe(false);
@@ -259,16 +274,16 @@ describe('objectstack#35974 — a read-only package\'s view: read-only panel, no
259274
expect(panelProps.current?.readOnly).toBe(false);
260275
// My views are no row of Manage views; the shared rows are judged as ever.
261276
expect(screen.queryByTestId(`manage-views-row-${PERSONAL.id}`)).toBeNull();
262-
await waitFor(() => expect(rowOffers(SHIPPED.name).pin).toBe(false));
263-
expect(rowOffers(CUSTOM.name)).toEqual(OFFERED);
277+
await waitFor(async () => expect(await rowOffers(SHIPPED.name)).toEqual(FACTORY_OFFERS));
278+
expect(await rowOffers(CUSTOM.name)).toEqual(OFFERED);
264279
});
265280

266281
it('while the package list is unread, the shipped view keeps every offer (the server still refuses)', async () => {
267282
packageList.answer = () => new Promise<any[]>(() => {});
268283
mount(SHIPPED.name);
269284
await settle();
270285
await waitFor(() => expect(screen.getByTestId(`manage-views-row-${SHIPPED.name}`)).toBeTruthy());
271-
expect(rowOffers(SHIPPED.name)).toEqual(OFFERED);
286+
expect(await rowOffers(SHIPPED.name)).toEqual(OFFERED);
272287
expect(panelProps.current?.readOnly).toBe(false);
273288
});
274289

@@ -277,7 +292,7 @@ describe('objectstack#35974 — a read-only package\'s view: read-only panel, no
277292
mount(SHIPPED.name);
278293
await settle();
279294
await waitFor(() => expect(screen.getByTestId(`manage-views-row-${SHIPPED.name}`)).toBeTruthy());
280-
expect(rowOffers(SHIPPED.name)).toEqual(OFFERED);
295+
expect(await rowOffers(SHIPPED.name)).toEqual(OFFERED);
281296
expect(panelProps.current?.readOnly).toBe(false);
282297
});
283298
});

‎ui/packages/app-shell/src/views/ObjectView.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
11341134
listViewActions: {
11351135
rename: activeView && activeIsPersonal && personalViewsReady && personalGrant('update')
11361136
? (label: string) => handleRenamePersonalView(String(activeView.id), label)
1137-
: activeView && isAdmin && !activeViewPackageRefusesSaves && savedViews.some((sv: any) => viewRowId(sv) === activeView.id)
1137+
// A read-only package's view is renamed too (objectstack#35974):
1138+
// `updateView` writes the label into its customization pair.
1139+
: activeView && isAdmin && savedViews.some((sv: any) => viewRowId(sv) === activeView.id)
11381140
? async (label: string) => { await handleRenameView(String(activeView.id), label); return true; }
11391141
: undefined,
11401142
save: !isEnvironmentList && canUpdatePersonalView && listPersonalizedParts.length > 0 ? () => { void handleSaveToPersonalView(); } : undefined,

‎ui/packages/plugin-view/src/__tests__/readonlyViewMenus-10209.test.tsx‎

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,50 +110,49 @@ describe('ManageViewsDialog row menu (#10209)', () => {
110110
});
111111
});
112112

113-
describe('ManageViewsDialog `readonlyConfigViewable` (objectstack#35974)', () => {
114-
/** A saved view the server refuses to save: read-only, its configuration still readable. */
115-
const VIEWABLE: ViewTabItem = {
116-
id: 'crm_lead.shipped', label: 'Shipped', type: 'grid', readonly: true, readonlyConfigViewable: true,
117-
};
118-
119-
it('a read-only row with the flag offers only the configuration entry, labelled as viewing', () => {
120-
const onConfigView = vi.fn();
121-
renderDialog([VIEWABLE], { onConfigView });
122-
// No pin, no set default on the row itself.
123-
expect(screen.queryByTestId(`manage-views-pin-${VIEWABLE.id}`)).toBeNull();
124-
expect(screen.queryByTestId(`manage-views-default-${VIEWABLE.id}`)).toBeNull();
125-
expect(screen.getByTestId(`manage-views-readonly-${VIEWABLE.id}`)).toBeInTheDocument();
126-
open(screen.getByTestId(`manage-views-actions-${VIEWABLE.id}`));
127-
expect(menuShape()).toEqual(['menuitem']);
128-
const entry = screen.getByTestId(`manage-views-action-config-${VIEWABLE.id}`);
129-
expect(entry).toHaveTextContent('View config');
130-
expect(entry).not.toHaveTextContent('Edit');
131-
for (const key of ['rename', 'default', 'pin', 'delete']) {
132-
expect(screen.queryByTestId(`manage-views-action-${key}-${VIEWABLE.id}`)).toBeNull();
113+
describe('ManageViewsDialog `definitionReadonly` (objectstack#35974)', () => {
114+
/** A factory view of a read-only package: its definition is read-only, its row state is not. */
115+
const FACTORY: ViewTabItem = { id: 'crm_lead.shipped', label: 'Shipped', type: 'grid', definitionReadonly: true };
116+
117+
it('a definition-read-only row hides only Delete: rename, pin, set default and "View config" stay', () => {
118+
renderDialog([FACTORY]);
119+
// No lock: the row is not read-only.
120+
expect(screen.queryByTestId(`manage-views-readonly-${FACTORY.id}`)).toBeNull();
121+
expect(screen.getByTestId(`manage-views-pin-${FACTORY.id}`)).toBeInTheDocument();
122+
expect(screen.getByTestId(`manage-views-default-${FACTORY.id}`)).toBeInTheDocument();
123+
open(screen.getByTestId(`manage-views-actions-${FACTORY.id}`));
124+
expect(menuShape()).toEqual(['menuitem', 'menuitem', 'menuitem', 'menuitem']);
125+
for (const key of ['rename', 'config', 'default', 'pin']) {
126+
expect(screen.getByTestId(`manage-views-action-${key}-${FACTORY.id}`)).toBeInTheDocument();
133127
}
128+
expect(screen.queryByTestId(`manage-views-action-delete-${FACTORY.id}`)).toBeNull();
129+
const config = screen.getByTestId(`manage-views-action-config-${FACTORY.id}`);
130+
expect(config).toHaveTextContent('View config');
131+
expect(config).not.toHaveTextContent('Edit');
134132
});
135133

136-
it('the entry hands the view to the host\'s `onConfigView`', async () => {
134+
it('its "View config" hands the view to the host\'s `onConfigView`', async () => {
137135
const onConfigView = vi.fn();
138-
renderDialog([VIEWABLE], { onConfigView });
139-
open(screen.getByTestId(`manage-views-actions-${VIEWABLE.id}`));
140-
fireEvent.click(screen.getByTestId(`manage-views-action-config-${VIEWABLE.id}`));
141-
await waitFor(() => expect(onConfigView).toHaveBeenCalledWith(VIEWABLE.id));
142-
});
143-
144-
it('without the flag a read-only row is as before: no `…` trigger, no configuration entry', () => {
145-
renderDialog([{ ...VIEWABLE, readonlyConfigViewable: undefined }]);
146-
expect(screen.queryByTestId(`manage-views-actions-${VIEWABLE.id}`)).toBeNull();
147-
expect(screen.queryByTestId(`manage-views-action-config-${VIEWABLE.id}`)).toBeNull();
136+
renderDialog([FACTORY], { onConfigView });
137+
open(screen.getByTestId(`manage-views-actions-${FACTORY.id}`));
138+
fireEvent.click(screen.getByTestId(`manage-views-action-config-${FACTORY.id}`));
139+
await waitFor(() => expect(onConfigView).toHaveBeenCalledWith(FACTORY.id));
148140
});
149141

150-
it('on a mutable row the flag changes nothing: every entry, "Edit view config"', () => {
151-
renderDialog([{ ...EDITABLE, readonlyConfigViewable: true }], { onDuplicate: vi.fn() });
152-
open(screen.getByTestId(`manage-views-actions-${EDITABLE.id}`));
142+
it('without the flag a row is as before: all six entries, "Edit view config", Delete under a separator', () => {
143+
renderDialog([{ ...FACTORY, definitionReadonly: undefined }], { onDuplicate: vi.fn() });
144+
open(screen.getByTestId(`manage-views-actions-${FACTORY.id}`));
153145
expect(menuShape()).toEqual([
154146
'menuitem', 'menuitem', 'menuitem', 'menuitem', 'menuitem', 'separator', 'menuitem',
155147
]);
156-
expect(screen.getByTestId(`manage-views-action-config-${EDITABLE.id}`)).toHaveTextContent('Edit view config');
148+
expect(screen.getByTestId(`manage-views-action-config-${FACTORY.id}`)).toHaveTextContent('Edit view config');
149+
expect(screen.getByTestId(`manage-views-action-delete-${FACTORY.id}`)).toBeInTheDocument();
150+
});
151+
152+
it('`readonly` wins: a read-only row with the flag is as any read-only row (no `…`, lock drawn)', () => {
153+
renderDialog([{ ...READONLY, definitionReadonly: true }]);
154+
expect(screen.queryByTestId(`manage-views-actions-${READONLY.id}`)).toBeNull();
155+
expect(screen.getByTestId(`manage-views-readonly-${READONLY.id}`)).toBeInTheDocument();
157156
});
158157
});
159158

0 commit comments

Comments
 (0)