Skip to content

Commit 905e423

Browse files
committed
refactor(console): drop Make shared and Unshare; keep the Shared gate, publish-at-once and the gone-view notice (#36409)
#36371 closed as not planned: sharing or unsharing an existing view is not wanted now. Its three measured faults are #36409: Shared offered to an organization administrator the server refuses, a view created Shared left an unpublished draft, and a gone view dropped in silence. This keeps those fixes and removes the row actions, their keys, tests, docs and census row; the dropdown width and the de quote-pair pin go back to main. Claude-Session: https://claude.ai/code/session_01QsR2jTPMb2q2wRssyREqhQ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5bdea0f commit 905e423

25 files changed

Lines changed: 63 additions & 610 deletions

‎.changeset/only-admins-share-views.md‎

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
Clause-②: yes (widening)
7+
Metadata-protocol: none
8+
9+
A shared list view is offered only to an administrator who may write one, and it is shared at once. Add view offers Shared only to an administrator whose session holds `manage_metadata`, the capability the shared view's write door asks; an organization administrator without it is no longer offered a Shared choice the server answers `403`. A view created Shared is saved and published in one act, so everyone sees it on their next read instead of waiting behind a draft; a refused save publishes nothing. A reader who opens a view the server says no longer exists is told so once, and the list shows its default view. Two new `@object-ui/i18n` keys under `view.switcher` carry the notices in every locale.

‎content/docs/ui/views.mdx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,8 @@ The split pane beside an open record keeps the same switcher.
473473
one: a user whose session holds `manage_metadata`, the capability the view's write door
474474
(`PUT /api/v1/meta/view/:name`) asks, so the server refuses everyone else whatever the
475475
Console shows. For that administrator **Add view** offers **Shared** beside **My view**
476-
(**My view** stays the default), each of their own views offers **Make shared**, and a shared
477-
view saved in the app offers **Unshare**, which moves it back into their **My views**. A
478-
view your app authors, a read-only package ships, or a package view's customization has no
479-
**Unshare**. A view created shared, or made shared, is published at once: there is no draft
480-
to publish first. A user who has a view open when it is unshared or deleted is told so, and
476+
(**My view** stays the default). A view created shared is published at once: there is no
477+
draft to publish first. A user who opens a view that has since been deleted is told so, and
481478
the list shows its default view.
482479

483480
## Form View

‎packages/rest/src/meta-write-door-capability-enumeration.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,18 +706,18 @@ describe('#30675 — the data doors refuse on their own capability, not `manage_
706706
});
707707

708708
/**
709-
* [objectstack#36371] Only an administrator makes a list view everyone sees.
709+
* [objectstack#36409] Only an administrator makes a list view everyone sees.
710710
* A shared view is `view` metadata, so the door that shares one is this
711711
* surface's save (the Console saves `?mode=draft` and publishes at once), the
712-
* door that unshares one is the delete, and the publish promotes it. Driven
712+
* publish promotes it, and the delete removes it. Driven
713713
* with the systemPermissions the SHIPPED sets grant, not hand-written ones: a
714714
* member (`member_default`), an organization administrator (that baseline
715715
* plus `organization_admin`, which withholds `manage_metadata`) and the
716716
* platform administrator (`admin_full_access`, the control). The Console asks
717717
* the same capability before it offers Shared (`useCanAuthorMetadata`), so the
718718
* organization administrator's refusal here is why that control is hidden.
719719
*/
720-
describe('#36371 — sharing a list view is an administrator\'s act', () => {
720+
describe('#36409 — sharing a list view is an administrator\'s act', () => {
721721
const grants = (...names: string[]): string[] => {
722722
const held = new Set<string>();
723723
for (const name of names) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
* only, so it never answers for the next URL.
3030
* - `refusal` is set for `denied` alone. Every other verdict leaves the page's
3131
* missing-item face: the server said absence, or said nothing.
32-
* - `absent` (objectstack#36371) is set for `not_found` alone: the server
32+
* - `absent` (objectstack#36409) is set for `not_found` alone: the server
3333
* says the item is not there for anyone, so a page may say it is gone (a
34-
* view unshared or deleted while a reader had it open) rather than fall
34+
* view deleted since the reader's address named it) rather than fall
3535
* back in silence. Unreachable and unknown answers say nothing.
3636
*
3737
* Nothing is cached across mounts: a verdict about the CALLER goes stale the

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

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
700700
? (requestedViewId.includes('.') ? requestedViewId : `${objectDef.name}.${requestedViewId}`)
701701
: null;
702702
const viewAccess = useMetaItemRefusal('view', missedViewName);
703-
// objectstack#36371 — a view the address names that the server says is
704-
// gone (unshared or deleted while the reader had it open): the list opens
705-
// its default view, and says why once per name.
703+
// objectstack#36409 — a view the address names that the server says is
704+
// gone (deleted, or never there): the list opens its default view, and
705+
// says why once per name.
706706
const goneViewNoticed = useRef<string | null>(null);
707707
useEffect(() => {
708708
if (!viewAccess.absent || !missedViewName || goneViewNoticed.current === missedViewName) return;
@@ -1137,30 +1137,21 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
11371137
listSeedRef,
11381138
});
11391139

1140-
// objectstack#36371 — only an administrator holding the shared view's write
1141-
// capability shares views: creates one shared, makes one of their own
1142-
// shared, or unshares one (`./objectViewViewSharing.ts`).
1140+
// objectstack#36409 — only an administrator holding the shared view's write
1141+
// capability creates a shared view, and it is published at once
1142+
// (`./objectViewViewSharing.ts`).
11431143
const canAuthorMetadata = useCanAuthorMetadata();
11441144
const canShareViews = mayShareViews(isAdmin, canAuthorMetadata);
11451145
const sharingApp = useRuntimeCreateApp(t);
1146-
const viewTabItemsRef = useRef<ReadonlyArray<{ id: string; label?: unknown }>>([]);
11471146
const viewSharing = useViewSharing({
11481147
objectName: objectDef.name,
11491148
objectDef,
11501149
metadataClient,
11511150
dataSource,
11521151
app: sharingApp,
1153-
personalViews,
1154-
savedViews,
1155-
viewIds: views.map((v: any) => String(v.id)),
1156-
labelOf: (id) => String(viewTabItemsRef.current.find((item) => item.id === id)?.label ?? id),
1157-
activeViewId,
11581152
routeViewId: viewId,
11591153
navigate,
1160-
pinnedViewId,
1161-
setPinnedViewId: setPinnedViewChoice,
11621154
refresh: () => setRefreshKey((k) => k + 1),
1163-
confirmHandler,
11641155
t,
11651156
});
11661157

@@ -1206,18 +1197,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
12061197
? (id: string) => setPersonalViewDialog({ mode: 'rename', viewId: id })
12071198
: undefined,
12081199
onDeletePersonalView: personalViewsReady ? (id: string) => { void handleDeletePersonalView(id); } : undefined,
1209-
onMakeSharedView: canShareViews && personalViewsReady
1210-
? (id: string) => { void viewSharing.makeShared(id); }
1211-
: undefined,
1212-
// Unsharing makes the view one of the reader's own, so it needs their create.
1213-
onUnshareView: canShareViews && personalViewsReady && personalGrant('create')
1214-
? (id: string) => { void viewSharing.unshare(id); }
1215-
: undefined,
12161200
});
1217-
// Read when an unshare asks for the view's name, after this render.
1218-
useEffect(() => {
1219-
viewTabItemsRef.current = viewTabItems;
1220-
}, [viewTabItems]);
12211201

12221202
// objectstack#35974 — the view panel is read-only on a view a read-only
12231203
// package ships, judged from the SAME answer that drew its Manage views

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

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
*
1313
* Each row offers on hover the reader's ☆ (sidebar Favorites) and 📌 (the
1414
* view this object's list opens by default), and on the reader's own views
15-
* Rename and Delete. For a reader who may share views (objectstack#36371),
16-
* the reader's own views add 「Make shared」 and a shared view saved here adds
17-
* 「Unshare」 (`./objectViewViewSharing.ts`). The trigger (type icon, name, count, caret) and the
15+
* Rename and Delete. The trigger (type icon, name, count, caret) and the
1816
* popover around this body are the switcher's (`./objectViewTitleSwitcher.tsx`).
1917
*/
2018

2119
import { lazy, Suspense, useState, type ComponentType, type ReactNode } from 'react';
2220
import { cn, Input } from '@object-ui/components';
2321
import type { useObjectTranslation } from '@object-ui/i18n';
24-
import { Check, ListOrdered, Lock, Pencil, Pin, Plus, Share2, Star, Trash2 } from 'lucide-react';
22+
import { Check, ListOrdered, Pencil, Pin, Plus, Star, Trash2 } from 'lucide-react';
2523
import type { ListViewFavorites } from '../layout/listViewFavorites.js';
2624
import { VIEW_TYPE_ICONS } from './objectViewHelpers.js';
2725
import type { CreateViewCardProps } from './CreateViewDialog.js';
@@ -60,10 +58,6 @@ export interface ObjectViewSwitcherMenuProps {
6058
onManageViews?: () => void;
6159
onRenamePersonalView?: (viewId: string) => void;
6260
onDeletePersonalView?: (viewId: string) => void;
63-
/** objectstack#36371 — 「Make shared」 on the reader's own views. Absent ⇒ not offered. */
64-
onMakeSharedView?: (viewId: string) => void;
65-
/** objectstack#36371 — 「Unshare」 on the shared views marked `unsharable`. Absent ⇒ not offered. */
66-
onUnshareView?: (viewId: string) => void;
6761
/** 「Add view」 and its card. Absent ⇒ `onAddView`, if any. */
6862
create?: SwitcherCreateOptions;
6963
/** 「Add view」 for a host with no card to offer: the dropdown closes and this runs (the Create View dialog). */
@@ -112,8 +106,6 @@ export function ObjectViewSwitcherMenu({
112106
onManageViews,
113107
onRenamePersonalView,
114108
onDeletePersonalView,
115-
onMakeSharedView,
116-
onUnshareView,
117109
create,
118110
onAddView,
119111
phone = false,
@@ -170,8 +162,6 @@ export function ObjectViewSwitcherMenu({
170162
: t('view.switcher.pin', { defaultValue: 'Pin: open this view by default' });
171163
const renameLabel = t('view.rename', { defaultValue: 'Rename' });
172164
const deleteLabel = t('view.deleteView', { defaultValue: 'Delete View' });
173-
const makeSharedLabel = t('view.switcher.makeShared', { defaultValue: 'Make shared' });
174-
const unshareLabel = t('view.switcher.unshare', { defaultValue: 'Unshare' });
175165
const iconButton = 'flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground max-sm:h-11 max-sm:w-11 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
176166
// Shown on hover or focus, and always while set; a touch screen has no
177167
// hover, so there they always show.
@@ -245,30 +235,6 @@ export function ObjectViewSwitcherMenu({
245235
<Pencil className="h-3.5 w-3.5" />
246236
</button>
247237
)}
248-
{view.personal && onMakeSharedView && (
249-
<button
250-
type="button"
251-
data-testid="view-switcher-make-shared"
252-
aria-label={makeSharedLabel}
253-
title={makeSharedLabel}
254-
onClick={() => { onClose(); onMakeSharedView(view.id); }}
255-
className={cn(iconButton, reveal)}
256-
>
257-
<Share2 className="h-3.5 w-3.5" />
258-
</button>
259-
)}
260-
{!view.personal && view.unsharable && onUnshareView && (
261-
<button
262-
type="button"
263-
data-testid="view-switcher-unshare"
264-
aria-label={unshareLabel}
265-
title={unshareLabel}
266-
onClick={() => { onClose(); onUnshareView(view.id); }}
267-
className={cn(iconButton, reveal)}
268-
>
269-
<Lock className="h-3.5 w-3.5" />
270-
</button>
271-
)}
272238
{view.personal && onDeletePersonalView && (
273239
<button
274240
type="button"

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
import * as React from 'react';
1818
import { describe, it, expect, vi, afterEach } from 'vitest';
1919
import { render, cleanup, screen, fireEvent, within } from '@testing-library/react';
20-
// The switcher's module reaches a dynamic `import('@objectstack/lint')` (the
21-
// draft bar's publish lint): pay its load at collection, never inside a case's
22-
// clocked window (`check:test-source-alias`).
23-
import '@objectstack/lint';
2420
import { ObjectViewTitleSwitcher, type ObjectViewTitleSwitcherProps, type TitleSwitcherView } from './objectViewTitleSwitcher';
2521
import type { ListViewFavorites } from '../layout/listViewFavorites';
2622

@@ -239,44 +235,3 @@ describe('objectstack#30046 — a host with no reader of its own hands no pin an
239235
expect(onViewChange).toHaveBeenCalledWith('board');
240236
});
241237
});
242-
243-
describe('objectstack#36371 — 「Make shared」 and 「Unshare」 on the dropdown rows', () => {
244-
const SHARING_VIEWS: TitleSwitcherView[] = [
245-
{ id: 'all', label: 'All Leads', type: 'grid', authored: true },
246-
{ id: 'crm_lead.team', label: 'Team', type: 'grid', authored: false, unsharable: true },
247-
{ id: 'crm_lead.packaged', label: 'Packaged', type: 'grid', authored: false },
248-
{ id: 'pv_1', label: 'Mine', type: 'grid', authored: false, personal: true },
249-
];
250-
251-
it('a reader who may share gets Make shared on their own views and Unshare on an unsharable shared view only', () => {
252-
const onMakeSharedView = vi.fn();
253-
const onUnshareView = vi.fn();
254-
const { menu } = mount({ views: SHARING_VIEWS, onMakeSharedView, onUnshareView });
255-
const row = (id: string) => within(menu).getByTestId(`view-switcher-row-${id}`);
256-
expect(within(row('pv_1')).getByTestId('view-switcher-make-shared')).toBeInTheDocument();
257-
expect(within(row('pv_1')).queryByTestId('view-switcher-unshare')).toBeNull();
258-
expect(within(row('crm_lead.team')).getByTestId('view-switcher-unshare')).toBeInTheDocument();
259-
expect(within(row('crm_lead.team')).queryByTestId('view-switcher-make-shared')).toBeNull();
260-
// A view the object authors, and a shared view not marked unsharable (a
261-
// package's), offer neither.
262-
for (const id of ['all', 'crm_lead.packaged']) {
263-
expect(within(row(id)).queryByTestId('view-switcher-unshare')).toBeNull();
264-
expect(within(row(id)).queryByTestId('view-switcher-make-shared')).toBeNull();
265-
}
266-
fireEvent.click(within(row('pv_1')).getByTestId('view-switcher-make-shared'));
267-
expect(onMakeSharedView).toHaveBeenCalledWith('pv_1');
268-
});
269-
270-
it('Unshare hands the view id to the host', () => {
271-
const onUnshareView = vi.fn();
272-
const { menu } = mount({ views: SHARING_VIEWS, onUnshareView });
273-
fireEvent.click(within(within(menu).getByTestId('view-switcher-row-crm_lead.team')).getByTestId('view-switcher-unshare'));
274-
expect(onUnshareView).toHaveBeenCalledWith('crm_lead.team');
275-
});
276-
277-
it('a reader who may not share (no handlers) is offered neither, whatever the rows say', () => {
278-
const { menu } = mount({ views: SHARING_VIEWS });
279-
expect(within(menu).queryByTestId('view-switcher-make-shared')).toBeNull();
280-
expect(within(menu).queryByTestId('view-switcher-unshare')).toBeNull();
281-
});
282-
});

0 commit comments

Comments
 (0)