Skip to content

Commit 2924732

Browse files
feat(console): the design mode is entered from the app-name menu; the page header drops Edit app and Open in Studio (#36485) (#36621)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi92ncfFpPUpTD8314otX5oaG)_ Fixes #36485 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:系统管理员在任何应用里点左上角应用名,应用列表下面、和「添加应用」同一组多了「编辑应用」,点了直接进入设计模式;页头右上角不再有「编辑应用」和「在 Studio 中查看 某应用」两个按钮,只剩 AI 助手和帮助。自建应用和安装来的应用一样;侧栏收起时从左边缘滑出的菜单里也能点到;普通成员看不到,手机上没有入口。 - 为什么做:运行界面设计模式专题的一张子卡,按你「立卡」的那条建议,把设计入口集中到应用名菜单,页头只留每页自己的按钮。 - 出错会怎样:最坏是管理员在页头找不到「编辑应用」,要去应用名菜单里点;设计模式本身和保存都没改,撤回本 PR 即恢复原来的按钮。 - 要你做什么:无。 ## What changes - **App-name menu** (`SidebarAppMenu`): a new 「Edit app」 item (`sidebar-app-menu-edit-app`, the `topbar.editApp` key every locale already carries, no new i18n key) under the app list, in one group with 「Add app」 (one rule above the group, none between the two). Choosing it calls the shell's `useDesignMode().enter` for the app on screen: no navigation, no Studio. - **Who sees it — the header button's condition, carried over unchanged, no new judgement**: `useStudioEntryGate` (the gate `useAppStudioEntry` reads) answers non-null, i.e. `useWorkspaceAdminStatus().isAdmin` AND `useCanAuthorMetadata()` (the server-reported `manage_metadata` capability) AND the app's package is one `GET /api/v1/packages` lists (not a kernel package: Setup, Studio, Account get none); a read-only package (`posture: 'view'`) only where the customization door takes the caller (`!postureHasOrgWall(useTenancyPosture()) || user.isPlatformAdmin`), as #36363 set it. It reads the app's own Studio path (`appStudioDesignPath`); the gate judges the package id only, so the answer is the one the header got on every route. - **While the mode is on** the item is not drawn (same as the header button was). **Where no shell holds the mode** it is not drawn either (the header used to fall back to a Studio link there; nothing in the console renders the sidebar outside `ConsoleLayout`'s provider). - **Collapsed sidebar**: the float from the left edge is the same panel with the same head, so the item is there too (pinned and browser-measured). - **Phone**: the sidebar head with the app menu is drawn from 768 px up only, so no entry, as before. - **Page header** (`ShellPageActions`): `EditAppButton` is deleted: no 「Edit app」 and no 「Open {app} in Studio」 in the group on any route. The group now reads no Studio gate at all (`useAppStudioEntry(false)`, app only, for the help menu's package). `useAppStudioEntry` stays: `AppHeader` (the top bar still drawn below 768 px and on docs pages) reads it. - **Installed apps today**: on `main` an installed (read-only) app already enters the mode (#36363 landed), so in this PR an installed app's menu item behaves exactly as a self-built one's. Its one exception is the walled-deployment case above: there the item is absent (the header showed the eye into Studio; that eye is gone with the header buttons, so such a caller reaches Studio through the app switcher's row or Studio's landing). - **Onboarding**: there is no step pointing at 「Edit app」: `chrome/OnboardingWalkthrough.tsx` is a stub that renders nothing, and no other tour exists in the console. ## Tests <details><summary>Pins added or rewritten (vitest, root ui/)</summary> - `SidebarAppMenu-36112.test.tsx`, new top-level describe 「Edit app」 in the app menu enters the design mode: placement under the list with one rule before the group; choosing it turns the real `useDesignModeController` on and the item is gone while on; a read-only package's app has it and enters; walled + read-only gets none, walled + writable keeps it; controls: a member, an admin without `manage_metadata`, the Setup app (package not listed), no shell holding the mode. The package list is the stubbed `fetch`; the file-level `beforeEach` now stubs it for every test, since the menu reads the gate for admins. - `ShellPageActions-36111.test.tsx`: the group's order is comments then help; the old 「Edit app」 / eye / design-mode-button describes are replaced by one asserting neither entry (test id and accessible name) for writable and read-only packages, with and without a design-mode shell, walled, and for a member. - `UnifiedSidebar.hiddenCollapse-35062.test.tsx`, new top-level describe: sidebar collapsed at 1024 px, floated by a press on the left edge, the real Radix app menu opened from inside the float offers 「Edit app」, and choosing it turns the mode on. </details> <details><summary>Runs at f7d907a</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/layout/__tests__/` plus `ObjectView.shellPageActions-36111`, `RecordDetailView.topBar-27524`, `PageView.consoleHeader-36111` (lock VERDICT command-exit 0): Test Files 157 passed (157), Tests 1255 passed (1255). Run at 2b4666e plus the test edits; the float pin and typing commit followed, re-run: the two harness files 36/36. - `pnpm --filter @object-ui/app-shell type-check` (both `tsc --noEmit` and `tsconfig.test.json`): VERDICT command-exit 0. - eslint on the five changed source and test files: 0 errors. </details> <details><summary>Ablation (one-shot, not kept)</summary> - Menu item: `node scripts/ablation-replace.mjs --file ui/packages/app-shell/src/layout/SidebarAppMenu.tsx --anchor '{enterDesignMode && EDIT_APP_ITEM_ELEMENT}' --delete -- vitest …` (anchor 1 → 0, blob 367de8d → 71946a69): 5 failed | 31 passed: every positive pin in both harnesses red, every control green; restored blob 367de8d = HEAD. - Header: `ShellPageActions.tsx` swapped for its base-commit text under an EXIT trap: 3 failed | 5 passed (the order pin and both no-entry pins red; the member control and the scope pins green); restored blob 2e64064 = HEAD, `git status` clean. </details> ## Acceptance notes - Browser, own stack (CRM example on its own port, `--fresh`; Console dev server pointed at it), 1440 px. HotCRM is not in this container: the CRM example's `com.example.crm` is a code package served read-only, so it stands in for the installed app; a writable app was made for the self-built case (`POST /api/v1/packages` `com.acme.mine` plus app `my_sales` saved into it). - Admin, read-only CRM app and writable My Sales app: header group children = help only, no 「in Studio」 text anywhere on the leads list, the accounts list and the pipeline dashboard; menu reads `CRM · Setup · (My Sales) · Edit app · Add app`; choosing 「Edit app」 draws the design-mode bar; reopening the menu in the mode shows no 「Edit app」; collapsed sidebar, floated from the edge: item present, choosing it draws the bar. - Member (created by the admin, no CRM permissions): menu reads `CRM`, no 「Edit app」. - 390 px: no app menu trigger and no 「Edit app」 anywhere. - Not measured in the browser: a report route and a custom page route (the CRM example has neither in its menu); the group is the same component on every route and `PageView.consoleHeader-36111` / `ObjectView.shellPageActions-36111` / `RecordDetailView.topBar-27524` stayed green. - Screenshots (before = the two files at the base commit, served by the same dev server), in `/mnt/project-files/objectstack-seat2/`: - header before / after: `36485-before-crm-readonly-header.png`, `36485-before-selfbuilt-writable-header.png` / `36485-after-crm-readonly-header.png`, `36485-after-selfbuilt-writable-header.png` - app menu before / after: `36485-before-crm-readonly-app-menu.png` / `36485-after-crm-readonly-app-menu.png`, `36485-after-selfbuilt-writable-app-menu.png` - in the mode: `36485-after-*-design-mode-on.png`, `36485-after-*-app-menu-in-mode.png`; float: `36485-after-*-float-app-menu.png`, `36485-after-*-float-design-mode-on.png`; member: `36485-after-member-app-menu.png` - The top bar still drawn from 640 to 767 px and on an app's docs pages keeps its Studio pencil / eye (`AppHeader`, outside this card's file surface): it opens Studio, not the mode. Left as is; named in the report for the seat. - `designMode.tsx`'s docblock still says the mode is entered from the page header's 「Edit app」 (`ShellPageActions`); the file is read-only here (open PR #36606 edits it). `ui/packages/app-shell/README.md`'s "App → Studio reverse bridge" describes the top bar only and does not mention the mode's door; also outside the file surface. Both named in the report. - ADR-0146 D5 says the app bar entry draws as 「Open {app} in Studio」; the page header's copy of it is gone. The sentence goes to the seat's ADR-revision card, not this PR. ## Verification Read first: 1. `ui/packages/app-shell/src/layout/SidebarAppMenu.tsx`, `useEnterDesignMode`: the gate carried over from the header; the risk is a viewer who saw the header button and now sees no menu item, or the reverse. 2. `ui/packages/app-shell/src/layout/ShellPageActions.tsx`, `ShellPageActionsGroup`: the group no longer reads the gate. 3. `UnifiedSidebar.hiddenCollapse-35062.test.tsx`, the new last describe: the float path. Two-minute check: as an admin, open any app page at desktop width, click the app name at the top left: 「Edit app」 sits under the app list above 「Add app」; click it and the blue Design mode bar appears; the page header's top-right has only the AI and help buttons. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3110de5 commit 2924732

6 files changed

Lines changed: 332 additions & 224 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
feat(console): the design mode is entered from the app-name menu; the page header no longer carries 「Edit app」 or 「Open {app} in Studio」
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The app-name menu at the top of the sidebar now offers 「Edit app」 under the list of apps, in one group with 「Add app」. Choosing it turns the design mode on for the app on screen, in place. It is offered on the condition the page header's button was drawn on, unchanged: a workspace admin holding `manage_metadata`, on an app whose package Studio lists (the console's own Setup, Studio and Account apps get none). An app built here and an installed (read-only) one get it alike, except where the customization door is walled off for the caller (a walled deployment, not the platform operator): there an installed app's menu offers no 「Edit app」. While the mode is on, the menu does not offer it. The menu is drawn from 768 px up, docked or floated over the content while the sidebar is collapsed; a phone has no way into the mode, as before.
11+
12+
The page's top-right button group now holds the comments slot, the AI assistant and help only: its 「Edit app」 and the read-only package's 「Open {app} in Studio」 are gone. The app switcher's 「Open {app} in Studio」 row is unchanged, and so is the top bar's Studio entry where a top bar is still drawn (from 640 to 767 px wide, and on an app's docs pages).

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

Lines changed: 16 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
/**
44
* ShellPageActions — the page's top-right button group (objectstack#36111,
55
* phase 1 of the top-bar removal, objectstack#36107): from left to right the
6-
* comments slot, 「Edit app」, the AI assistant and help, at the same place on
7-
* every in-app page — a list, a record, a dashboard, a report, a custom page.
6+
* comments slot, the AI assistant and help, at the same place on every in-app
7+
* page — a list, a record, a dashboard, a report, a custom page.
8+
*
9+
* The group carries nothing that edits the app (objectstack#36485): the
10+
* design mode is entered from the app-name menu's 「Edit app」
11+
* (`SidebarAppMenu`), for an app built here and an installed one alike, and
12+
* no 「Open {app} in Studio」 is drawn here.
813
*
914
* The SHELL decides whether it is drawn, not the page: `ConsoleLayout` mounts
1015
* `ShellPageActionsScope`, which hands the group to the headers through the
@@ -27,24 +32,18 @@
2732
* test that mounts a page bare) the group is never drawn, and on a phone
2833
* neither: the phone has its own bar.
2934
*
30-
* The parts are the top bar's own: 「Edit app」 reads the same gate as the top
31-
* bar's pencil (`useAppStudioEntry`), the AI button IS `AssistantTopBarButton`,
32-
* and the help menu IS `HelpMenu`. Where the shell holds the design mode
33-
* (`designMode.tsx`, objectstack#36362), 「Edit app」 turns it on instead of
34-
* opening Studio, and is not drawn while it is on; elsewhere it opens what the
35-
* pencil opens.
35+
* The parts are the top bar's own: the AI button IS `AssistantTopBarButton`,
36+
* and the help menu IS `HelpMenu`.
3637
*/
3738

3839
import * as React from 'react';
39-
import { Link, useLocation, useParams } from 'react-router-dom';
40-
import { Blocks, Eye } from 'lucide-react';
41-
import { Button, cn, useSidebar } from '@object-ui/components';
40+
import { useLocation, useParams } from 'react-router-dom';
41+
import { cn, useSidebar } from '@object-ui/components';
4242
import { useObjectTranslation } from '@object-ui/i18n';
4343
import { useMetadata } from '../providers/MetadataProvider.js';
4444
import { useNavigationContext } from '../context/NavigationContext.js';
4545
import { matchAppBySegment, appStudioRoutePath } from '../utils/index.js';
4646
import { useStudioEntryGate, type StudioEntry } from '../hooks/useStudioDesignGate.js';
47-
import { useServedAppLabel } from '../hooks/useServedAppLabel.js';
4847
import { useAiSurfaceEnabled } from '../hooks/useAiSurface.js';
4948
import {
5049
ShellPageActionsSlotContext,
@@ -55,9 +54,6 @@ import {
5554
import { LocalizedSidebarTrigger } from './LocalizedSidebarTrigger.js';
5655
import { AssistantTopBarButton } from './AssistantTopBarButton.js';
5756
import { HelpMenu } from './HelpMenu.js';
58-
import { useDesignMode, type DesignModeValue } from './designMode.js';
59-
import { useAuth } from '@object-ui/auth';
60-
import { postureHasOrgWall, useTenancyPosture } from '../hooks/useTenancyPosture.js';
6157

6258
/**
6359
* Counts the headers under a scope that place the expand button, so the
@@ -184,8 +180,9 @@ export function useShellPageActionsOn(): boolean {
184180
* page or report route its design surface (`appStudioRoutePath`). `null` when
185181
* this principal or this package gets no entry (`useStudioEntryGate`).
186182
*
187-
* The top bar's 「Edit app」 pencil and the group's 「Edit app」 both read it,
188-
* so the two cannot open different places.
183+
* The top bar's 「Edit app」 pencil reads it, and the app-name menu's
184+
* 「Edit app」 reads its gate (objectstack#36485), so the two cannot offer
185+
* the app to different people.
189186
*/
190187
export function useAppStudioEntry(enabled: boolean, activeAppName?: string): {
191188
currentApp: unknown;
@@ -205,87 +202,6 @@ export function useAppStudioEntry(enabled: boolean, activeAppName?: string): {
205202
return { currentApp, entry };
206203
}
207204

208-
/**
209-
* 「Edit app」 in the group: its words beside an icon that is not the pencil
210-
* (the record's 「Edit」 carries the pencil), the words dropped below `lg` with
211-
* the tooltip keeping them. A read-only package's app gets the top bar's eye
212-
* and 「Open {app} in Studio」 (ADR-0146 D5) at the same place.
213-
*
214-
* objectstack#36362 — under a shell that holds the design mode, 「Edit app」
215-
* turns the mode on, in place, and opens no Studio. objectstack#36363 — so
216-
* does a read-only package's app, where the customization door takes this
217-
* caller: its changes are saved as this environment's customization.
218-
*/
219-
function EditAppButton({
220-
entry,
221-
appText,
222-
designMode,
223-
}: {
224-
entry: StudioEntry;
225-
appText: string;
226-
designMode: DesignModeValue | null;
227-
}) {
228-
const { t } = useObjectTranslation();
229-
// objectstack#36363 — a read-only package's app (an installed one) enters
230-
// the mode too: what the mode saves goes to the package's customization,
231-
// as Studio's menu editing does. Not where the customization door is walled
232-
// off for this caller (only the platform operator may call it there).
233-
const posture = useTenancyPosture();
234-
const { user } = useAuth();
235-
const customizable = !postureHasOrgWall(posture) || user?.isPlatformAdmin === true;
236-
if (entry.posture === 'view' && !(designMode && customizable)) {
237-
const viewText = t('topbar.openAppInStudio', { defaultValue: 'Open {{app}} in Studio', app: appText });
238-
return (
239-
<Button
240-
variant="ghost"
241-
size="sm"
242-
className="h-8 shrink-0 gap-1.5 px-2 max-w-[14rem]"
243-
asChild
244-
data-testid="shell-page-actions-view-app"
245-
title={viewText}
246-
>
247-
<Link to={entry.path} aria-label={viewText}>
248-
<Eye className="h-4 w-4 shrink-0" aria-hidden="true" />
249-
<span className="hidden lg:inline truncate text-xs font-medium">{viewText}</span>
250-
</Link>
251-
</Button>
252-
);
253-
}
254-
const label = t('topbar.editApp', { defaultValue: 'Edit app' });
255-
if (designMode) {
256-
return (
257-
<Button
258-
type="button"
259-
variant="ghost"
260-
size="sm"
261-
className="h-8 shrink-0 gap-1.5 px-2"
262-
data-testid="shell-page-actions-edit-app"
263-
title={label}
264-
aria-label={label}
265-
onClick={designMode.enter}
266-
>
267-
<Blocks className="h-4 w-4 shrink-0" aria-hidden="true" />
268-
<span className="hidden lg:inline text-xs font-medium">{label}</span>
269-
</Button>
270-
);
271-
}
272-
return (
273-
<Button
274-
variant="ghost"
275-
size="sm"
276-
className="h-8 shrink-0 gap-1.5 px-2"
277-
asChild
278-
data-testid="shell-page-actions-edit-app"
279-
title={label}
280-
>
281-
<Link to={entry.path} aria-label={label}>
282-
<Blocks className="h-4 w-4 shrink-0" aria-hidden="true" />
283-
<span className="hidden lg:inline text-xs font-medium">{label}</span>
284-
</Link>
285-
</Button>
286-
);
287-
}
288-
289205
export type ShellPageActionsProps = ShellPageActionsSlotProps;
290206

291207
/** The group, where the shell turned it on; nothing anywhere else. */
@@ -300,17 +216,13 @@ function renderShellPageActionsGroup(props: ShellPageActionsSlotProps): React.Re
300216
}
301217

302218
function ShellPageActionsGroup({ comments }: ShellPageActionsProps) {
303-
const { entry, currentApp } = useAppStudioEntry(true);
304-
const { appLabel } = useServedAppLabel();
219+
// The app only: the group draws no Studio entry, so it reads no gate.
220+
const { currentApp } = useAppStudioEntry(false);
305221
const { enabled: aiEnabled } = useAiSurfaceEnabled();
306222
const appPackageId = (currentApp as { _packageId?: string } | undefined)?._packageId;
307-
const designMode = useDesignMode();
308223
return (
309224
<div className="flex shrink-0 items-center gap-0.5" data-testid="shell-page-actions">
310225
{comments}
311-
{entry && !designMode?.active && (
312-
<EditAppButton entry={entry} appText={currentApp ? appLabel(currentApp as any) : ''} designMode={designMode} />
313-
)}
314226
{aiEnabled && <AssistantTopBarButton className="max-md:size-8" />}
315227
<HelpMenu inApp appPackageId={appPackageId} triggerClassName="h-8 w-8 shrink-0" triggerTestId="shell-page-actions-help" />
316228
</div>

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

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
* the viewers who may build, 「Add app」 at the foot (build with AI or in
1010
* Studio, start from a template, the marketplace).
1111
*
12+
* objectstack#36485 — and the door into the design mode (`designMode.tsx`,
13+
* objectstack#36362): 「Edit app」 under the list, in one group with
14+
* 「Add app」, for the viewers the page header's 「Edit app」 was drawn for
15+
* (the header draws none any more). The sidebar's head is drawn from 768 px
16+
* up only, docked or floated over the content while the sidebar is
17+
* collapsed, so a phone gets no way in, as before.
18+
*
1219
* The list is `useLauncherApps`', the list Home's tiles and the phone's app
1320
* sheet draw, so every place offers the same apps. The phone keeps
1421
* `AppSwitcher`'s bottom sheet in its own top bar.
@@ -28,19 +35,22 @@ import {
2835
DropdownMenuTrigger,
2936
Input,
3037
} from '@object-ui/components';
31-
import { Check, ChevronDown, Hammer, LayoutGrid, Plus, Store } from 'lucide-react';
38+
import { Blocks, Check, ChevronDown, Hammer, LayoutGrid, Plus, Store } from 'lucide-react';
3239
import { useObjectTranslation } from '@object-ui/i18n';
33-
import { useWorkspaceAdminStatus } from '@object-ui/auth';
40+
import { useAuth, useWorkspaceAdminStatus } from '@object-ui/auth';
3441
import { useMetadata } from '../providers/MetadataProvider.js';
3542
import { matchAppBySegment } from '../utils/index.js';
36-
import { appAddressSegment } from '../utils/appRoute.js';
43+
import { appAddressSegment, appStudioDesignPath } from '../utils/appRoute.js';
3744
import { useServedAppLabel } from '../hooks/useServedAppLabel.js';
3845
import { useLauncherApps } from '../hooks/useLauncherApps.js';
3946
import { useCanAuthorMetadata } from '../hooks/useCanAuthorMetadata.js';
47+
import { useStudioEntryGate } from '../hooks/useStudioDesignGate.js';
4048
import { useAiSurfaceEnabled } from '../hooks/useAiSurface.js';
4149
import { isAiStudioEnabled, isMarketplaceEnabled } from '../runtime-config.js';
4250
import { STUDIO_NEW_PACKAGE_PATH } from '../views/studio-design/studioNewPackage.js';
4351
import { AppMark } from './AppMark.js';
52+
import { useDesignMode } from './designMode.js';
53+
import { postureHasOrgWall, useTenancyPosture } from '../hooks/useTenancyPosture.js';
4454

4555
/** The app count above which the menu draws a search field over the list. */
4656
export const APP_MENU_SEARCH_FROM = 8;
@@ -93,13 +103,49 @@ function useAddAppEntries(): AddAppEntry[] {
93103
return entries;
94104
}
95105

96-
/** The menu's foot: 「Add app」 and its choices. */
106+
/**
107+
* What 「Edit app」 does for this viewer, or `null` where it is not drawn: it
108+
* turns the shell's design mode on for the app on screen, in place.
109+
*
110+
* Drawn on the page header's button's condition, unchanged: a workspace admin
111+
* holding `manage_metadata`, on an app whose package Studio lists
112+
* (`useStudioEntryGate`, the gate `useAppStudioEntry` reads; it judges the
113+
* package the path names, so the app's own Studio path is read), so the
114+
* console's own apps get none. A read-only (installed) package's app gets it too
115+
* (objectstack#36363: its changes are saved as this environment's
116+
* customization), except where the customization door is walled off for this
117+
* caller. Not drawn where no shell holds the mode, nor while the mode is on.
118+
*/
119+
function useEnterDesignMode(apps: Parameters<typeof matchAppBySegment>[0], activeAppName: string): (() => void) | null {
120+
const entry = useStudioEntryGate(appStudioDesignPath(matchAppBySegment(apps, activeAppName), true));
121+
const designMode = useDesignMode();
122+
const posture = useTenancyPosture();
123+
const { user } = useAuth();
124+
const customizable = !postureHasOrgWall(posture) || user?.isPlatformAdmin === true;
125+
if (!entry || !designMode || designMode.active) return null;
126+
if (entry.posture === 'view' && !customizable) return null;
127+
return designMode.enter;
128+
}
129+
130+
/** 「Edit app」: the door into the design mode. */
131+
function EditAppItem({ onEnter }: { onEnter: () => void }) {
132+
const { t } = useObjectTranslation();
133+
return (
134+
<DropdownMenuItem onSelect={onEnter} className="flex items-center gap-2.5 py-2" data-testid="sidebar-app-menu-edit-app">
135+
<span className="flex size-[22px] shrink-0 items-center justify-center text-muted-foreground" aria-hidden>
136+
<Blocks className="size-4" />
137+
</span>
138+
<span className="flex-1 truncate">{t('topbar.editApp', { defaultValue: 'Edit app' })}</span>
139+
</DropdownMenuItem>
140+
);
141+
}
142+
143+
/** 「Add app」 and its choices. */
97144
function AddAppSubmenu() {
98145
const { t } = useObjectTranslation();
99146
const entries = useAddAppEntries();
100147
return (
101148
<>
102-
<DropdownMenuSeparator />
103149
<DropdownMenuSub>
104150
<DropdownMenuSubTrigger className="flex items-center gap-2.5 py-2" data-testid="sidebar-app-menu-add">
105151
<span className="flex size-[22px] shrink-0 items-center justify-center text-muted-foreground" aria-hidden>
@@ -135,6 +181,7 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro
135181
const apps = metadataApps || [];
136182
const { apps: launcherApps } = useLauncherApps(apps);
137183
const mayAddApp = useMayAddApp();
184+
const enterDesignMode = useEnterDesignMode(apps, activeAppName);
138185
const [query, setQuery] = React.useState('');
139186

140187
// The route may name an app the launcher does not offer (a direct URL to an
@@ -203,6 +250,8 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro
203250
</div>
204251
)}
205252
</div>
253+
{(enterDesignMode || mayAddApp) && <DropdownMenuSeparator />}
254+
{enterDesignMode && <EditAppItem onEnter={enterDesignMode} />}
206255
{mayAddApp && <AddAppSubmenu />}
207256
</DropdownMenuContent>
208257
</DropdownMenu>

0 commit comments

Comments
 (0)