Skip to content

Commit c890070

Browse files
feat(console): Studio landing cards open package management, and link to all packages (#35516)
Fixes #35196 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:管理员从首页进 Studio 后,每张应用卡片上多了「管理」按钮,一点就能停用或重新启用一个模块,页面右上角还多了「全部软件包」链接;以前要先打开应用、再点顶栏应用名、再点弹层最底下一项才找得到。 - 为什么做:HotCRM 的开发想关掉一个随代码加载的模块却找不到停用按钮,只能手输网址;这次把入口挂到 Studio 首页上。 - 出错会怎样:最坏是 Studio 首页的卡片按钮打不开管理面板或排版走样,停用和启用本身走的是原来那张面板,撤回本改动即可恢复原样。 - 要你做什么:无,席位落地。 ## 席位核对 ### What changes - **Studio landing (`BuilderLanding.tsx`)**: every package card (installed apps and the author's own) carries **Manage**, which opens the same `PackageDetailSheet` the top-bar switcher's "Package info & settings" opens. The sheet's Disable follows the served `disableable`; Enable shows on any disabled package. After a lifecycle action the landing re-reads the list and the sheet's record (a failed re-read closes the sheet with a toast, the switcher's posture). The title row gains **All packages**, a link to the unfiltered Packages route (`/apps/setup/component/developer/packages`, no `source` query). - **Card layout**: each card's two buttons stack in one column, so the app name keeps the width it had with one button. Measured first with them side by side: at 1400px the names truncated ("Multi-Pack..."); stacked, `scrollWidth > clientWidth` is false for both names at 1400px and at 390px, and no horizontal page scroll. - **`PackageSwitcher.tsx`**: the switcher's full-row read is hoisted, unchanged in body, from an in-component `useCallback` to the exported `fetchInstalledPackageRow`, so both doors open the sheet on the same record. The switcher keeps its own `fetchFullPackage` alias, so its tests and comments still read the same. - **`setup-nav.contributions.ts` comment and `setup-packages-door.test.ts`**: they now name the door a default boot serves (the console Studio at `/_console/studio`: landing link plus card Manage) instead of `studio.app.ts`'s Overview → Packages, which only a host that loads `@objectstack/studio` serves. The pin's third case is retitled as the declared app's entry; its assertions are unchanged. - i18n: four `studio` namespace rows, en and zh. Changeset: `@object-ui/app-shell` and `@object-ui/i18n`, patch. - Not touched: the `@objectstack/studio` load lists, Setup navigation entries, `packages/spec/**` (ruling 甲, option C). ### Tests <details><summary>New test, landing tests, switcher tests (head 9428e59)</summary> - `BuilderLanding.packagesDoor-35196.test.tsx` (5 cases, real `BuilderLanding` and real `PackageDetailSheet`): a `disableable` code module's Manage opens a sheet with Disable; control, a read-only app the door refuses opens one with neither Disable nor Enable; a disabled module's sheet offers Enable; every card carries Manage; the All packages link is the unfiltered route. - `vitest run packages/app-shell/src/views/studio-design/BuilderLanding` at 9428e59: Test Files 13 passed (13), Tests 95 passed (95). - Earlier, at 78f732a: `BuilderLanding*` + `StudioDesignSurface.manage*` / `.package*` / `.homeLoop*` + `packages-io*`: Test Files 25 passed (25), Tests 222 passed (222). - `pnpm --filter @object-ui/app-shell type-check` at 9428e59: exit 0. `@object-ui/i18n type-check` at 78f732a: exit 0 (i18n unchanged since). - `@objectstack/platform-objects` `setup-packages-door.test.ts`: Tests 3 passed (3). </details> <details><summary>Ablation, one run, then restored</summary> `node scripts/ablation-replace.mjs` changed `const manageButton = (p: PkgEntry) => (` to `... => null && (` (anchor 1 → 0, blob 30ad627 → cadcb7d1). Result: 4 of 5 cases red (every Manage case); the All packages link case stayed green, as expected. Restored: the blob equals HEAD (30ad627) and `git diff HEAD` is empty. The test imports `./BuilderLanding` from source, so no build was needed. </details> ### Acceptance notes - Browser readings before the change (B1–B3) are on the card, comment 7008882599. Summary: the switcher entry works end to end (`PATCH …/disable` 200, `…/enable` 200); a disabled package is not stranded; the landing had no Manage and no link to the full list. - The switcher's entry is labelled "Package info & settings", not "Manage". It is left as it is (outside this card's surface); the landing's button is the visible "Manage". - A disabled package's landing card shows no disabled state; the sheet does. Not changed here. - The All packages route is hosted under the Setup app's address, the one console app every boot loads; no Setup nav item is added (ruling 甲). A Studio-hosted route for the full list does not exist today. ### Verification <details><summary>Browser, after the change</summary> Boot: `examples/app-multi-package`, `objectstack dev --ui --seed-admin` on a private port. The Console was served from `ui/` source through Vite HMR, proxied to that backend; Playwright Chromium, admin user. - Landing at 1400px: two installed-app cards, each with Customize and Manage; All packages in the title row with href `/apps/setup/component/developer/packages`. - Manage on `com.example.multi.orders` opened the sheet (module · Read-only · code · Enabled · View info / Disable / Export). Disable → confirm → `PATCH …/disable` 200 → Enable shown → `PATCH …/enable` 200 → Disable shown. - The unfiltered route on the built Console (`/_console/apps/setup/component/developer/packages`, which redirects to the setup package-id segment) lists both packages under a Packages heading. </details> <details><summary>Gates (local subset, final head 9428e59)</summary> - `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran` (with exit codes): 69 derived families accounted for: 68 run with exit 0, 1 NOT MEASURED. - NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, PREREQUISITE NOT MET (it needs every package's `dist/`; only the CLI closure was built here). CI runs it. - `pnpm --dir ui exec vitest run scripts/`: Test Files 171 passed | 2 skipped (173), exit 0. The first run was SIGKILLed when the shared box ran out of memory; it was run again under the lock. - `node scripts/pm/overlap-check.mjs --branch=HEAD`: VERDICT clean exit 0. - Families CI runs (lint, Test Core, Type Check UI and the rest) are left to the PR's check-runs. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CbP6iSEGkWb5fn8yqd)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent a354bb0 commit c890070

8 files changed

Lines changed: 438 additions & 135 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): the Studio landing opens package management in one click
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Studio's landing (the App Builder home at `/_console/studio`) is now the visible door to package management. Every package card carries **Manage**, which opens the same detail sheet as the top-bar package switcher's "Package info & settings": Disable where the server says the package can be switched off (a module of an installed app, or your own app), Enable on a disabled package, and export. The title row gains an **All packages** link to the unfiltered Packages page. Before, the only way in from a menu was to open a package, open the package switcher and pick its last entry, so admins of code-loaded modules looked for Disable and did not find it.

‎packages/platform-objects/src/apps/setup-nav.contributions.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,21 @@ export const SETUP_NAV_CONTRIBUTIONS: NavigationContribution[] = [
4141
// No `group_apps` entry ships from this package.
4242
//
4343
// No unfiltered Packages entry (#25098, ruling 甲 amending #23892 B): the
44-
// full `developer:packages` list is a development surface, so its one
45-
// unfiltered door is Studio's Overview → Packages (`studio.app.ts`). Setup
46-
// reaches installed packages through the marketplace-filtered "Installed
47-
// Apps" door (`nav_marketplace_installed`, `developer:packages` with
44+
// full `developer:packages` list is a development surface, so its door is in
45+
// Studio only. The Studio that every boot serves is the console's own, at
46+
// `/_console/studio` (the `@objectstack/studio` app is not default-loaded,
47+
// so `studio.app.ts`'s Overview → Packages entry is served only where a host
48+
// loads that app). There, the landing's "All packages" link opens the
49+
// unfiltered page, and each package card's Manage (like the top-bar
50+
// switcher's "Package info & settings") opens the package's detail sheet,
51+
// with Disable / Enable (#35196, pinned on the console side by
52+
// `BuilderLanding.packagesDoor-35196.test.tsx`). Setup reaches installed
53+
// packages through the marketplace-filtered "Installed Apps" door
54+
// (`nav_marketplace_installed`, `developer:packages` with
4855
// `params: { source: 'marketplace' }`), which
4956
// `@objectstack/cloud-connection` contributes to this group wherever the
5057
// marketplace capability is present. `setup-packages-door.test.ts` pins
51-
// both halves.
58+
// what this package ships for each app.
5259
//
5360
// And no Packaged Actions entry (objectstack#34724, the ADR-0146 D4
5461
// amendment of 2026-11-17): a packaged action's on/off switch for this

‎packages/platform-objects/src/apps/setup-packages-door.test.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,25 @@
55
//
66
// The console's `developer:packages` component is the one list of what is
77
// installed. Opened with no `source` filter it is a development surface, so its
8-
// unfiltered entry lives in Studio only (Overview → Packages). Setup reaches
9-
// installed packages through the marketplace-filtered "Installed Apps" door —
8+
// unfiltered door lives in Studio only. Setup reaches installed packages
9+
// through the marketplace-filtered "Installed Apps" door —
1010
// `developer:packages` with `params: { source: 'marketplace' }` — which
1111
// `@objectstack/cloud-connection` contributes to Setup's `group_apps` wherever
1212
// the marketplace capability is present, and pins on its side
1313
// (`marketplace-installed-ui-entry.pin.test.ts`).
1414
//
15+
// The Studio every boot serves is the console's own, at `/_console/studio`:
16+
// the `@objectstack/studio` app this package declares (`studio.app.ts`) is not
17+
// default-loaded (`apps/studio/src/index.ts`). So the served door is the
18+
// console's, not a nav item: the Studio landing's "All packages" link and each
19+
// package card's Manage, which opens the detail sheet with Disable / Enable
20+
// (#35196). The console pins that door
21+
// (`ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx`).
22+
//
1523
// This file is the platform-objects half: what THIS package ships for each app.
1624
// Both directions are pinned, because either regression is silent at runtime —
17-
// an unfiltered Setup entry simply renders, and a Studio entry that goes
18-
// missing leaves the full list reachable only by a hand-typed URL.
25+
// an unfiltered Setup entry simply renders, and the declared Studio app's entry
26+
// is what a host that does load that app serves.
1927
import { describe, it, expect } from 'vitest';
2028

2129
import { SETUP_APP } from './setup.app.js';
@@ -72,7 +80,10 @@ describe('the unfiltered package list is a Studio surface, not a Setup one (#250
7280
expect(items.filter((i) => i.id === 'nav_packages')).toEqual([]);
7381
});
7482

75-
it('Studio still ships the unfiltered entry, under Overview', () => {
83+
// The declared `@objectstack/studio` app, for a host that loads it. Not the
84+
// door a default boot serves: that one is the console Studio landing's
85+
// (see the file header).
86+
it('the declared Studio app still ships the unfiltered entry, under Overview', () => {
7687
const overview = walk(STUDIO_APP.navigation as unknown[]).find((i) => i.id === 'group_overview');
7788
expect(overview, 'Studio lost its group_overview').toBeDefined();
7889

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35196 — the served Studio's door to package management.
5+
*
6+
* Ruling 甲 (objectstack#25098) puts the unfiltered package list in Studio
7+
* only. The `@objectstack/studio` app whose Overview → Packages entry names it
8+
* is not default-loaded, so on a default boot the Studio is the console's own,
9+
* at `/studio`, and its landing is the door: each package card carries Manage,
10+
* which opens the package's detail sheet (the one the top-bar switcher's
11+
* "Package info & settings" opens), and the title row links to the unfiltered
12+
* Packages page.
13+
*
14+
* Read off the real `BuilderLanding` and the real `PackageDetailSheet`. The
15+
* sheet's Disable is the served `disableable` verdict and its Enable follows a
16+
* disabled record, so the cases hold one package of each kind, with a
17+
* read-only package the server does not let be disabled as the control.
18+
*/
19+
20+
import '@testing-library/jest-dom/vitest';
21+
// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock.
22+
import '@objectstack/lint';
23+
import * as React from 'react';
24+
import { afterEach, describe, expect, it, vi } from 'vitest';
25+
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';
26+
import { MemoryRouter, Route, Routes } from 'react-router-dom';
27+
import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config';
28+
29+
/** A code-loaded module of an installed app: the server serves `disableable: true`. */
30+
const MODULE = { id: 'com.example.multi.orders', name: 'Multi-Package Orders' };
31+
/** A code-loaded app: read-only, and the disable door refuses it. */
32+
const APP = { id: 'com.example.multi.core', name: 'Multi-Package Core' };
33+
/** A module already switched off. */
34+
const DISABLED = { id: 'com.example.multi.extras', name: 'Multi-Package Extras' };
35+
/** The author's own writable base. */
36+
const OWN = { id: 'com.acme.mine', name: 'My App' };
37+
38+
const entries = [
39+
{ ...MODULE, writable: false, namespace: 'crm' },
40+
{ ...APP, writable: false, namespace: 'crm' },
41+
{ ...DISABLED, writable: false, namespace: 'crm' },
42+
{ ...OWN, writable: true, namespace: 'mine' },
43+
];
44+
45+
/** `GET /api/v1/packages` as the wire serves it: the full rows the sheet opens on. */
46+
const servedRows = [
47+
{ manifest: { ...MODULE, version: '1.0.0', type: 'module' }, source: 'code', writable: false, disableable: true, enabled: true, status: 'installed' },
48+
{ manifest: { ...APP, version: '1.0.0', type: 'app' }, source: 'code', writable: false, disableable: false, enabled: true, status: 'installed' },
49+
{ manifest: { ...DISABLED, version: '1.0.0', type: 'module' }, source: 'code', writable: false, disableable: true, enabled: false, status: 'disabled' },
50+
{ manifest: { ...OWN, version: '0.1.0', type: 'app' }, source: 'authored', writable: true, disableable: true, enabled: true, status: 'installed' },
51+
];
52+
53+
vi.mock('./packages-io', async (importOriginal) => {
54+
const mod = await importOriginal<typeof import('./packages-io')>();
55+
return {
56+
...mod,
57+
fetchPackages: vi.fn(async () => entries),
58+
fetchListedPackageIds: vi.fn(async () => new Set(entries.map((e) => e.id))),
59+
};
60+
});
61+
62+
// The create dialog is closed throughout; its form stack is not under test.
63+
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
64+
65+
import { BuilderLanding, STUDIO_ALL_PACKAGES_PATH } from './BuilderLanding';
66+
67+
const json = (body: unknown, status = 200) =>
68+
({ ok: status < 400, status, json: async () => body, text: async () => JSON.stringify(body) }) as Response;
69+
70+
afterEach(() => {
71+
cleanup();
72+
vi.unstubAllGlobals();
73+
resetRuntimeConfigForTesting();
74+
});
75+
76+
async function renderLanding() {
77+
resetRuntimeConfigForTesting();
78+
vi.stubGlobal(
79+
'fetch',
80+
vi.fn(async (input: RequestInfo | URL) => {
81+
const url = String(input);
82+
if (/\/api\/v1\/packages(\?|$)/.test(url)) return json({ success: true, data: { packages: servedRows } });
83+
if (url.includes('/api/v1/meta/_drafts')) return json({ drafts: [] });
84+
return json({ features: { installLocal: false, marketplace: false } });
85+
}),
86+
);
87+
await initRuntimeConfig();
88+
render(
89+
<MemoryRouter initialEntries={['/studio']}>
90+
<Routes>
91+
<Route path="/studio" element={<BuilderLanding />} />
92+
</Routes>
93+
</MemoryRouter>,
94+
);
95+
await screen.findByText(MODULE.name);
96+
}
97+
98+
/** The card for `id`, and its Manage button. */
99+
function manageOn(id: string): HTMLElement {
100+
const card = document.querySelector<HTMLElement>(`[data-package-id="${id}"]`);
101+
if (!card) throw new Error(`no card for ${id}`);
102+
return within(card).getByTestId('studio-landing-manage');
103+
}
104+
105+
/** Opens `id`'s sheet from its card and answers the sheet's action names. */
106+
async function openSheet(id: string, name: string): Promise<string[]> {
107+
fireEvent.click(manageOn(id));
108+
const sheet = await screen.findByRole('dialog');
109+
await within(sheet).findByText(name);
110+
return within(sheet)
111+
.getAllByRole('button')
112+
.map((b) => (b.textContent ?? '').trim())
113+
.filter(Boolean);
114+
}
115+
116+
describe('the Studio landing is the served door to package management (objectstack#35196)', () => {
117+
it('a code-loaded module the server lets be disabled opens a sheet with Disable', async () => {
118+
await renderLanding();
119+
expect(await openSheet(MODULE.id, MODULE.name)).toContain('Disable');
120+
});
121+
122+
it('control: a read-only app the disable door refuses opens a sheet without Disable', async () => {
123+
await renderLanding();
124+
const actions = await openSheet(APP.id, APP.name);
125+
expect(actions).not.toContain('Disable');
126+
expect(actions).not.toContain('Enable');
127+
});
128+
129+
it('a disabled package opens a sheet with Enable, so switching it back on stays one click from the landing', async () => {
130+
await renderLanding();
131+
const actions = await openSheet(DISABLED.id, DISABLED.name);
132+
expect(actions).toContain('Enable');
133+
expect(actions).not.toContain('Disable');
134+
});
135+
136+
it("every card carries Manage, the author's own apps included", async () => {
137+
await renderLanding();
138+
for (const { id } of entries) expect(manageOn(id)).toBeInTheDocument();
139+
expect(await openSheet(OWN.id, OWN.name)).toContain('Disable');
140+
});
141+
142+
it('the title row links to the unfiltered Packages page', async () => {
143+
await renderLanding();
144+
const link = screen.getByTestId('studio-landing-all-packages');
145+
expect(link).toHaveAttribute('href', '/apps/setup/component/developer/packages');
146+
expect(STUDIO_ALL_PACKAGES_PATH).toBe('/apps/setup/component/developer/packages');
147+
// Unfiltered: no `source` query narrows it to the marketplace view.
148+
expect(link.getAttribute('href')).not.toContain('source=');
149+
});
150+
});

0 commit comments

Comments
 (0)