Skip to content

Commit ec9e7de

Browse files
committed
fix(ui): a read-only package's view hides only Delete in Manage views; definitionReadonly replaces readonlyConfigViewable
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgW85kwjGaz7HqsmEuv
1 parent c9d195d commit ec9e7de

3 files changed

Lines changed: 29 additions & 26 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ export function useObjectViewTitleSwitcher({
356356
} as ViewTabItem;
357357
});
358358

359-
// objectstack#35974 — Manage views offers no pin, default, delete or
360-
// rename on a saved view a read-only package ships: the server refuses
361-
// each (it goes to the customization package). Its row is read-only there,
362-
// by the package the row was served under and the session-held `writable`
363-
// verdict objectstack#35933 reads, and its configuration stays offered to
364-
// look at (`readonlyConfigViewable`): the view panel opens read-only.
365-
// Unknown (unread, failed, unlisted) keeps the row as it was. Manage views
366-
// only: the switcher's sections above still read `authored` from
367-
// `isSystem`.
359+
// objectstack#35974 — a saved view a read-only package ships: its
360+
// definition is read-only in Manage views (`definitionReadonly`). The
361+
// server refuses its delete and its panel save, so Delete is not offered
362+
// and the panel opens read-only ("View config"); rename, pin and set as
363+
// default stay, since `updateView` writes those into the package's
364+
// customization pair. Judged by the package the row was served under and
365+
// the session-held `writable` verdict objectstack#35933 reads. Unknown
366+
// (unread, failed, unlisted) keeps the row as it was. Manage views only:
367+
// the switcher's sections above still read `authored` from `isSystem`.
368368
const refusingPackages = usePackagesRefusingSaves(isAdmin
369369
? savedViews.map((sv: any) => studioPackageId(sv)).filter((id: string | null): id is string => id !== null)
370370
: []);
@@ -375,7 +375,7 @@ export function useObjectViewTitleSwitcher({
375375
.map((item) => {
376376
if (item.readonly) return item;
377377
const packageId = studioPackageId(savedViews.find((sv: any) => viewRowId(sv) === item.id));
378-
return packageId !== null && refusingPackages.has(packageId) ? { ...item, readonly: true, readonlyConfigViewable: true } : item;
378+
return packageId !== null && refusingPackages.has(packageId) ? { ...item, definitionReadonly: true } : item;
379379
});
380380
const switcherViews: TitleSwitcherView[] = viewItems.map((item) => {
381381
const personal = personalViewIds.has(item.id);

‎ui/packages/plugin-view/src/ManageViewsDialog.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ const SortableRow: React.FC<RowProps> = ({
171171
// default, pin, edit configuration, delete). Duplicate is preserved
172172
// because it produces a fresh override that *is* mutable.
173173
const isReadonly = !!view.readonly;
174-
// A read-only row whose configuration may still be looked at
175-
// (`ViewTabItem.readonlyConfigViewable`): its configuration entry stays,
176-
// labelled as viewing; nothing else read-only rows hide comes back.
177-
const viewsConfigOnly = isReadonly && !!view.readonlyConfigViewable;
174+
// A row whose definition is read-only but whose row state is not
175+
// (`ViewTabItem.definitionReadonly`): no Delete, and its configuration is
176+
// offered to look at. `readonly` wins.
177+
const definitionReadonly = !isReadonly && !!view.definitionReadonly;
178178

179179
/**
180180
* The overflow menu's entries, each resolved ONCE to the handler it will
@@ -189,10 +189,10 @@ const SortableRow: React.FC<RowProps> = ({
189189
*/
190190
const renameAction = isReadonly ? undefined : onStartRename;
191191
const duplicateAction = onDuplicate;
192-
const configAction = isReadonly && !viewsConfigOnly ? undefined : onConfigView;
192+
const configAction = isReadonly ? undefined : onConfigView;
193193
const setDefaultAction = isReadonly || view.isDefault ? undefined : onSetDefault;
194194
const pinAction = isReadonly ? undefined : onSetPinned;
195-
const deleteAction = isReadonly ? undefined : onDelete;
195+
const deleteAction = isReadonly || definitionReadonly ? undefined : onDelete;
196196
const hasEntryAboveDelete =
197197
!!(renameAction || duplicateAction || configAction || setDefaultAction || pinAction);
198198
const hasMenuEntry = hasEntryAboveDelete || !!deleteAction;
@@ -385,7 +385,7 @@ const SortableRow: React.FC<RowProps> = ({
385385
data-testid={`manage-views-action-config-${view.id}`}
386386
onClick={() => configAction(view.id)}
387387
>
388-
{viewsConfigOnly
388+
{definitionReadonly
389389
? <><Eye className="h-4 w-4 mr-2" /> {vt('view.showViewConfig', 'View config')}</>
390390
: <><Pencil className="h-4 w-4 mr-2" /> {vt('view.editViewConfig', 'Edit view config')}</>}
391391
</DropdownMenuItem>

‎ui/packages/plugin-view/src/ViewTabBar.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,19 @@ export interface ViewTabItem {
197197
/** Optional tooltip shown alongside the lock icon when `readonly` is true. */
198198
readonlyReason?: string;
199199
/**
200-
* On a `readonly` row only: the view's configuration may still be LOOKED
201-
* AT. `ManageViewsDialog` then keeps the row's configuration entry, labelled
202-
* as viewing ("View config", not "Edit view config"), and the host's
203-
* `onConfigView` opens it with nothing to save; every other mutation stays
204-
* hidden. Use it for a view the user may read but the server refuses to
205-
* save (e.g. a view a read-only package ships). Ignored when `readonly` is
206-
* not set, and absent ⇒ a read-only row offers no configuration entry, as
207-
* before. `ViewTabBar` does not read it.
200+
* The view's DEFINITION is read-only while its row state is not: e.g. a
201+
* view a read-only package ships, whose label, pin and default the host
202+
* still writes (into that package's customization), but whose definition
203+
* cannot be saved and which cannot be deleted.
204+
*
205+
* When `true`, `ManageViewsDialog` hides Delete and labels the
206+
* configuration entry as viewing ("View config", not "Edit view config"):
207+
* the host's `onConfigView` opens the configuration with nothing to save.
208+
* Rename, pin and set as default stay offered, and no lock icon is drawn
209+
* (the row is not read-only). `readonly` wins when both are set. Absent ⇒
210+
* the row behaves as before. `ViewTabBar` does not read it.
208211
*/
209-
readonlyConfigViewable?: boolean;
212+
definitionReadonly?: boolean;
210213
/**
211214
* The view's description, already resolved to the viewer's language and
212215
* already gated by the host on the view's `appearance.showDescription`

0 commit comments

Comments
 (0)