Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/36899-studio-left-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@object-ui/app-shell': patch
'@object-ui/components': patch
'@object-ui/i18n': patch
'@object-ui/console': patch
---

feat(studio): a collapsible left menu of six groups replaces the top pillar nav

Clause-②: yes (widening)
Metadata-protocol: none

ADR-0084 (amended) · #36899, part of #36890.

- **Studio's one navigation is a left menu.** The top bar's Data / Automations / Access / All metadata switcher is gone. Every Studio page (a package's pillars and area, the package-less flows `~org`, and the cross-package leg `~all`) draws the same menu of six groups: Data, UI, Automation, Platform, Access, AI (数据、界面、自动化、平台、访问、AI). Each group lists the metadata types the package holds (the directory's own rule, `scopeDirectoryEntries`), with a type count per group and an item count per type, and a search box that narrows the entries. A type entry opens that type's list in the area; an item of an object, flow or permission set still opens its designer. Four entries are not a type: Organization flows (`~org`, under Automation), Default sharing (the Access pillar's OWD overview, under Access), Diagnostics (under Platform) and Positions and permissions (the environment catalog on `~all`, under Access).
- **It collapses like the app sidebar, under its own cookie.** It is the app sidebar's primitive: the header's toggle hides and shows it, the state survives a reload under `studio_menu_state` (never the app sidebar's `sidebar_state`), and below 768 px it is a drawer. `SidebarProvider` (`@object-ui/components`) takes a new optional `cookieName` prop for that; the default is unchanged.
- **The menu names the `system` group Platform / 平台 and the `security` group Access / 访问**, the amended ADR-0084's group names, through its own `studioMenuGroupLabel`. The shared domain dictionary (`translateMetadataDomain`) is unchanged: Setup's datasource pages and the rest of Studio still say System / 系统 and Security / 安全.
- **`~all` is drawn in the builder's shell.** `/studio/~all/metadata/*` is served by the same route as a package's area, so it has the left menu too; the landing's frame no longer draws it. A `~org` area URL (or `?package=~org`) now lands on the package-less flows instead of being read as a package.
- **「‹ Back to app」 names the current package's app** (decision 5), never a remembered app of another package; a package with no app names the package and goes to the apps home.
- Changes and Publish stay at the right end of the top bar, beside Cancel and Save.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
* the route hands it `area="metadata"`. `:packageId/:tab` matches one
* segment, so without this route an area URL such as
* `/studio/crm/metadata/flow` matched nothing.
* - The cross-package leg (`/studio/~all/metadata/*`) is the area alone, with
* no package, in the frame the landing draws. Every other `~all` URL lands
* on it, so none reaches the pillar builder as a package id.
* - The entry gate decides first, as for every Studio URL.
* - The cross-package leg (`/studio/~all/metadata/*`) is the same builder
* route with `~all` as its segment (objectstack#36899): the surface draws
* the area alone, with no package, beside the left menu every Studio page
* has. Every other `~all` URL lands on it, so none reaches a pillar.
* - The entry gate decides first, as for every Studio URL, the left menu's
* targets included.
*
* The builder module is mocked with markers (as in
* `StudioRoute.lazyBuilder-11798.test.tsx`); the gate, the frame and the
Expand Down Expand Up @@ -139,28 +141,37 @@ describe('/studio — the "All metadata" area\'s routes (objectstack#28561)', ()
expect(surface).toHaveAttribute('data-area', '');
});

it('the cross-package leg is the area alone, with no package, in the landing\'s frame', async () => {
it('the cross-package leg is the builder with its area open on `~all` (objectstack#36899: one shell, one menu)', async () => {
renderStudio('/studio/~all/metadata/permission?scope=environment');
const area = await screen.findByTestId('studio-metadata-area');
expect(area).toHaveAttribute('data-package', 'null');
expect(screen.queryByTestId('studio-pillar-builder')).toBeNull();
// The console's own top bar frames it; its brand links home.
expect(screen.getByRole('link', { name: 'ObjectOS home' })).toHaveAttribute('href', '/home');
const surface = await screen.findByTestId('studio-pillar-builder');
expect(surface).toHaveAttribute('data-package', '~all');
expect(surface).toHaveAttribute('data-area', 'metadata');
// The landing's frame (the console's top bar) no longer draws it.
expect(screen.queryByRole('link', { name: 'ObjectOS home' })).toBeNull();
expect(screen.queryByTestId('studio-metadata-area')).toBeNull();
expect(location()).toBe('/studio/~all/metadata/permission?scope=environment');
});

it.each(['/studio/~all', '/studio/~all/data', '/studio/~all/flow/f1'])(
'%s lands on the cross-package area, never on the builder as a package id',
'%s lands on the cross-package area, never on a pillar',
async (url) => {
renderStudio(url);
expect(await screen.findByTestId('studio-metadata-area')).toBeInTheDocument();
const surface = await screen.findByTestId('studio-pillar-builder');
expect(location()).toBe('/studio/~all/metadata');
expect(screen.queryByTestId('studio-pillar-builder')).toBeNull();
expect(surface).toHaveAttribute('data-area', 'metadata');
expect(surface).toHaveAttribute('data-package', '~all');
},
);

it.each(['/studio/~all/metadata', '/studio/com.example.crm/metadata'])(
'a principal the gate refuses gets neither leg: %s',
it.each([
'/studio/~all/metadata',
'/studio/com.example.crm/metadata',
// objectstack#36899 — the left menu's targets that are not an area list.
'/studio/~org/automations',
'/studio/com.example.crm/access?surface=owd%3Aoverview',
'/studio/com.example.crm/metadata/_diagnostics',
])(
'a principal the gate refuses gets none of them: %s',
async (url) => {
permissionsFetch = answer(['setup.access']);
renderStudio(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ describe('/studio/PKG/TAB records the package as a recent entry (objectui#11863)
expect(persisted()).toBeNull();
});

it('the cross-package leg is not a package either, now the builder draws it (objectstack#36899)', async () => {
renderStudio('/studio/~all/metadata/permission?scope=environment');
await screen.findByTestId('studio-pillar-builder');

expect(recent()).toEqual([]);
expect(persisted()).toBeNull();
});

it('a principal the entry gate refuses records nothing: the visit is recorded behind the gate', async () => {
permissionsFetch = async () => jsonResponse({ authenticated: true, systemPermissions: ['setup.access'] });
renderStudio('/studio/com.acme.crm/data');
Expand Down
42 changes: 14 additions & 28 deletions ui/apps/console/src/components/StudioRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ const StudioDesignSurface = lazy(() =>
const BuilderLanding = lazy(() =>
import('./studioBuilder').then((m) => ({ default: m.BuilderLanding })),
);
const StudioMetadataArea = lazy(() =>
import('./studioBuilder').then((m) => ({ default: m.StudioMetadataArea })),
);

/**
* What a principal without `studio.access` sees, at the Studio URL they opened
Expand Down Expand Up @@ -221,7 +218,7 @@ function StudioLanding() {
}

/**
* The console frame `/studio` screens without a package draw (objectui#11863):
* The console frame the `/studio` landing draws (objectui#11863):
* the console's own top bar in its `studio` variant and the command palette in
* its `studio` scope, around a body that loads with its route.
*/
Expand All @@ -246,21 +243,6 @@ function StudioConsoleFrame({ children }: { children: ReactNode }) {
);
}

/**
* objectstack#28561 — the "All metadata" area's cross-package leg
* (`/studio/~all/metadata/*`, ADR-0146 D1): the environment catalog, served
* with no package. No package means no pillars, no package switcher and no
* package publish, so it is not the pillar builder: it is the area alone, in
* the frame the landing draws, which it is entered from.
*/
function StudioAllPackagesMetadata() {
return (
<StudioConsoleFrame>
<StudioMetadataArea packageId={null} />
</StudioConsoleFrame>
);
}

/**
* A package's pillar builder, which records the visit as a recent `package`
* entry (objectui#11863), so the landing can list the packages an author was
Expand All @@ -272,14 +254,14 @@ function StudioAllPackagesMetadata() {
* which lands on the Data pillar — and no label: the landing labels it from the
* package list it loads (objectui#11678's shape). Keyed on the package, not the
* pillar, so moving between pillars of one package leaves the list as it is,
* and the provider writes nothing. The package-less scope (`~org`) is not a
* package and records nothing.
* and the provider writes nothing. The package-less scope (`~org`) and the
* cross-package leg (`~all`) are not packages and record nothing.
*/
function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) {
const { packageId } = useParams();
const { addRecentItem } = useRecentItems();
useEffect(() => {
if (!packageId || packageId === STUDIO_ORG_SCOPE_SEGMENT) return;
if (!packageId || packageId === STUDIO_ORG_SCOPE_SEGMENT || packageId === STUDIO_ALL_PACKAGES_SEGMENT) return;
addRecentItem({
id: `package:${packageId}`,
type: 'package',
Expand Down Expand Up @@ -309,8 +291,7 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA })
*
* `/studio` front door (pick / create a writable package)
* `/studio/~org` the package-less scope lands on its one pillar
* `/studio/~all/metadata/*` the "All metadata" area across packages
* `/studio/~all/*` lands on that area
* `/studio/~all/*` lands on the "All metadata" area across packages
* `/studio/:packageId` a package lands on its Data pillar
* `/studio/:packageId/metadata/*` a package's "All metadata" area, in the builder
* `/studio/:packageId/:tab` the pillar builder (a recent-package visit)
Expand All @@ -331,6 +312,15 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA })
* cross-package segment (`metadataArea.ts` in app-shell says why it is not
* `~org`); every `~all` URL outside the area lands on it, so none reaches the
* pillar builder as a package id.
*
* objectstack#36899 — the cross-package leg (`/studio/~all/metadata/*`) is
* served by the generic area route, as `~org`'s pillar is by the generic pillar
* route: the SAME `StudioDesignSurface`, which reads `~all` as "no package"
* and draws the area alone, under the left menu every Studio page draws. It
* used to be the area in the landing's console frame, a second shell the
* author flipped into from the menu's Access group. The more specific
* `:packageId/metadata/*` outranks `~all/*` for an area URL; every other
* `~all` URL still lands on the area.
*/
export const studioRoutes = (
<Route path="/studio" element={<StudioRoute />}>
Expand All @@ -339,10 +329,6 @@ export const studioRoutes = (
path={STUDIO_ORG_SCOPE_SEGMENT}
element={<Navigate to={STUDIO_ORG_SCOPE_PILLAR} replace />}
/>
<Route
path={`${STUDIO_ALL_PACKAGES_SEGMENT}/${STUDIO_METADATA_AREA}/*`}
element={<StudioAllPackagesMetadata />}
/>
<Route
path={`${STUDIO_ALL_PACKAGES_SEGMENT}/*`}
element={<Navigate to={studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT)} replace />}
Expand Down
Loading
Loading