Skip to content

Commit 4ef1ea9

Browse files
feat(console): the sidebar object entry offers Object settings, and the folded list menu leads with it (#36612)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9GPJ8pmbK219Pay95x25Uno)_ Fixes #36487 Clause-②: no Metadata-protocol: none ## 维护者速读 - 系统管理员打开任一对象的列表页(自建应用和安装来的应用都算),点右上角「⋮」,第一项是新加的「对象设置」,点了打开 Studio 里这个对象(能看到字段);左侧菜单对象项「…」里原来的「设计」改成「对象设置」,仪表盘、页面菜单项不再有「设计」。 - 属于「运行界面的设计模式」专题:给列表页一个进入对象设置的入口,替代页头将要去掉的「编辑应用」「在 Studio 中查看」两个按钮。 - 只有系统管理员会看到变化,普通成员不受影响;出错最坏是入口不出现或打开到 Studio 的数据页,可整体撤回。 - 无。 ## What changes 1. **The list's ⋮ More leads with Object settings.** `ObjectViewMoreMenu` (`objectViewPageHeader.tsx`) takes the gated path from `ObjectViewPageBarActions` and draws `ObjectSettingsMenuItem` first, above the object's description, Import and the favorites entry, with a separator after it. It opens `appStudioObjectPath`: the object in Studio's Data surface, where its fields are. No separate Manage fields entry. The two existing entries are unchanged. - The narrow header's folded ⋯ (`objectViewHeaderChrome.tsx`) leads with the same entry (`object_view_object_settings`). 2. **Admins only, built and installed apps alike.** One gate for every menu that draws the entry: `useObjectSettingsGate(path)` is the app bar's `useStudioEntryGate` in either posture. A writable package (an app built here) gives `edit` and a read-only one (an installed app) gives `view`. A kernel package's app and a member get nothing. No new admin check. 3. **The sidebar ⋯ menu.** An `object` entry (and an `object:` favorite) offers **Object settings** where it offered Design, with the same destination as item 1. A `dashboard`, `page` or `report` entry, and such a favorite, offers no Studio entry. `sidebarItemDesignPath` / `favoriteDesignPath` keep their names (their caller `UnifiedSidebar.tsx` is outside this card's surface) and now answer for objects only. The sidebar entry now shows on read-only (installed) packages too, through the one shared gate (accepted in the claim amendment). 4. **Unsaved edits.** Every entry navigates through `confirmUnsavedLeave`, the existing seam (item 4, kept literal per the claim amendment). `console.nav.design` is replaced by `console.nav.objectSettings` in all 11 locale packs (no existing key to reuse; the Chinese text is the card's own 对象设置). Changeset: `.changeset/36487-object-settings-entry.md` (`@object-ui/app-shell`, `@object-ui/i18n`, patch). ### Read first 1. `ui/packages/app-shell/src/layout/SidebarItemMenu.tsx`: `useObjectSettingsGate` (the posture choice: read-only packages get the entry) and `sidebarItemDesignPath` (dashboard and page dropped). 2. `ui/packages/app-shell/src/views/objectViewPageHeader.tsx`: `ObjectViewPageBarActions` reads the route and the gate; `ObjectViewMoreMenu` draws the entry first. 3. `ui/packages/app-shell/src/views/objectViewHeaderChrome.tsx`: the hook now reads the route and the gate itself. ### Two-minute check As a workspace admin, open HotCRM's Accounts list and click ⋮ at the right end of the view bar. The first entry reads Object settings, and it opens `/studio/PACKAGE/data?surface=object:account`. As a member, the same ⋮ shows the description and Add to favorites only. ## Acceptance (card) against this PR | Card line | Status | |---|---| | Built app list ⋮: first item Object settings, opens the object in Studio | Done, pinned (writable package) | | HotCRM list ⋮: same | Done, pinned (read-only package) | | Member: no Object settings in ⋮ | Done, pinned (member, admin without authoring, kernel app) | | Sidebar object entry ⋯: Object settings, no Design, same destination | Done, pinned | | Sidebar dashboard entry ⋯: no Design | Done, pinned (navigation entry and favorite) | | Sorted, unsaved list, then Object settings: unsaved prompt | Dropped by the area as a false premise (claim amendment); the entry goes through the existing seam, pinned with a registered edit | | Before/after screenshots | NOT MEASURED, reason below | ## Tests Forced edits to existing tests (each because Design became Object settings, or because its rule changed): - `SidebarItemMenu-12427.test.tsx`: labels; `sidebarItemDesignPath` now null for page, dashboard and report entries. - `SidebarItemMenu.designAsksUnsaved-13231.test.tsx`: label only. - `SidebarItemMenu.designFollowsPackagePosture-12615.test.tsx`: a read-only (installed) package's entry and favorite now list Object settings; a kernel favorite and a member get none (new cases). - `SidebarItemMenu.designOpensStudio-12520.test.tsx`: dashboard and page entries and favorites now answer null. - `UnifiedSidebar.favoritesMenu-12427.test.tsx`: labels, plus a dashboard favorite's menu offers no Studio entry. New: - `views/objectViewPageHeader.objectSettings-36487.test.tsx`: the list ⋮ shows Object settings first, above the description, for an admin on a writable package and on a read-only one. A member, an admin without authoring and a kernel app get none. With an unsaved edit registered, the click asks and Cancel stays; OK opens the object in Studio. A control case with nothing registered opens Studio without asking. - `views/__tests__/objectViewHeaderChrome.objectSettings-36487.test.tsx`: the folded menu, same four questions. <details><summary>Readings (head b3af5fd)</summary> - Lock depth before each locked run: depth 1, hold at 2, go. - At caeacab: touched suites, both new pins, the seven ObjectView header suites and all of `packages/i18n/`: 121 files, 2121 passed, 13 skipped; lock VERDICT command-exit 0. - b3af5fd changes one test file only (the folded-menu pin read the router address through a module variable, which `Lint UI` refused); both new pins re-run there: 2 files, 11 passed, VERDICT command-exit 0. `pnpm run lint` in `ui/packages/app-shell`: exit 0, 0 errors. - Type check: `turbo run type-check --filter=@object-ui/app-shell`, 69/69 tasks successful (`tsc --noEmit` and `tsconfig.test.json`). - Ablation (list ⋮ item): `scripts/ablation-replace.mjs` turned `{objectSettingsPath && (` into a constant-false guard (anchor 1 to 0, blob b3d6a42 to 3d8f5609); the new pin went 4 failed / 3 passed (the member, no-authoring and kernel cases stay green, as they should); restored, blob equal to HEAD b3d6a42, `git diff HEAD` empty. - Ablation (gate, earlier head 4958e70): `useObjectSettingsGate` mutated to the edit-only posture; 3 cases red; restored, blob equal to HEAD. - ui gates: `check:i18n-keys`, `check:spec-symbols`, `check:icon-record-names`, `check:new-line-citations` all exit 0. - Derived gates (`dispatch-gates --commands`, 41 commands): all 41 exit 0 on head b3af5fd; `--ran` reconciliation: 41 derived, 41 run, 0 NOT-MEASURED, 0 UNRUN. </details> ## Acceptance notes - The sorted-unsaved-list line: the list's unsaved sort lives in the list draft store. That store never registers with the unsaved-edits seam and is built to survive in-app departures. One-off reading: after `patchListDraft(scope, sort desc)`, `confirmUnsavedLeave` asked 0 times and ran the departure once. The area kept item 4 literal and dropped that line (claim amendment). - Phone: the phone's top-row ⋮ is built in `ObjectView.tsx`, outside this card; not offered there (noted by the area for a later card). - `UnifiedSidebar.tsx` still says "Design" in a comment and passes `designPath`; outside this card's surface, left as is. - Screenshots NOT MEASURED: no Console was booted in this container for this card. The dispatch allowed the lightest dogfood path only when the lock and a console fit in reasonable time, and every acceptance line above is pinned by a unit test instead. Session: https://claude.ai/code/session_01ADHkmRGDrq6JSytBsNFabU 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRGDrq6JSytBsNFabU --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 70f6790 commit 4ef1ea9

22 files changed

Lines changed: 651 additions & 196 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): the sidebar's object entry offers Object settings in place of Design, and dashboard and page entries no longer offer Design
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A sidebar entry's ⋯ menu used to offer Design for an object, a dashboard or a page entry, and only on an app whose package Studio lists as writable. An object entry, and an object favorite, now offer Object settings instead, which opens the object in Studio's Data surface, where its fields are. It is offered to a workspace admin who may author metadata on an app built here and on an installed app alike; an installed app's package opens in Studio's browse-only posture. A dashboard, page or report entry offers no Studio entry any more: each is edited on its own page. Object settings asks first when the page on screen holds unsaved edits, as Design did.
12+
13+
The list header's folded ⋯ menu, drawn when the header is too narrow for its actions, leads with the same Object settings entry under the same rule.
14+
15+
The `console.nav.design` translation key is replaced by `console.nav.objectSettings` in every locale pack.

‎ui/packages/app-shell/src/layout/SidebarItemMenu.tsx‎

Lines changed: 101 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
* 1. Add to favorites / Remove from favorites, always, first.
1010
* 2. Open in new tab and Copy link, for an entry that goes somewhere (an
1111
* `action` entry runs something and has no address to open or copy).
12-
* 3. Design, for an entry whose target has a designer: it opens what the app
13-
* bar's Edit app opens for that item, the item's Studio surface
14-
* ({@link sidebarItemDesignPath}, objectui#12520). Shown on the rule the app
15-
* bar's Edit app follows, `useStudioDesignGate` (objectui#12615): to a
16-
* principal who may author metadata, for a package Studio lists as
17-
* writable. A read-only package and the console's own system apps get no
18-
* Design entry. The server refuses the write either way; this is the
19-
* presentational half.
12+
* 3. Object settings, for an `object` entry (objectstack#36487): it opens the
13+
* object in Studio, where its fields are ({@link sidebarItemDesignPath}),
14+
* the entry the list page's ⋮ leads with ({@link ObjectSettingsMenuItem}).
15+
* Shown on the rule the app bar's Studio entry follows,
16+
* `useStudioEntryGate` (objectui#12615, #27356 row 12): to a principal who
17+
* may author metadata, for a package Studio lists, writable (built here) or
18+
* read-only (installed). The console's own system apps get none. A
19+
* dashboard, page or report entry gets no Studio entry here any more: each
20+
* is edited on its own page. The server refuses a write either way; this
21+
* is the presentational half.
2022
*
2123
* The trigger is hover-revealed, as the pin icon it replaces was
2224
* (objectui#1055): nothing is permanently visible. A right-click anywhere on the
@@ -38,101 +40,122 @@ import {
3840
DropdownMenuTrigger,
3941
SidebarMenuAction,
4042
} from '@object-ui/components';
41-
import { ExternalLink, Link2, MoreHorizontal, PencilRuler, Star, StarOff } from 'lucide-react';
43+
import { ExternalLink, Link2, MoreHorizontal, Settings2, Star, StarOff } from 'lucide-react';
4244
import { toast } from 'sonner';
4345
import type { NavigationItem } from '@object-ui/types';
4446
import { useObjectTranslation } from '@object-ui/i18n';
45-
import { useStudioDesignGate } from '../hooks/useStudioDesignGate.js';
47+
import { useStudioEntryGate } from '../hooks/useStudioDesignGate.js';
4648
import { useFavorites } from '../hooks/useFavorites.js';
4749
import { useNavPins } from '../hooks/useNavPins.js';
4850
import { useNavMemberGates, navEntriesShownToMember } from '../hooks/useNavMemberGates.js';
4951
import { useMetadata } from '../providers/MetadataProvider.js';
5052
import { matchAppBySegment } from '../utils/index.js';
51-
import { appStudioRoutePath } from '../utils/appRoute.js';
53+
import { appStudioObjectPath } from '../utils/appRoute.js';
5254
import { confirmUnsavedLeave } from '../chrome/unsavedEdits.js';
5355

5456
/**
55-
* The route an entry of a designable type opens, in the shape the app bar reads
56-
* a route in: `type` is the first segment after `/apps/<app>/`, `name` the
57-
* second. An object's list is `/apps/<app>/<object>`, so its first segment IS
58-
* the object's name; a dashboard is `/apps/<app>/dashboard/<name>` and a page
59-
* `/apps/<app>/page/<name>`. Any other type, and an entry naming no target, has
60-
* no designer here: `null`.
61-
*/
62-
function designableRoute(
63-
type: string,
64-
name: string | undefined,
65-
): { type: string; name?: string } | null {
66-
if (!name) return null;
67-
if (type === 'object') return { type: name };
68-
if (type === 'dashboard' || type === 'page') return { type, name };
69-
return null;
70-
}
71-
72-
/**
73-
* Where Design takes an item of `app`: the path the app bar's Edit app opens on
74-
* the item's own route, through the one derivation both controls share,
75-
* `appStudioRoutePath` (objectui#12520). An `object` opens Studio's Data
76-
* surface (`surface=object:NAME`), a `dashboard` or a `page` its Interfaces
77-
* surface (`surface=dashboard:NAME`, `surface=page:NAME`). `null` when the app
78-
* has no owning package Studio can open, so the entry hides as the app bar's
79-
* pencil does; there is no other destination to fall back to.
57+
* Where Object settings takes an object of `app` (objectstack#36487): the
58+
* object in Studio's Data surface (`surface=object:NAME`), through the
59+
* derivation the app bar's Studio entry reads on the object's list,
60+
* `appStudioObjectPath` (objectui#12520). `null` when the app has no owning
61+
* package Studio can open, or names no object, so the entry hides as the app
62+
* bar's does; there is no other destination to fall back to.
8063
*
81-
* The gate is not read here: `SidebarItemMenu` reads it where the entry is
82-
* drawn (`useStudioDesignGate`, the app bar's), so this answers for a principal
83-
* and a package that pass it.
64+
* The gate is not read here: the menu that draws the entry reads it
65+
* ({@link useObjectSettingsGate}), so this answers for a principal and a
66+
* package that pass it.
8467
*/
85-
function studioDesignPath(
86-
app: NavApp | null | undefined,
87-
type: string,
88-
name: string | undefined,
89-
): string | null {
90-
const route = designableRoute(type, name);
91-
if (!route) return null;
92-
return appStudioRoutePath(app, true, route);
68+
function objectSettingsPath(app: NavApp | null | undefined, objectName: string | undefined): string | null {
69+
return appStudioObjectPath(app, true, objectName);
9370
}
9471

9572
/**
96-
* The designer of what a navigation entry opens, in the app whose navigation
97-
* draws it ({@link studioDesignPath}), or `null` when the entry's type has no
98-
* designer: only `object`, `dashboard` and `page` entries have one. Every other
99-
* type (`url`, `component`, `separator`, `group`, `action`, and the types
100-
* objectui#12427 left undecided) has none.
73+
* The Object settings path of a navigation entry, in the app whose navigation
74+
* draws it ({@link objectSettingsPath}), or `null`: only an `object` entry has
75+
* one (objectstack#36487). A `dashboard`, `page` or `report` entry has none —
76+
* each is edited on its own page — and neither has any other type (`url`,
77+
* `component`, `separator`, `group`, `action`).
10178
*/
10279
export function sidebarItemDesignPath(
10380
item: NavigationItem,
10481
app: NavApp | null | undefined,
10582
): string | null {
106-
const name =
107-
item.type === 'object'
108-
? item.objectName
109-
: item.type === 'dashboard'
110-
? item.dashboardName
111-
: item.type === 'page'
112-
? item.pageName
113-
: undefined;
114-
return studioDesignPath(app, item.type, name);
83+
return item.type === 'object' ? objectSettingsPath(app, item.objectName) : null;
11584
}
11685

11786
/**
118-
* The designer of a favorite that is not a navigation entry, read from its id
119-
* (`object:NAME`, `dashboard:NAME`, `page:NAME`), in the app the favorite opens:
120-
* the one its `href` names (`/apps/<app>/...`), which need not be the app the
121-
* sidebar is drawn in. Any other id (a record, a report, an app) has none. The
122-
* id, not the stored `type`, decides: an app favorite is stored with
123-
* `type: 'object'` and an `app:` id, and has no object to design. A favorite
124-
* whose `href` names no app in `apps` has none either.
87+
* The Object settings path of a favorite that is not a navigation entry, read
88+
* from its id (`object:NAME`), in the app the favorite opens: the one its
89+
* `href` names (`/apps/<app>/...`), which need not be the app the sidebar is
90+
* drawn in. Any other id (a record, a dashboard, a page, a report, an app) has
91+
* none (objectstack#36487). The id, not the stored `type`, decides: an app
92+
* favorite is stored with `type: 'object'` and an `app:` id, and has no object
93+
* to open. A favorite whose `href` names no app in `apps` has none either.
12594
*/
12695
export function favoriteDesignPath(
12796
favorite: { id: string; href: string },
12897
apps: readonly NavApp[] | null | undefined,
12998
): string | null {
130-
const match = /^(object|dashboard|page):(.+)$/.exec(favorite.id);
99+
const match = /^object:(.+)$/.exec(favorite.id);
131100
if (!match) return null;
132101
const segment = /^\/apps\/([^/?#]+)/.exec(favorite.href)?.[1];
133102
const app = matchAppBySegment(apps ?? [], segment);
134103
if (!app) return null;
135-
return studioDesignPath(app, match[1], match[2]);
104+
return objectSettingsPath(app, match[1]);
105+
}
106+
107+
/**
108+
* objectstack#36487 — `path` when this principal may open the object it names
109+
* in Studio, else `null`: the app bar's own gate (`useStudioEntryGate`,
110+
* objectui#12615), in either posture. A workspace admin who may author
111+
* metadata gets it for a package Studio lists writable (an app built here)
112+
* and for one it lists read-only (an installed app), which Studio opens to
113+
* look at; a member, and the console's own system apps, get none.
114+
* ⛔ Never a second admin check: the gate is read here, once, for every menu
115+
* that draws the entry.
116+
*/
117+
export function useObjectSettingsGate(path: string | null | undefined): string | null {
118+
return useStudioEntryGate(path)?.path ?? null;
119+
}
120+
121+
/**
122+
* The Object settings path of the list of `objectName` in the app the route
123+
* names (`appSegment`), before the gate ({@link useObjectSettingsGate}): the
124+
* path the list page's ⋮ leads with, the one the sidebar's object entry opens.
125+
*/
126+
export function useObjectSettingsPath({
127+
appSegment,
128+
objectName,
129+
}: {
130+
appSegment: string | undefined;
131+
objectName: string | undefined;
132+
}): string | null {
133+
const { apps } = useMetadata();
134+
if (!appSegment || !objectName) return null;
135+
const app = matchAppBySegment(
136+
((apps ?? []) as NavApp[]).filter((a) => a.active !== false),
137+
appSegment,
138+
);
139+
return objectSettingsPath(app, objectName);
140+
}
141+
142+
/**
143+
* Object settings (objectstack#36487): the entry that opens an object in
144+
* Studio, where its fields are. The list page's ⋮ leads with it and the
145+
* sidebar's object entry carries it, so the two places say the same thing in
146+
* the same words and open the same place. Hand it a path the gate passed
147+
* ({@link useObjectSettingsGate}). Leaving asks first when the page holds
148+
* unsaved edits (`confirmUnsavedLeave`, objectui#13231).
149+
*/
150+
export function ObjectSettingsMenuItem({ path, testId }: { path: string; testId?: string }) {
151+
const { t } = useObjectTranslation();
152+
const navigate = useNavigate();
153+
return (
154+
<DropdownMenuItem data-testid={testId} onSelect={() => confirmUnsavedLeave(() => navigate(path))}>
155+
<Settings2 className="h-4 w-4" />
156+
<span>{t('console.nav.objectSettings', { defaultValue: 'Object settings' })}</span>
157+
</DropdownMenuItem>
158+
);
136159
}
137160

138161
/**
@@ -262,11 +285,12 @@ export interface SidebarItemMenuProps {
262285
/** Adds the entry to the Favorites section, or removes it. */
263286
onToggleFavorite: () => void;
264287
/**
265-
* The router path of the entry's designer ({@link sidebarItemDesignPath}).
266-
* The Design entry shows only when this is set AND the app bar's gate passes
267-
* it (`useStudioDesignGate`: the viewer may author metadata, and the package
268-
* the path opens is writable); the gate is read here, so no host can forget
269-
* it.
288+
* The router path the entry's Object settings opens
289+
* ({@link sidebarItemDesignPath}, {@link favoriteDesignPath}). The entry
290+
* shows only when this is set AND the app bar's gate passes it
291+
* ({@link useObjectSettingsGate}: the viewer may author metadata, and Studio
292+
* lists the package the path opens); the gate is read here, so no host can
293+
* forget it.
270294
*/
271295
designPath?: string | null;
272296
}
@@ -291,9 +315,8 @@ export function SidebarItemMenu({
291315
designPath,
292316
}: SidebarItemMenuProps) {
293317
const { t } = useObjectTranslation();
294-
const navigate = useNavigate();
295318
// objectui#12615 — the app bar's own gate, on the package this path opens.
296-
const gatedDesignPath = useStudioDesignGate(designPath);
319+
const objectSettings = useObjectSettingsGate(designPath);
297320
// A router path is opened and copied as the href the row's own `Link`
298321
// renders for it, which carries the basename the host mounted the console
299322
// under (`/_console`): a new tab and a copied link resolve against the
@@ -360,15 +383,7 @@ export function SidebarItemMenu({
360383
<span>{t('console.nav.copyLink', { defaultValue: 'Copy link' })}</span>
361384
</DropdownMenuItem>
362385
)}
363-
{gatedDesignPath && (
364-
<DropdownMenuItem
365-
data-testid="sidebar-item-menu-design"
366-
onSelect={() => confirmUnsavedLeave(() => navigate(gatedDesignPath))}
367-
>
368-
<PencilRuler className="h-4 w-4" />
369-
<span>{t('console.nav.design', { defaultValue: 'Design' })}</span>
370-
</DropdownMenuItem>
371-
)}
386+
{objectSettings && <ObjectSettingsMenuItem path={objectSettings} testId="sidebar-item-menu-object-settings" />}
372387
</DropdownMenuContent>
373388
</DropdownMenu>
374389
);

‎ui/packages/app-shell/src/layout/__tests__/SidebarItemMenu-12427.test.tsx‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
*
66
* The entries derive from the entry's type and target: Add to / Remove from
77
* favorites first, then Open in new tab and Copy link for an entry that goes
8-
* somewhere, then Design for an entry with a designer, shown only to a
9-
* principal who may author metadata (`isAdmin && canAuthorMetadata`). A
10-
* right-click on the row opens the same menu.
8+
* somewhere, then Object settings for an object entry (objectstack#36487),
9+
* shown only to a principal who may author metadata
10+
* (`isAdmin && canAuthorMetadata`). A right-click on the row opens the same
11+
* menu.
1112
*
1213
* Harness: the real component in a real `SidebarMenuItem` row, the real router
1314
* and the real `resolveHref` of `@object-ui/layout` for the entry's address;
1415
* the translator returns each call site's inline default, and the two
1516
* principal answers are stand-ins. The entry's app is owned by a package, so
16-
* Design has a Studio surface to open (objectui#12520), and the package list
17+
* Object settings has a Studio surface to open (objectui#12520), and the package list
1718
* serves that package writable, so the gate's package half passes
1819
* (objectui#12615).
1920
*/
@@ -123,8 +124,8 @@ async function openMenu(): Promise<string[]> {
123124
beforeEach(() => {
124125
viewer.isAdmin = true;
125126
viewer.canAuthorMetadata = true;
126-
// objectui#12615 — the app's package is served writable, so the Design
127-
// gate's package half passes and this file's own questions are the ones asked.
127+
// objectui#12615 — the app's package is served writable, so the Object
128+
// settings gate's package half passes and this file's own questions are the ones asked.
128129
vi.stubGlobal(
129130
'fetch',
130131
vi.fn(async (url: unknown) => ({
@@ -147,12 +148,12 @@ afterEach(() => {
147148
});
148149

149150
describe('SidebarItemMenu: the entries an object entry offers (objectui#12427)', () => {
150-
it('lists exactly four entries for a principal who may author metadata, Design last', async () => {
151+
it('lists exactly four entries for a principal who may author metadata, Object settings last', async () => {
151152
renderRow();
152-
expect(await openMenu()).toEqual(['Add to favorites', 'Open in new tab', 'Copy link', 'Design']);
153+
expect(await openMenu()).toEqual(['Add to favorites', 'Open in new tab', 'Copy link', 'Object settings']);
153154
});
154155

155-
it('lists exactly three for a non-admin: no Design entry', async () => {
156+
it('lists exactly three for a non-admin: no Object settings entry', async () => {
156157
viewer.isAdmin = false;
157158
renderRow();
158159
expect(await openMenu()).toEqual(['Add to favorites', 'Open in new tab', 'Copy link']);
@@ -175,10 +176,10 @@ describe('SidebarItemMenu: the entries an object entry offers (objectui#12427)',
175176
});
176177

177178
describe('SidebarItemMenu: what each entry does (objectui#12427)', () => {
178-
it('Design opens Studio\'s Data surface for the entry\'s object (objectui#12520)', async () => {
179+
it('Object settings opens Studio\'s Data surface for the entry\'s object (objectui#12520, objectstack#36487)', async () => {
179180
renderRow();
180181
await openMenu();
181-
fireEvent.click(screen.getByRole('menuitem', { name: 'Design' }));
182+
fireEvent.click(screen.getByRole('menuitem', { name: 'Object settings' }));
182183
await waitFor(() =>
183184
expect(screen.getByTestId('where')).toHaveTextContent('/studio/com.acme.crm/data?surface=object:crm_lead'),
184185
);
@@ -222,7 +223,7 @@ describe('SidebarItemMenu: what each entry does (objectui#12427)', () => {
222223
});
223224

224225
describe('SidebarItemMenu: entries an entry type does not offer (objectui#12427)', () => {
225-
it('a url entry shows no Design entry, even to an admin who may author metadata', async () => {
226+
it('a url entry shows no Object settings entry, even to an admin who may author metadata', async () => {
226227
renderRow({ item: HELP });
227228
expect(await openMenu()).toEqual(['Add to favorites', 'Open in new tab', 'Copy link']);
228229
});
@@ -241,23 +242,25 @@ describe('SidebarItemMenu: right-click (objectui#12427)', () => {
241242
const notPrevented = fireEvent.contextMenu(screen.getByTestId('row-link'));
242243
expect(notPrevented).toBe(false);
243244
const items = await screen.findAllByRole('menuitem');
244-
expect(items.map((el) => el.textContent)).toEqual(['Add to favorites', 'Open in new tab', 'Copy link', 'Design']);
245+
expect(items.map((el) => el.textContent)).toEqual(['Add to favorites', 'Open in new tab', 'Copy link', 'Object settings']);
245246
});
246247
});
247248

248-
describe('sidebarItemDesignPath: the Studio surface per entry type (objectui#12427, objectui#12520)', () => {
249-
it('a page entry opens its Interfaces surface, as the app bar does on the page', () => {
250-
const page = { id: 'p', type: 'page', pageName: 'home_page', label: 'Home' } as NavigationItem;
251-
expect(sidebarItemDesignPath(page, APP)).toBe('/studio/com.acme.crm/interfaces?surface=page:home_page');
249+
describe('sidebarItemDesignPath: only an object entry has a Studio entry (objectui#12520, objectstack#36487)', () => {
250+
it('an object entry opens its object in the Data surface', () => {
251+
expect(sidebarItemDesignPath(LEADS, APP)).toBe('/studio/com.acme.crm/data?surface=object:crm_lead');
252252
});
253253

254-
it('an object entry opens the Data surface, a dashboard entry the Interfaces surface', () => {
255-
expect(sidebarItemDesignPath(LEADS, APP)).toBe('/studio/com.acme.crm/data?surface=object:crm_lead');
254+
it('a dashboard, page or report entry has none: each is edited on its own page', () => {
255+
const page = { id: 'p', type: 'page', pageName: 'home_page', label: 'Home' } as NavigationItem;
256256
const dash = { id: 'd', type: 'dashboard', dashboardName: 'sales', label: 'Sales' } as NavigationItem;
257-
expect(sidebarItemDesignPath(dash, APP)).toBe('/studio/com.acme.crm/interfaces?surface=dashboard:sales');
257+
const report = { id: 'r', type: 'report', reportName: 'pipeline', label: 'Pipeline' } as NavigationItem;
258+
expect(sidebarItemDesignPath(page, APP)).toBeNull();
259+
expect(sidebarItemDesignPath(dash, APP)).toBeNull();
260+
expect(sidebarItemDesignPath(report, APP)).toBeNull();
258261
});
259262

260-
it('url, component and separator entries have no designer', () => {
263+
it('url, component and separator entries have none', () => {
261264
const component = { id: 'c', type: 'component', componentRef: 'x:y', label: 'C' } as NavigationItem;
262265
const separator = { id: 's', type: 'separator' } as NavigationItem;
263266
expect(sidebarItemDesignPath(HELP, APP)).toBeNull();

0 commit comments

Comments
 (0)