Skip to content

Commit f9f45d3

Browse files
fix(ui): a view a read-only package ships offers no footer calculation menu and no Rename (#35975)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuVwX4pUdM1qvNLSqRZNSvv3)_ Fixes #35933 Clause-②: no Metadata-protocol: none Skills-docs: none — no authorable metadata changes (Metadata-protocol: none) repo:objectstack#1 · os-sales · session_01L6bhgW85kwjGaz7HqsmEuv ## 维护者速读 - 管理员打开只读包自带的列表视图时,表格底部不再出现「计算」下拉菜单,选项菜单里也不再有「重命名」;自定义包里保存的共享视图和个人视图照旧都有。 - 属于列表页重做专题:替管理员去掉一个点了必被服务器拒绝的入口(之前选完会回滚并弹提示)。 - 出错时最坏情况是该给的菜单没出现,管理员要改共享视图就得走视图设置;读不到包列表时菜单照旧出现,可直接撤回本改动。 - 无。 ## What changes - `@object-ui/data-objectstack` `listViews()`: each row now carries the package the server served it under (the item's `_packageId`), on both arms. The `config`-flattening arm rebuilt the row from `config` and dropped it; the bare-spec arm now also carries an item-level `_packageId` when the spec is nested. The return type is unchanged (a Promise of `any[]`). - `@object-ui/app-shell` `ObjectView`: an admin on a saved shared view is offered the footer calculation pick (`pickSummary`, from #35702) and the options menu's Rename only when the view's package is not one the server's package list carries as read-only. The verdict is the packages row's `writable` (`isWritablePackage`, ADR-0070 D2), read through `usePackagePosture` / `fetchSessionPackages`, the same session-held read the app bar's Studio entries already make, so no new request on a page the app bar has drawn. A row with no package (personal view, stored view bound to none, the `sys_metadata` sentinel) stays savable; the package id is read with the existing `studioPackageId` guard, now exported from `utils/appRoute.ts` (not re-exported from the package entry). - Fails open on purpose: while the list is unread, when the read fails, and for a package the list leaves out (kernel packages), the menu stays as it was before and the server's refusal still applies. - No name-shape rule: every stored view is named `object.key`, the console's own saved shared views included. Read first (risk order): 1. `ui/packages/app-shell/src/views/ObjectView.tsx` — the two `!activeViewPackageRefusesSaves` conditions in `listViewActions` (`rename`, `pickSummary`) and the `activeSavedViewRow` read above them. 2. `ui/packages/app-shell/src/hooks/useStudioDesignGate.ts` — `usePackageRefusesSaves`, the fail-open answer over `usePackagePosture`. 3. `ui/packages/data-objectstack/src/index.ts` — `listViews`' map: `row._packageId` on the flattening arm, the rebuilt bare-spec return. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView.readOnlyPackageView-35933.test.tsx` → 6 passed; the first case reads "a view a read-only package ships: no calculation menu, no Rename". ## Tests - `ui/packages/app-shell/src/views/ObjectView.readOnlyPackageView-35933.test.tsx` (new, 6 cases, real `ObjectView`, `ListView` stand-in recording its props, `fetchSessionPackages` stubbed): a read-only package's view gets no `onColumnSummaryPick` and no `onRenameView`; a customization-package shared view, a view bound to no package and a personal view get the pick; an unread list and a failed read leave the pick on the shipped view. - `ui/packages/data-objectstack/src/listViews.servedPackage-35933.test.ts` (new, 3 cases): a flattened ViewItem row keeps `_packageId` (shipped and custom), a bare spec row keeps it, a row served with none gains none. Runs at head `bfa65e89` (local, under the shared verify lock). `bfa65e89` is the pre-push spelling of this PR's head `fa4ec1b6`: the only change between them is the commit trailer reworded to the model-free pair, and `git diff bfa65e89 fa4ec1b` is empty, so every local reading below is a reading of `fa4ec1b6`'s tree: <details><summary>Targeted suites: 228 files / 2396 tests passed</summary> `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/ObjectView packages/app-shell/src/hooks/useStudioDesignGate packages/app-shell/src/utils/__tests__/appRoute.test.ts packages/app-shell/src/__tests__/spec-symbol-parity.test.ts packages/app-shell/src/layout/__tests__/SidebarItemMenu.designFollowsPackagePosture-12615.test.tsx packages/app-shell/src/views/__tests__/columnSummaryWrite-35702.test.ts packages/data-objectstack/` → `Test Files 228 passed (228)` · `Tests 2396 passed (2396)` · `VERDICT command-exit 0`. That is every `ObjectView*` suite, the Studio-gate and `appRoute` suites, and the whole `@object-ui/data-objectstack` package. The whole `@object-ui/app-shell` package (2357 test files) is declared to CI's Test UI shards, not run locally: a local full run held the shared lock for 20 minutes without finishing and was stopped. </details> <details><summary>Type-check: both packages exit 0</summary> `pnpm --workspace-concurrency=2 --filter @object-ui/data-objectstack --filter @object-ui/app-shell type-check` → both `Done`, `VERDICT command-exit 0` (app-shell's includes `tsc -p tsconfig.test.json`, which compiles the new test). </details> <details><summary>Ablations: each gate reverted, its pin goes red, restore proven</summary> All via `node scripts/ablation-replace.mjs` (anchor hit 1 → 0, blob moved, restore blob == HEAD and `git diff HEAD` empty). The tests import the source relatively, so no `dist/` is in the path. 1. `pickSummary` gate (`: isAdmin && !activeViewPackageRefusesSaves && isSavedViewId(` → `: isAdmin && isSavedViewId(`): "a view a read-only package ships: no calculation menu, no Rename" fails, `expected true to be false`; 5 others pass. 2. Rename gate (`activeView && isAdmin && !activeViewPackageRefusesSaves && savedViews.some(` → without the middle term): the same case fails, `expected [Function] to be undefined`. 3. Adapter carry (the line `if (packageId !== undefined) row._packageId = packageId;` deleted): "a flattened ViewItem row keeps its `_packageId`, shipped or custom" fails; 2 others pass. The bare-spec case passes either way: that arm already kept a spec-level `_packageId`, and the case pins it. </details> ## Acceptance notes - The view settings panel's Save is not gated here (seat ruling, scope A): on a read-only package's view the panel is also how an admin reads the view's configuration, so whether it opens read-only or its entry is hidden is a product choice. Today that save is still refused by the server with the "save it into the customization package" message. Remainder moves to #35974. - The Manage views dialog's pin, set default and delete on such a view are not touched by this PR; they are in #35974 too. - A view a kernel package ships keeps the menu (the package list leaves kernel packages out, so their verdict is unknown here); the server refuses that save as before. ## Verification <details><summary>Derived gate families: 41 derived, 41 run, 0 NOT MEASURED</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (merge base `9ed18a50e`, head `bfa65e89`) derived 41 families. All 41 exited 0. Two needed a second run because the first never got the lock (`vitest run scripts/` exit 99; `check:type-check-debt` exit 3 PREREQUISITE NOT MET). Their reruns under the lock: `scripts/` 172 passed / 2 skipped files, 5111 tests; type-check-debt `0 ledger entr(ies) re-measured ... none above its recorded number`. `--ran` reconciliation with exit codes: `41 run, 0 NOT-MEASURED (a DERIVED zero)`. </details> <details><summary>Clause-② measurement: no</summary> The built declaration `ui/packages/data-objectstack/dist/index.d.ts` still declares `listViews(objectName, options?: { previewDrafts?: boolean })` returning a Promise of `any[]`, as on main. This diff adds no exported type or symbol to a published entry. `@object-ui/app-shell` is `private: true`. The exported `studioPackageId` and `usePackageRefusesSaves` are not re-exported from its entry (`src/index.ts` names `resolveHostAppSegment, appRouteSegment, filterActiveApps` from `./utils` and no Studio-gate hook). </details> Overlap: `node scripts/pm/overlap-check.mjs --branch=claude/issue-35933-view-package-gate` → merges cleanly with `origin/main`, #35918 and #35910 (each shares `ObjectView.tsx`); `VERDICT clean exit 0`. Not browser-verified: NOT MEASURED, reason: no showcase stand was booted for this card. The same refusal path is browser-measured on #35919 (`rt-07`), and the gate is pinned against the real `ObjectView` above. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgW85kwjGaz7HqsmEuv <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgW85kwjGaz7HqsmEuv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d6be99d commit f9f45d3

7 files changed

Lines changed: 399 additions & 8 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/data-objectstack': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
fix(ui): a view a read-only package ships offers no footer calculation menu and no Rename
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
On a list view that ships inside a read-only package (a code or installed package), an admin was offered the footer's calculation menu and the options menu's Rename; the server refuses both saves ("save it into the customization package"), so the pick was taken back with a toast. Neither is offered there now. A shared view the console saved into the customization package, a stored view bound to no package and the reader's own view keep them.
12+
13+
The view's name cannot tell these apart, since every stored view is named `object.key`; the package the row was served under does. `listViews()` in `@object-ui/data-objectstack` now carries the row's served `_packageId` on both of its arms (the `config`-flattening arm dropped it). The console reads the server's `writable` verdict for that package from the package list it already holds for the session, the one the app bar's Studio entries read. While that list is unread, or when the read fails or does not name the package, the menu stays offered as before and the server's refusal still applies.

‎ui/packages/app-shell/src/hooks/useStudioDesignGate.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,25 @@ export function useStudioDesignGate(path: string | null | undefined): string | n
185185
const entry = useStudioEntryGate(path);
186186
return entry?.posture === 'edit' ? entry.path : null;
187187
}
188+
189+
/**
190+
* objectstack#35933 — whether the server refuses a save into `packageId`, by
191+
* the same `writable` verdict and the same session-held read as the Studio
192+
* entries above: `true` only when the package list carries the package as
193+
* read-only (a code or installed package). A list's saved shared view hands
194+
* its served package here, and a view the answer is `true` for is offered no
195+
* save of its own (its changes go to the package's customization, which the
196+
* door says on a refused save).
197+
*
198+
* Fails open, the opposite of the entries above and on purpose: `null` (a
199+
* personal view or a view bound to no package), a read still in flight, a
200+
* failed read and a package the list leaves out (a kernel package) all
201+
* answer `false`, so the save stays offered as it was before this read and
202+
* the server's write gate refuses what it refuses. A save hidden from a
203+
* writable view is the worse failure; one the server refuses is said.
204+
* ⛔ Never a derivation from the view's name: every stored view is named
205+
* `object.key`, the console's own saved shared views included.
206+
*/
207+
export function usePackageRefusesSaves(packageId: string | null): boolean {
208+
return usePackagePosture(packageId) === 'view';
209+
}

‎ui/packages/app-shell/src/utils/appRoute.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,12 @@ export function appStudioRoutePath(
317317
return appStudioDesignPath(app, isWorkspaceAdmin);
318318
}
319319

320-
/** Shared guard: the owning package id usable by the Studio design surface. */
321-
function studioPackageId(app: AppRouteLike | null | undefined): string | null {
320+
/**
321+
* Shared guard: the owning package id usable by the Studio design surface.
322+
* Also the reading of a list's saved view row (objectstack#35933): the row
323+
* carries its served `_packageId`, and the same id names the same package.
324+
*/
325+
export function studioPackageId(app: AppRouteLike | null | undefined): string | null {
322326
const packageId = app?._packageId;
323327
if (typeof packageId !== 'string' || !packageId || packageId === 'sys_metadata') return null;
324328
return packageId;
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#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
7+
* customization package, and the reader's own view, still offer the menu.
8+
*
9+
* A dotted view name cannot tell the two apart: every stored view is named
10+
* `object.key`, the console's own saved views included. What tells them apart
11+
* is the package the row was served under (`listViews()` carries the item's
12+
* `_packageId`) and the server's `writable` verdict for that package, read from
13+
* the session-held package list the Studio entries read (`fetchSessionPackages`).
14+
* While that verdict is unknown the menu stays offered, as it was before: the
15+
* server refuses the save and the pick is taken back.
16+
*
17+
* What runs: the real `ObjectView` on a stub data source. `ListView` is
18+
* replaced by a stand-in that records the props it is handed, so the menu's
19+
* presence is read as the `onColumnSummaryPick` the list receives (the grid
20+
* draws the menu exactly when it has one, pinned in plugin-grid's
21+
* `footerCalculationPicker-35702` tests). The package list is stubbed at
22+
* `fetchSessionPackages`.
23+
*/
24+
25+
import * as React from 'react';
26+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
27+
import { render, cleanup, act, waitFor } from '@testing-library/react';
28+
import { MemoryRouter, Routes, Route } from 'react-router-dom';
29+
// `ObjectView` reaches a dynamic `import('@objectstack/lint')`: pay its load at
30+
// collection, never inside a case's clocked window (`check:test-source-alias`).
31+
import '@objectstack/lint';
32+
33+
vi.mock('@object-ui/permissions', async (importOriginal) => {
34+
const actual = await importOriginal<typeof import('@object-ui/permissions')>();
35+
// Stable identities: `ListView` names `perms` in its fetch dependencies.
36+
const perms = {
37+
check: () => ({ allowed: true }),
38+
checkField: () => true,
39+
getFieldPermissions: () => [],
40+
getRowFilter: () => undefined,
41+
getObjectApiOperations: () => undefined,
42+
roles: [],
43+
isLoaded: false,
44+
hasCapabilities: () => true,
45+
can: () => true,
46+
cannot: () => false,
47+
};
48+
const fieldPerms = { canRead: () => true, canWrite: () => true, permissions: [] };
49+
return { ...actual, usePermissions: () => perms, useFieldPermissions: () => fieldPerms };
50+
});
51+
52+
vi.mock('@object-ui/auth', async (importOriginal) => ({
53+
...(await importOriginal<Record<string, unknown>>()),
54+
useAuth: () => ({ user: { id: 'u1', name: 'Ada' }, activeOrganization: { id: 'org1', name: 'Acme' } }),
55+
// The shared view's saves are an administrator's.
56+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
57+
createAuthenticatedFetch: () => vi.fn(),
58+
}));
59+
60+
vi.mock('@object-ui/collaboration', async (importOriginal) => ({
61+
...(await importOriginal<Record<string, unknown>>()),
62+
useRealtimeSubscription: () => ({ lastMessage: null }),
63+
useConflictResolution: () => ({ hasConflicts: false, resolveAllConflicts: () => {} }),
64+
}));
65+
66+
vi.mock('sonner', () => ({
67+
toast: Object.assign(vi.fn(), {
68+
success: vi.fn(), error: vi.fn(), info: vi.fn(),
69+
warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(),
70+
}),
71+
}));
72+
73+
vi.mock('./MetadataInspector', () => ({
74+
MetadataPanel: () => null,
75+
useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }),
76+
}));
77+
vi.mock('./RecordDetailView', () => ({ RecordDetailView: () => null }));
78+
79+
/** The props the list was last handed. */
80+
const listProps = vi.hoisted(() => ({ current: null as Record<string, any> | null }));
81+
vi.mock('@object-ui/plugin-list', async (importOriginal) => ({
82+
...(await importOriginal<typeof import('@object-ui/plugin-list')>()),
83+
ListView: (props: any) => {
84+
listProps.current = props;
85+
return null;
86+
},
87+
}));
88+
89+
/** The session-held package list, as `GET /api/v1/packages` answers it (parsed). */
90+
const packageList = vi.hoisted(() => ({ answer: (): Promise<any[]> => Promise.resolve([]) }));
91+
vi.mock('./studio-design/packages-io', async (importOriginal) => ({
92+
...(await importOriginal<Record<string, unknown>>()),
93+
fetchSessionPackages: vi.fn(() => packageList.answer()),
94+
}));
95+
96+
import { ObjectView } from './ObjectView';
97+
import { ExpressionProvider } from '../providers/ExpressionProvider';
98+
99+
const OBJECT = 'showcase_task';
100+
const SHIPPED_PACKAGE = 'com.example.showcase';
101+
const CUSTOM_PACKAGE = 'com.example.showcase.custom';
102+
103+
/** A view the read-only code package ships, as `listViews()` serves it. */
104+
const SHIPPED = {
105+
name: `${OBJECT}.in_progress`, object: OBJECT, label: 'In progress', type: 'grid',
106+
columns: ['name', 'amount'], _packageId: SHIPPED_PACKAGE,
107+
};
108+
/** A shared view the console saved: dotted the same way, in the customization package. */
109+
const CUSTOM = {
110+
name: `${OBJECT}.team_tasks`, object: OBJECT, label: 'Team tasks', type: 'grid',
111+
columns: ['name', 'amount'], _packageId: CUSTOM_PACKAGE,
112+
};
113+
/** A stored view bound to no package. */
114+
const UNBOUND = { name: `${OBJECT}.unbound`, object: OBJECT, label: 'Unbound', type: 'grid', columns: ['name', 'amount'] };
115+
/** The reader's own view (`sys_personal_view`). */
116+
const PERSONAL = {
117+
id: 'pv_mine', user_id: 'u1', object_name: OBJECT, label: 'My tasks',
118+
config: { type: 'grid', columns: ['name', 'amount'], data: { provider: 'object', object: OBJECT } },
119+
};
120+
121+
/** The packages row for each id: the server's `writable` verdict. */
122+
const PACKAGES = [
123+
{ id: SHIPPED_PACKAGE, name: 'Showcase', writable: false, namespace: 'showcase' },
124+
{ id: CUSTOM_PACKAGE, name: 'Showcase (custom)', writable: true, namespace: 'showcase' },
125+
];
126+
127+
function mount(viewId: string) {
128+
const dataSource = {
129+
find: vi.fn(async (resource: string) =>
130+
resource === 'sys_personal_view' ? { data: [PERSONAL], total: 1 } : { data: [], total: 0 }),
131+
findOne: vi.fn(async () => null),
132+
create: vi.fn(async () => ({})),
133+
update: vi.fn(async () => ({})),
134+
delete: vi.fn(async () => ({})),
135+
getObjectSchema: vi.fn(async () => ({ name: OBJECT, fields: {} })),
136+
listViews: vi.fn(async () => [SHIPPED, CUSTOM, UNBOUND]),
137+
updateView: vi.fn(async () => ({})),
138+
};
139+
render(
140+
<ExpressionProvider user={{ id: 'u1', name: 'Ada', profile: 'admin' }}>
141+
<MemoryRouter initialEntries={[`/apps/demo/${OBJECT}/view/${encodeURIComponent(viewId)}`]}>
142+
<Routes>
143+
<Route
144+
path="/apps/:appName/:objectName/view/:viewId"
145+
element={
146+
<ObjectView
147+
dataSource={dataSource as never}
148+
objects={[{
149+
name: OBJECT,
150+
label: 'Task',
151+
fields: { name: { type: 'text', label: 'Name' }, amount: { type: 'number', label: 'Amount' } },
152+
}]}
153+
onEdit={() => {}}
154+
/>
155+
}
156+
/>
157+
</Routes>
158+
</MemoryRouter>
159+
</ExpressionProvider>,
160+
);
161+
}
162+
163+
const settle = () => act(() => new Promise<void>((resolve) => setTimeout(resolve, 300)));
164+
165+
/** Whether the list is handed the footer's calculation pick. */
166+
const offersMenu = () => typeof listProps.current?.onColumnSummaryPick === 'function';
167+
168+
beforeEach(() => {
169+
listProps.current = null;
170+
packageList.answer = () => Promise.resolve(PACKAGES);
171+
localStorage.clear();
172+
});
173+
174+
afterEach(() => {
175+
cleanup();
176+
});
177+
178+
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+
mount(SHIPPED.name);
181+
await settle();
182+
await waitFor(() => expect(listProps.current).not.toBeNull());
183+
expect(offersMenu()).toBe(false);
184+
expect(listProps.current?.onRenameView).toBeUndefined();
185+
});
186+
187+
it('a shared view saved into the customization package keeps the menu and Rename', async () => {
188+
mount(CUSTOM.name);
189+
await settle();
190+
await waitFor(() => expect(offersMenu()).toBe(true));
191+
expect(listProps.current?.columnSummaryPickFields).toEqual(['name', 'amount']);
192+
expect(typeof listProps.current?.onRenameView).toBe('function');
193+
});
194+
195+
it('a stored view bound to no package keeps the menu', async () => {
196+
mount(UNBOUND.name);
197+
await settle();
198+
await waitFor(() => expect(offersMenu()).toBe(true));
199+
});
200+
201+
it('the reader\'s own view keeps the menu', async () => {
202+
mount(PERSONAL.id);
203+
await settle();
204+
await waitFor(() => expect(offersMenu()).toBe(true));
205+
});
206+
207+
it('while the package list is unread, the shipped view keeps the menu (the server still refuses)', async () => {
208+
packageList.answer = () => new Promise<any[]>(() => {});
209+
mount(SHIPPED.name);
210+
await settle();
211+
await waitFor(() => expect(offersMenu()).toBe(true));
212+
});
213+
214+
it('a failed package-list read keeps the menu', async () => {
215+
packageList.answer = () => Promise.reject(new Error('offline'));
216+
mount(SHIPPED.name);
217+
await settle();
218+
await waitFor(() => expect(offersMenu()).toBe(true));
219+
});
220+
});

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ import { ManagedUsersInviteLine } from './managedEnvironmentUsers.js';
5656
import { importTargetFields } from './importTargetFields.js';
5757
import { resolveViewId } from '../utils/resolveViewId.js';
5858
import { usePhoneViewport } from '../hooks/usePhoneViewport.js';
59+
import { usePackageRefusesSaves } from '../hooks/useStudioDesignGate.js';
60+
import { studioPackageId } from '../utils/appRoute.js';
5961
import { LIST_PINNED_VIEW_PREFERENCE, objectPreferenceScope, useWorkspacePreference } from '../utils/workspacePreference.js';
6062
import { defaultListViewId, isSavedViewId, viewRowId } from '../utils/viewIdentity.js';
6163
import { useObjectActions } from '../hooks/useObjectActions.js';
@@ -828,6 +830,14 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
828830
// along, and a column the view does not declare is not offered. Each
829831
// resolves whether the pick was saved; on `false` the grid takes it back.
830832
const personalViewRow = activeView ? personalViews.views.find((v) => v.id === activeView.id) : undefined;
833+
// objectstack#35933 — the open saved shared view's own package (its row's
834+
// served `_packageId`), and whether the server refuses saves into it: a
835+
// view a read-only package ships is offered no save of its own. Read for
836+
// an admin only, the one reader offered such a save; unknown offers it.
837+
const activeSavedViewRow = activeView && isAdmin
838+
? savedViews.find((sv: any) => viewRowId(sv) === activeView.id)
839+
: undefined;
840+
const activeViewPackageRefusesSaves = usePackageRefusesSaves(studioPackageId(activeSavedViewRow));
831841
const handlePickPersonalViewSummary = async (field: string, summary: ColumnSummary | null): Promise<boolean> => {
832842
if (!personalViewRow) return false;
833843
const columns = columnsWithSummary(personalViewRow.config.columns as ListColumn[] | string[] | undefined, field, summary);
@@ -1098,7 +1108,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
10981108
listViewActions: {
10991109
rename: activeView && activeIsPersonal && personalViewsReady && personalGrant('update')
11001110
? (label: string) => handleRenamePersonalView(String(activeView.id), label)
1101-
: activeView && isAdmin && savedViews.some((sv: any) => viewRowId(sv) === activeView.id)
1111+
: activeView && isAdmin && !activeViewPackageRefusesSaves && savedViews.some((sv: any) => viewRowId(sv) === activeView.id)
11021112
? async (label: string) => { await handleRenameView(String(activeView.id), label); return true; }
11031113
: undefined,
11041114
save: !isEnvironmentList && canUpdatePersonalView && listPersonalizedParts.length > 0 ? () => { void handleSaveToPersonalView(); } : undefined,
@@ -1116,10 +1126,13 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
11161126
// views is drawn with. Every stored view has a qualified,
11171127
// dotted name, the console's own saved views included
11181128
// (`object.key` in the custom package), so the name cannot
1119-
// tell a view a read-only package ships; the door refuses
1120-
// that save by design (it goes to the custom package) and
1121-
// the refused pick is taken back, as the panel's save is.
1122-
: isAdmin && isSavedViewId(savedViews, String(activeView.id))
1129+
// tell a view a read-only package ships: its row's package
1130+
// does (objectstack#35933), and such a view is offered no
1131+
// menu. While that is unknown the menu stays; the door
1132+
// refuses that save by design (it goes to the custom
1133+
// package) and the refused pick is taken back, as the
1134+
// panel's save is.
1135+
: isAdmin && !activeViewPackageRefusesSaves && isSavedViewId(savedViews, String(activeView.id))
11231136
? handlePickSharedViewSummary
11241137
: undefined,
11251138
summaryPickFields: declaredColumnFields(

‎ui/packages/data-objectstack/src/index.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6481,6 +6481,11 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
64816481
// unpublished view (ADR-0037). The overlay tags the item, not its
64826482
// nested spec, so read from either.
64836483
const isDraft = v._draft === true || spec?._draft === true;
6484+
// objectstack#35933 — the package the server served the row under
6485+
// (the item's `_packageId`, which the overlay stamps on the item,
6486+
// not on a nested spec), carried as served on both arms, so the list
6487+
// can tell a view a read-only package ships from one it may save.
6488+
const packageId = typeof v._packageId === 'string' && v._packageId !== '' ? v._packageId : undefined;
64846489
// Canonical ViewItem (ADR-0017) carries its body under `config`;
64856490
// the display `type` (grid/kanban/gallery/…) lives at `config.type`,
64866491
// and only the list/form *family* sits at the top level (`viewKind`).
@@ -6516,9 +6521,15 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
65166521
}
65176522
row.isDefault = !!spec.isDefault;
65186523
if (isDraft) row._draft = true;
6524+
if (packageId !== undefined) row._packageId = packageId;
65196525
return row;
65206526
}
6521-
return isDraft ? { ...spec, _draft: true } : spec;
6527+
if (!isDraft && (packageId === undefined || spec?._packageId === packageId)) return spec;
6528+
return {
6529+
...spec,
6530+
...(isDraft ? { _draft: true } : {}),
6531+
...(packageId !== undefined ? { _packageId: packageId } : {}),
6532+
};
65226533
});
65236534
} catch (err) {
65246535
// Kept verbatim, on every arm. The console breadcrumb was never the

0 commit comments

Comments
 (0)