Skip to content

Commit 2b4666e

Browse files
committed
feat(app-shell): the design mode's door moves to the app-name menu; the page header drops Edit app and Open in Studio
Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
1 parent aff34ba commit 2b4666e

4 files changed

Lines changed: 245 additions & 222 deletions

File tree

‎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: 52 additions & 4 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,9 +35,9 @@ 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';
3643
import { appAddressSegment } from '../utils/appRoute.js';
@@ -41,6 +48,9 @@ import { useAiSurfaceEnabled } from '../hooks/useAiSurface.js';
4148
import { isAiStudioEnabled, isMarketplaceEnabled } from '../runtime-config.js';
4249
import { STUDIO_NEW_PACKAGE_PATH } from '../views/studio-design/studioNewPackage.js';
4350
import { AppMark } from './AppMark.js';
51+
import { useAppStudioEntry } from './ShellPageActions.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,48 @@ 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+
* (`useAppStudioEntry`'s gate, `useStudioEntryGate`), so the console's own
113+
* apps get none. A read-only (installed) package's app gets it too
114+
* (objectstack#36363: its changes are saved as this environment's
115+
* customization), except where the customization door is walled off for this
116+
* caller. Not drawn where no shell holds the mode, nor while the mode is on.
117+
*/
118+
function useEnterDesignMode(activeAppName: string): (() => void) | null {
119+
const { entry } = useAppStudioEntry(true, activeAppName);
120+
const designMode = useDesignMode();
121+
const posture = useTenancyPosture();
122+
const { user } = useAuth();
123+
const customizable = !postureHasOrgWall(posture) || user?.isPlatformAdmin === true;
124+
if (!entry || !designMode || designMode.active) return null;
125+
if (entry.posture === 'view' && !customizable) return null;
126+
return designMode.enter;
127+
}
128+
129+
/** 「Edit app」: the door into the design mode. */
130+
function EditAppItem({ onEnter }: { onEnter: () => void }) {
131+
const { t } = useObjectTranslation();
132+
return (
133+
<DropdownMenuItem onSelect={onEnter} className="flex items-center gap-2.5 py-2" data-testid="sidebar-app-menu-edit-app">
134+
<span className="flex size-[22px] shrink-0 items-center justify-center text-muted-foreground" aria-hidden>
135+
<Blocks className="size-4" />
136+
</span>
137+
<span className="flex-1 truncate">{t('topbar.editApp', { defaultValue: 'Edit app' })}</span>
138+
</DropdownMenuItem>
139+
);
140+
}
141+
142+
/** 「Add app」 and its choices. */
97143
function AddAppSubmenu() {
98144
const { t } = useObjectTranslation();
99145
const entries = useAddAppEntries();
100146
return (
101147
<>
102-
<DropdownMenuSeparator />
103148
<DropdownMenuSub>
104149
<DropdownMenuSubTrigger className="flex items-center gap-2.5 py-2" data-testid="sidebar-app-menu-add">
105150
<span className="flex size-[22px] shrink-0 items-center justify-center text-muted-foreground" aria-hidden>
@@ -135,6 +180,7 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro
135180
const apps = metadataApps || [];
136181
const { apps: launcherApps } = useLauncherApps(apps);
137182
const mayAddApp = useMayAddApp();
183+
const enterDesignMode = useEnterDesignMode(activeAppName);
138184
const [query, setQuery] = React.useState('');
139185

140186
// The route may name an app the launcher does not offer (a direct URL to an
@@ -203,6 +249,8 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro
203249
</div>
204250
)}
205251
</div>
252+
{(enterDesignMode || mayAddApp) && <DropdownMenuSeparator />}
253+
{enterDesignMode && <EditAppItem onEnter={enterDesignMode} />}
206254
{mayAddApp && <AddAppSubmenu />}
207255
</DropdownMenuContent>
208256
</DropdownMenu>

0 commit comments

Comments
 (0)