Skip to content

Commit 178bfae

Browse files
committed
feat(console): a 「⋯」 package menu in Studio's top bar; Import on Setup → Packages
With the Studio home gone, the Packages page's development-face actions (Edit, Export, Duplicate, Revert, Adopt loose items) had no served door. - metadata-admin/packageActions.tsx now holds those actions' requests and dialogs/forms (the package REST helper, revert, export, adopt, the Edit dialog, the Adopt confirmation, the Duplicate form); the development face's detail sheet imports them unchanged in behaviour. - studio-design/StudioPackageMenu.tsx: the 「⋯」 beside the app or package name, six items in the maintainer's table order, each reusing the shared action; Revert asks first and is greyed with no pending changes; Edit, Duplicate, Revert and Adopt are greyed on a read-only package; Manage in Setup… opens Setup → Packages on the package's row. Drawn only with a current package (never ~org / ~all) and for a manage_metadata holder. - PackagesPage: Import beside New Package on the administration face too; `?package=ID` on that face opens the package's detail on arrival. - en / zh keys under engine.studio.packageMenu.*; a changeset. Claude-Session: https://claude.ai/code/session_01QSeKYmjeYX4T3tqfUCDu4K Co-authored-by: Claude <noreply@anthropic.com>
1 parent 17748fb commit 178bfae

11 files changed

Lines changed: 1378 additions & 210 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): a 「⋯」 package menu in Studio's top bar, and Import on Setup → Packages
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
With the Studio home gone, the whole-package actions of the Packages page's development view had no button anywhere. They are back, in two places:
12+
13+
- **Studio's top bar.** Beside the app or package name at the left end there is now a 「⋯」 menu (zh: 软件包操作) with six items: Edit package info (编辑软件包信息), Export (导出), Duplicate as a new package (复制为新软件包), Revert to last publish (还原到上次发布), Adopt loose items (收编散落项) and Manage in Setup… (在设置中管理…). Each opens the same dialog and sends the same request as the development view's button; the answer appears as a toast. Revert now asks for confirmation first. On a read-only installed package, Edit, Duplicate, Revert and Adopt are greyed with the reason on hover; Revert is also greyed while nothing has changed since the last publish. Manage in Setup… opens Setup → Packages with that package's detail open, where it is enabled, disabled or deleted. The menu is shown only to people who can author metadata (`manage_metadata`), and not in the organization-flows scope or the all-packages view, where no package is open. Publishing every draft is not in the menu: Studio's Changes / Publish already do that.
14+
- **Setup → Packages.** Import now sits in the header beside New Package and works exactly as on the development view. A Setup → Packages address can open one package's detail directly by adding `&package=ID`.
15+
16+
The development view itself is unchanged.
17+
18+
New locale keys in the studio catalogue (en, zh): `engine.studio.packageMenu.trigger`, `.editInfo`, `.duplicate`, `.revert`, `.manageInSetup`, `.noChanges`, `.duplicateTitle`, `.duplicateDescription`, `.revertTitle`, `.revertDescription`.
19+
20+
Seventeen studio-catalogue rows that no screen read any more are removed: `engine.studio.menu.typeCount` and the app-worded `engine.studio.newApp.*` rows (`title`, `description`, `advancedHint`, `id`, `help.*`, `nsDerived`, `created`, `exists`, `failed`). None of them was in a published `@object-ui/i18n` release; `engine.studio.newApp.nameTaken` and `engine.studio.newApp.appFailed` are still used and stay.

‎ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx‎

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
* - a module package (`type: 'module'` declaring its app in `dependencies`)
2525
* is folded under that app's line and shown on demand;
2626
* - the columns are Name, Version, Status, Source, Update, and the developer
27-
* doors (Import, the platform switch, the Source chip's Show all) are not
28-
* drawn; New Package is, and lands in Studio (objectstack#36834).
27+
* doors (the platform switch, the Source chip's Show all) are not drawn;
28+
* New Package is, and lands in Studio (objectstack#36834), with Import
29+
* beside it (objectstack#37139; see the last describe of this file).
2930
* On the Studio door all of the developer doors and columns stay, and the
3031
* catalog is never asked.
3132
*
@@ -91,7 +92,7 @@ vi.mock('./PackageFormDialog', () => ({
9192
import { resolveHref } from '@object-ui/layout';
9293
import { PackageDetailSheet, PackagesPage, type InstalledPackageRow } from './PackagesPage';
9394
import { t } from './i18n';
94-
import { SETUP_NEW_PACKAGE_PATH } from './packageSource';
95+
import { SETUP_NEW_PACKAGE_PATH, setupPackagePath } from './packageSource';
9596
// The page's package form reaches the CEL authoring helpers, which load these
9697
// two lazily; loaded here so their first load is paid at import, not inside a
9798
// test's clocked window.
@@ -235,6 +236,10 @@ async function serve({
235236
if (path === '/api/v1/marketplace/install-local' && method === 'GET') {
236237
return reply(200, { success: true, data: { items: installs } });
237238
}
239+
// objectstack#37139 — Import: the file's manifest, installed.
240+
if (path === '/api/v1/marketplace/install-local' && method === 'POST') {
241+
return reply(200, { success: true, data: { manifestId: 'com.acme.imported' } });
242+
}
238243
const listing = /^\/api\/v1\/marketplace\/packages\/([^/]+)$/.exec(path);
239244
if (listing) {
240245
const id = decodeURIComponent(listing[1]);
@@ -499,7 +504,7 @@ describe('Setup → Installed Apps: an app is one line, its modules folded under
499504
describe('the two doors (objectstack#34722)', () => {
500505
const headers = () => screen.getAllByRole('columnheader').map((h) => h.textContent?.trim());
501506

502-
it('the administration face draws the administrator columns, New Package, and none of the developer doors', async () => {
507+
it('the administration face draws the administrator columns, New Package and Import, and none of the other developer doors', async () => {
503508
await serve({ packages: [HOTCRM, ...MODULES, TODO, CODE, PLATFORM] });
504509
renderAt(SETUP_URL);
505510
await settled();
@@ -512,9 +517,9 @@ describe('the two doors (objectstack#34722)', () => {
512517
row('engine.packages.installedApps.col.update'),
513518
row('engine.packages.col.actions'),
514519
]);
515-
expect(screen.queryByRole('button', { name: row('engine.packages.import') })).toBeNull();
516-
// objectstack#36834 — New Package is the administration face's one header
517-
// action; it lands in Studio (see the create case below).
520+
// objectstack#36834 — New Package lands in Studio (see the create case
521+
// below); objectstack#37139 — Import sits beside it.
522+
expect(screen.getByRole('button', { name: row('engine.packages.import') })).toBeInTheDocument();
518523
expect(screen.getByRole('button', { name: row('engine.packages.new') })).toBeInTheDocument();
519524
expect(screen.queryByTestId('pkg-show-platform')).toBeNull();
520525
expect(screen.queryByTestId('pkg-source-filter')).toBeNull();
@@ -631,12 +636,10 @@ describe('Setup → Packages: the administration face (objectstack#36834)', () =
631636

632637
expect(screen.getByTestId('pkg-source-picker-marketplace')).toHaveAttribute('data-state', 'on');
633638
expect(screen.queryByTestId('pkg-row-com.acme.code')).toBeNull();
634-
expect(screen.queryByRole('button', { name: row('engine.packages.import') })).toBeNull();
635639
// Clearing the filter stays on the administration face.
636640
fireEvent.click(screen.getByTestId('pkg-source-picker-all'));
637641
await waitFor(() => expect(query().get('face')).toBe('admin'));
638642
expect(await screen.findByTestId('pkg-row-com.acme.code')).toBeInTheDocument();
639-
expect(screen.queryByRole('button', { name: row('engine.packages.import') })).toBeNull();
640643
});
641644

642645
it('an unknown face is refused by name, not read as the development surface', async () => {
@@ -927,3 +930,76 @@ describe('Setup → Packages: a read-only base’s customizations in its detail
927930
await waitFor(() => expect(customizationReads).toEqual(['com.acme.code']));
928931
});
929932
});
933+
934+
// ---------------------------------------------------------------------------
935+
// objectstack#37139 — Import sits in Setup → Packages' header beside New
936+
// Package and works as it does on the development face; Studio's package
937+
// menu's 「Manage in Setup…」 opens this face on one package's row
938+
// (`?package=ID`).
939+
// ---------------------------------------------------------------------------
940+
941+
/** The header's Import, fed one package file. */
942+
async function importOn(lang: 'en' | 'zh') {
943+
const button = await screen.findByRole('button', { name: row('engine.packages.import', lang) });
944+
const input = document.querySelector('input[type="file"]') as HTMLInputElement;
945+
const file = new File([JSON.stringify({ id: 'com.acme.imported', name: 'Imported', version: '1.0.0' })], 'imported.json', {
946+
type: 'application/json',
947+
});
948+
fireEvent.change(input, { target: { files: [file] } });
949+
return button;
950+
}
951+
952+
describe('Setup → Packages: Import beside New Package (objectstack#37139)', () => {
953+
it.each(['en', 'zh'] as const)('%s: the header draws Import, then New Package', async (lang) => {
954+
await serve({ packages: [CODE] });
955+
renderAt(ADMIN_URL, lang);
956+
await screen.findByTestId('pkg-row-com.acme.code');
957+
const importButton = screen.getByRole('button', { name: row('engine.packages.import', lang) });
958+
const newButton = screen.getByRole('button', { name: row('engine.packages.new', lang) });
959+
expect(importButton.compareDocumentPosition(newButton) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
960+
expect(importButton.parentElement).toBe(newButton.parentElement);
961+
});
962+
963+
it.each(['en', 'zh'] as const)('%s: Import installs the file and re-reads the list, as on the development face', async (lang) => {
964+
await serve({ packages: [CODE] });
965+
renderAt(ADMIN_URL, lang);
966+
await screen.findByTestId('pkg-row-com.acme.code');
967+
const readsBefore = packagesReads;
968+
await importOn(lang);
969+
expect(
970+
await screen.findByText(t('engine.packages.import.success', lang === 'en' ? 'en-US' : 'zh-CN').replace('{id}', 'com.acme.imported')),
971+
).toBeInTheDocument();
972+
expect(writes).toEqual(['POST /api/v1/marketplace/install-local']);
973+
await waitFor(() => expect(packagesReads).toBeGreaterThan(readsBefore));
974+
});
975+
976+
it('CONTROL: the development surface’s Import sends the same request', async () => {
977+
await serve({ packages: [CODE] });
978+
renderAt(STUDIO_URL);
979+
await screen.findByTestId('pkg-row-com.acme.code');
980+
await importOn('en');
981+
await waitFor(() => expect(writes).toEqual(['POST /api/v1/marketplace/install-local']));
982+
});
983+
});
984+
985+
describe('Setup → Packages on one package’s row: `?package=ID` (objectstack#37139)', () => {
986+
it('opens that package’s detail on arrival and drops the param, keeping the face', async () => {
987+
await serve({ packages: [CODE, AUTHORED] });
988+
renderAt(setupPackagePath('app.b2r4'));
989+
const sheet = await screen.findByRole('dialog');
990+
expect(within(sheet).getByText('app.b2r4')).toBeInTheDocument();
991+
// The administration actions are there: Disable and Delete.
992+
expect(within(sheet).getByRole('button', { name: row('engine.packages.detail.disable') })).toBeInTheDocument();
993+
expect(within(sheet).getByRole('button', { name: row('engine.packages.detail.deletePackage') })).toBeInTheDocument();
994+
await waitFor(() => expect(query().has('package')).toBe(false));
995+
expect(query().get('face')).toBe('admin');
996+
});
997+
998+
it('an id the list does not name opens nothing, and the param is dropped', async () => {
999+
await serve({ packages: [CODE] });
1000+
renderAt(setupPackagePath('com.gone.away'));
1001+
await screen.findByTestId('pkg-row-com.acme.code');
1002+
await waitFor(() => expect(query().has('package')).toBe(false));
1003+
expect(screen.queryByRole('dialog')).toBeNull();
1004+
});
1005+
});

0 commit comments

Comments
 (0)