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
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
3839import * 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' ;
4242import { useObjectTranslation } from '@object-ui/i18n' ;
4343import { useMetadata } from '../providers/MetadataProvider.js' ;
4444import { useNavigationContext } from '../context/NavigationContext.js' ;
4545import { matchAppBySegment , appStudioRoutePath } from '../utils/index.js' ;
4646import { useStudioEntryGate , type StudioEntry } from '../hooks/useStudioDesignGate.js' ;
47- import { useServedAppLabel } from '../hooks/useServedAppLabel.js' ;
4847import { useAiSurfaceEnabled } from '../hooks/useAiSurface.js' ;
4948import {
5049 ShellPageActionsSlotContext ,
@@ -55,9 +54,6 @@ import {
5554import { LocalizedSidebarTrigger } from './LocalizedSidebarTrigger.js' ;
5655import { AssistantTopBarButton } from './AssistantTopBarButton.js' ;
5756import { 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 */
190187export 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-
289205export 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
302218function 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 >
0 commit comments