Skip to content
Draft
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/37454-studio-package-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(studio): a package's 概览 Overview page, with its Info and Pending tabs, and the package's ⋯ menu in its header

Clause-②: no
Metadata-protocol: none

Studio has a page for the open package itself, 概览 Overview, at `/studio/<package>/overview` (ADR-0084, amended 2026-11-26). It is drawn in the frame an item's page has, a header and a row of tabs:

- The header shows the package's name, a chip that reads 系统自带 (Built-in, with a lock) on a read-only package or 可写 (Writable), a chip that reads 使用中 (In use) or 已停用 (Disabled), and the description. The chips come from the package list's own answer (`writable`, `enabled`); a row that does not say draws no chip.
- The ⋯ package menu moved here from the top bar's left end. Its six rows are unchanged: edit info, export, duplicate, revert to last publish, adopt loose items, and Manage in Setup…. Disabling, enabling and deleting a package stay in Setup → Packages.
- 信息 Info lists the name, description, source, version and the package's app, read-only. The id, namespace and type are folded under 技术信息 (Technical details).
- 待发布 Pending (`?tab=pending`) is the pending-changes panel drawn in place, with its Publish all. It publishes through the same request, with the same review, notes, refusals and read-only rule as the top bar's Publish, which stays for now. Its tab shows how many drafts wait.

The Studio menu's first row, above its groups, is 概览 Overview. While drafts wait for a publish it carries their count as a badge, and one click on the badge opens the Pending tab. A search lists it when its name matches.

`DraftChangesPanel` takes two optional props, `embedded` (draw the panel in place instead of as a sheet) and `reloadKey` (read the drafts again when it changes); without them it behaves as before. New locale keys in the studio catalogue (en, zh): `engine.studio.menu.overview`, `engine.studio.menu.overviewPending` and `engine.studio.overview.*`.
755 changes: 402 additions & 353 deletions ui/packages/app-shell/src/preview/DraftChangesPanel.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* The CONTROL is the mount the Home page, `DraftPreviewBar` and
* `CommitTimeline` use: no `posture` prop at all. It must read exactly as the
* review posture does.
*
* objectstack#37454 — the same panel drawn in place (`embedded`), as Studio's
* package overview's Pending tab: the same list and Publish all with no sheet,
* no toast cleared on opening, and a fresh read whenever `reloadKey` moves.
*/

import '@testing-library/jest-dom/vitest';
Expand All @@ -34,6 +38,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
}),
}));

import { toast } from 'sonner';
import { DraftChangesPanel, type DraftChangesPosture } from '../DraftChangesPanel';
// The source under test reaches a dynamic `import('@objectstack/lint')`: pay its load at
// collection, never inside a case's clocked window (`check:test-source-alias`).
Expand Down Expand Up @@ -156,3 +161,63 @@ describe('objectui#12517 — the pending-changes sheet opens in a posture', () =
expectReviewPosture();
});
});

describe('objectstack#37454 — drawn in place as the overview\'s Pending tab (`embedded`)', () => {
const draftReads = () => fetchMock.mock.calls.filter(([input]) => String(input).includes('/_drafts')).length;

function Embedded({ reloadKey, onPublish = () => {} }: { reloadKey?: unknown; onPublish?: () => void }) {
return (
<DraftChangesPanel embedded open onOpenChange={() => {}} packageId="com.x" onPublish={onPublish} reloadKey={reloadKey} />
);
}

it('lists the drafts with Publish all, in place: no sheet, no dialog; its button publishes with no options', async () => {
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
const onPublish = vi.fn();
render(<Embedded onPublish={onPublish} />);
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
expect(screen.getByTestId('draft-changes-panel')).toHaveAttribute('data-embedded');
expect(screen.getByTestId('draft-changes-panel').tagName).toBe('SECTION');
expect(screen.queryByRole('dialog')).toBeNull();
fireEvent.click(screen.getByTestId('draft-changes-publish'));
expect(onPublish).toHaveBeenCalledTimes(1);
expect(onPublish).toHaveBeenCalledWith();
});

it('CONTROL: the sheet is a dialog, and carries no embedded mark', async () => {
await renderHost('review');
expect(screen.getByRole('dialog')).toBeInTheDocument();
expect(screen.getByTestId('draft-changes-panel')).not.toHaveAttribute('data-embedded');
});

it('opening clears no toast; CONTROL: opening the sheet clears them', async () => {
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
const dismiss = vi.spyOn(toast, 'dismiss');
render(<Embedded />);
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
expect(dismiss).not.toHaveBeenCalled();
cleanup();
render(<Host posture="review" />);
await waitFor(() => expect(dismiss).toHaveBeenCalled());
dismiss.mockRestore();
});

it('reads the drafts again when `reloadKey` moves; CONTROL: an unmoved key reads nothing more', async () => {
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
const { rerender } = render(<Embedded reloadKey="a" />);
await waitFor(() => expect(screen.getAllByText(/^(New|Update)$/)).toHaveLength(DRAFT_ROWS.length));
const first = draftReads();
expect(first).toBe(1);
rerender(<Embedded reloadKey="a" />);
await act(async () => {});
expect(draftReads()).toBe(first);
rerender(<Embedded reloadKey="b" />);
await waitFor(() => expect(draftReads()).toBe(first + 1));
});

it('closed, it draws nothing', () => {
vi.stubGlobal('fetch', fetchMock as unknown as typeof fetch);
render(<DraftChangesPanel embedded open={false} onOpenChange={() => {}} packageId="com.x" />);
expect(screen.queryByTestId('draft-changes-panel')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
* Leaving asks first when a pillar holds unsaved work, like every other
* header departure (`beforeNavigate`).
*
* objectstack#37139 — right of the name, the host may draw the package's 「⋯」
* menu (`menu`, `StudioPackageMenu`): only where there is a current package and
* only for a `manage_metadata` holder, which the host decides.
* objectstack#37454 — the package's 「⋯」 menu, which sat right of the name
* (objectstack#37139), moved to 概览 Overview's header (ADR-0084, amended
* 2026-11-26).
*/

import * as React from 'react';
Expand Down Expand Up @@ -88,7 +88,6 @@ export function StudioBackToApp({
locale,
beforeNavigate,
navigate,
menu,
}: {
/** The open package, or `null` in the package-less scope. */
packageId: string | null;
Expand All @@ -104,8 +103,6 @@ export function StudioBackToApp({
/** The header's unsaved-work veto: return false to stay in Studio. */
beforeNavigate: () => boolean;
navigate: (path: string) => void;
/** objectstack#37139 — the package's 「⋯」 menu, drawn right of the name; absent draws none. */
menu?: React.ReactNode;
}): React.ReactElement {
// Read once per visit: nothing in Studio is an app page, so the record
// cannot change while the author is here.
Expand Down Expand Up @@ -153,7 +150,6 @@ export function StudioBackToApp({
</span>
</>
)}
{menu}
<span aria-hidden="true" className="shrink-0 text-muted-foreground">
·
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
* `DraftChangesPanel`, reduced to the button that fires `onPublish` (the sheet
* has its own tests, `../../preview/__tests__/`).
*
* objectstack#37454 — the package's publish has a second door, 概览
* Overview's Pending tab (the panel drawn in place, `embedded`), wired to the
* same publish: every package-batch case below runs through both doors, the
* top bar's and the Pending tab's, with the same expectations.
*
* The expected sentences are read from the string table through the same
* `tFormat` the surface calls, so what is pinned is which row and which count,
* never the prose.
Expand Down Expand Up @@ -70,9 +75,13 @@ vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPan
vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null }));
vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null }));
vi.mock('../../preview/DraftChangesPanel', () => ({
DraftChangesPanel: ({ onPublish }: { onPublish?: () => void | Promise<void> }) =>
DraftChangesPanel: ({ onPublish, embedded }: { onPublish?: () => void | Promise<void>; embedded?: boolean }) =>
onPublish ? (
<button type="button" data-testid="publish-all-drafts" onClick={() => void onPublish()}>
<button
type="button"
data-testid={embedded ? 'publish-all-drafts-pending-tab' : 'publish-all-drafts'}
onClick={() => void onPublish()}
>
publish
</button>
) : null,
Expand Down Expand Up @@ -159,7 +168,7 @@ afterEach(() => {
vi.unstubAllGlobals();
});

async function publishAt(path: string, expectPosts: number): Promise<void> {
async function publishAt(path: string, expectPosts: number, button = 'publish-all-drafts'): Promise<void> {
render(
<MemoryRouter initialEntries={[path]}>
<Routes>
Expand All @@ -168,10 +177,19 @@ async function publishAt(path: string, expectPosts: number): Promise<void> {
</Routes>
</MemoryRouter>,
);
fireEvent.click(await screen.findByTestId('publish-all-drafts'));
fireEvent.click(await screen.findByTestId(button));
await waitFor(() => expect(posts).toHaveLength(expectPosts));
}

/**
* objectstack#37454 — the two doors of the package's publish: the top bar's
* Publish (its review sheet's button), and 概览 Overview's Pending tab.
*/
const PACKAGE_DOORS = [
{ door: 'the top bar', path: `/studio/${PACKAGE_ID}/interfaces`, button: 'publish-all-drafts' },
{ door: 'the overview\'s Pending tab', path: `/studio/${PACKAGE_ID}/overview?tab=pending`, button: 'publish-all-drafts-pending-tab' },
] as const;

/** Every toast the publish raised, by kind. */
function toasts() {
return {
Expand All @@ -181,7 +199,7 @@ function toasts() {
};
}

describe('the package publish names how many items went live, and what was refused (objectui#11807)', () => {
describe.each(PACKAGE_DOORS)('the package publish names how many items went live, and what was refused (objectui#11807) — from $door', ({ path, button }) => {
it('two published items: the count row, with 2', async () => {
batchBody = batch({
outcome: 'published',
Expand All @@ -190,7 +208,7 @@ describe('the package publish names how many items went live, and what was refus
published: published('repairs_repair_ticket', 'visit'),
failed: [],
});
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
await publishAt(path, 1, button);
await waitFor(() => expect(toast.success).toHaveBeenCalled());
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCount', 'en', { count: 2 })]);
expect(toasts().error).toEqual([]);
Expand All @@ -204,7 +222,7 @@ describe('the package publish names how many items went live, and what was refus
published: published('visit'),
failed: [],
});
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
await publishAt(path, 1, button);
await waitFor(() => expect(toast.success).toHaveBeenCalled());
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCountOne', 'en', { count: 1 })]);
});
Expand All @@ -222,15 +240,15 @@ describe('the package publish names how many items went live, and what was refus
failed: [],
unregistered: [{ type: 'object', name: 'visit', rule: 'object-registry-refused' }],
});
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
await publishAt(path, 1, button);
await waitFor(() => expect(toast.success).toHaveBeenCalled());
expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCount', 'en', { count: 2 })]);
expect(toasts().error).toEqual([]);
});

it('nothing to publish: said as such, neither a success nor a failure', async () => {
batchBody = batch({ outcome: 'nothing_to_publish', publishedCount: 0, failedCount: 0, published: [], failed: [] });
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
await publishAt(path, 1, button);
await waitFor(() => expect(toast.info).toHaveBeenCalled());
expect(toasts()).toEqual({ success: [], info: [t('engine.studio.publishNoneTitle', 'en')], error: [] });
});
Expand All @@ -247,7 +265,7 @@ describe('the package publish names how many items went live, and what was refus
published: [],
failed: [{ type: 'object', name: 'visit', error: reason, code: 'SECURITY_OWD_UNSET' }],
});
await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1);
await publishAt(path, 1, button);
await waitFor(() => expect(toast.error).toHaveBeenCalled());
expect(toasts().success).toEqual([]);
expect(toasts().info).toEqual([]);
Expand Down
Loading
Loading