From ef12b220a618528b22664bb53629259ca0b9d104 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 17:12:56 +0000 Subject: [PATCH 1/2] fix(app-shell): the app's own New report saves into the app's package, as a new view does Claude-Session: https://claude.ai/code/session_01QSeKYprGz1KcPK6n5ZfCZQ Co-authored-by: Claude --- .../src/views/ReportNewPage-36692.test.tsx | 79 ++++++++++++++++--- .../app-shell/src/views/ReportNewPage.tsx | 21 ++--- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/ui/packages/app-shell/src/views/ReportNewPage-36692.test.tsx b/ui/packages/app-shell/src/views/ReportNewPage-36692.test.tsx index 652ed303cb9..46fccabd1b6 100644 --- a/ui/packages/app-shell/src/views/ReportNewPage-36692.test.tsx +++ b/ui/packages/app-shell/src/views/ReportNewPage-36692.test.tsx @@ -220,17 +220,10 @@ describe('the new-report page saves on its own (objectstack#36692)', () => { expect(screen.queryByTestId('report-new-adds-to-menu')).toBeNull(); fireEvent.click(screen.getByText('save')); await waitFor(() => expect(screen.getByTestId('where')).toHaveTextContent('/apps/crm/report/payment_analysis')); - expect(saveAndPublish).toHaveBeenCalledWith( - 'report', - 'payment_analysis', - { ...DRAFT, name: 'payment_analysis' }, - expect.objectContaining({ metadataClient: client }), - ); - // objectstack#36906 — outside Studio it is saved where it was before: naming - // no package, and no package door is asked. - expect(client.save).not.toHaveBeenCalled(); - expect(doors.listCalls).toBe(0); - expect(toastInfo).not.toHaveBeenCalled(); + // objectstack#37261 — where it is saved is pinned by the app's-own-New + // describe below; here, that it was saved and published once. + expect(client.save).toHaveBeenCalledTimes(1); + expect(client.publish).toHaveBeenCalledTimes(1); }); it('Close goes back to the reports index, writing nothing', async () => { @@ -311,6 +304,70 @@ describe('reached with the design mode already on, the page draws no builder (ob }); }); +describe("the app's own New saves into the app's package, as a new view does (objectstack#37261)", () => { + // Opened from the app's reports index, outside Studio: the same rule as the + // Studio leg below and as a new view (`resolveRuntimeCreatePackage`). + async function saveFromApp() { + mount(); + fireEvent.click(screen.getByText('save')); + await waitFor(() => expect(screen.getByTestId('where')).toHaveTextContent('/apps/crm/report/payment_analysis')); + } + + it("from an app on a writable package, a new report names that package", async () => { + await saveFromApp(); + expect(client.save).toHaveBeenCalledWith( + 'report', + 'payment_analysis', + { ...DRAFT, name: 'payment_analysis' }, + { mode: 'draft', ifNoneMatch: '*', packageId: PKG }, + ); + expect(client.publish).toHaveBeenCalledWith('report', 'payment_analysis', { packageId: PKG }); + expect(doors.ensure).not.toHaveBeenCalled(); + expect(saveAndPublish).not.toHaveBeenCalled(); + expect(toastInfo).not.toHaveBeenCalled(); + }); + + it("on an installed (read-only) app, a new report names the base's customization package", async () => { + doors.listed = new Map([[PKG, { writable: false }]]); + doors.ensure.mockImplementation(async (base: string) => ({ packageId: `${base}.custom`, writable: true })); + await saveFromApp(); + expect(doors.ensure).toHaveBeenCalledWith(PKG); + expect(client.save).toHaveBeenCalledWith( + 'report', + 'payment_analysis', + { ...DRAFT, name: 'payment_analysis' }, + { mode: 'draft', ifNoneMatch: '*', packageId: `${PKG}.custom` }, + ); + expect(client.publish).toHaveBeenCalledWith('report', 'payment_analysis', { packageId: `${PKG}.custom` }); + expect(saveAndPublish).not.toHaveBeenCalled(); + expect(toastInfo).not.toHaveBeenCalled(); + }); + + it('control: when the ensure door refuses, Save falls back to naming no package, and says so, as a new view does', async () => { + doors.listed = new Map([[PKG, { writable: false }]]); + doors.ensure.mockImplementation(async () => { + throw Object.assign(new Error('Forbidden'), { status: 403 }); + }); + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + try { + await saveFromApp(); + expect(doors.ensure).toHaveBeenCalledWith(PKG); + expect(client.save).not.toHaveBeenCalled(); + expect(saveAndPublish).toHaveBeenCalledWith( + 'report', + 'payment_analysis', + { ...DRAFT, name: 'payment_analysis' }, + expect.objectContaining({ metadataClient: client }), + ); + expect(toastInfo).toHaveBeenCalledTimes(1); + expect(toastInfo).toHaveBeenCalledWith('report.builder.savedOutsideApp'); + expect(warn).toHaveBeenCalledWith(expect.stringContaining('the report is saved naming no package'), expect.anything()); + } finally { + warn.mockRestore(); + } + }); +}); + describe("opened from Studio's report list (objectstack#36906, decision 13)", () => { const studioList = '/studio/crm/metadata/report?q=pay'; const fromStudio = `?studio=${encodeURIComponent(studioList)}`; diff --git a/ui/packages/app-shell/src/views/ReportNewPage.tsx b/ui/packages/app-shell/src/views/ReportNewPage.tsx index 4571329352f..167448556f0 100644 --- a/ui/packages/app-shell/src/views/ReportNewPage.tsx +++ b/ui/packages/app-shell/src/views/ReportNewPage.tsx @@ -119,12 +119,13 @@ export function ReportNewPage({ dataSource }: { dataSource?: DataSource }) { }, [navigate, appName, studioReturn, studioLeaveMessage], ); - // objectstack#36906 — a report made from Studio's report list is saved in - // the app's package, where that list finds it, as a new view made in an app + // objectstack#36906, objectstack#37261 — a new report is saved in the app's + // package, where Studio's report list finds it, as a new view made in an app // is (`resolveRuntimeCreatePackage`): the package when it is writable, else // its customization package through the ensure door, else, when neither can - // be had, naming no package, as before, and a notice says so. A report made - // from the app's own reports index is saved as before, naming no package. + // be had, naming no package, and a notice says so. One rule for both ways in: + // Studio's report list and the app's own reports index. Outside any app it + // names no package, as a view does. const appPackageId = draftBarPackageOf(appName, apps as Parameters[1]); const handleSave = React.useCallback( @@ -149,7 +150,7 @@ export function ReportNewPage({ dataSource }: { dataSource?: DataSource }) { } const body = { ...draft, label, name }; const ctx = { metadataClient, dataSource: dataSource as any }; - const packageId = studioReturn ? await resolveRuntimeCreatePackage(appPackageId, 'report') : null; + const packageId = await resolveRuntimeCreatePackage(appPackageId, 'report'); const outcome = packageId ? await saveAndPublishInPackage('report', name, body, packageId, ctx) : await saveAndPublishRuntimeMetadata('report', name, body, ctx); @@ -157,11 +158,11 @@ export function ReportNewPage({ dataSource }: { dataSource?: DataSource }) { toast.error(t('form.saveError'), { description: t('report.builder.pendingDraft') }); return false; } - // Opened from Studio, the app's package (or its customization package) - // could not be had, so the report was saved naming no package: the - // Studio list × goes back to does not show it. Say so, as a new view - // saved outside its app does (`onSavedOutsideApp`). - if (studioReturn && appPackageId && !packageId) toast.info(t('report.builder.savedOutsideApp')); + // The app's package (or its customization package) could not be had, + // so the report was saved naming no package: Studio's report list does + // not show it. Say so, whichever way the builder was opened, as a new + // view saved outside its app does (`onSavedOutsideApp`). + if (appPackageId && !packageId) toast.info(t('report.builder.savedOutsideApp')); } catch (err) { toast.error(t('form.saveError'), { description: formatMetadataError(err), From 9ded3000d8fc7c0a888a2f8296e9af4dcec1a54d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 17:19:32 +0000 Subject: [PATCH 2/2] chore(changeset): app's own New report saves into the app's package Claude-Session: https://claude.ai/code/session_01QSeKYprGz1KcPK6n5ZfCZQ Co-authored-by: Claude --- .changeset/37261-app-new-report-package.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .changeset/37261-app-new-report-package.md diff --git a/.changeset/37261-app-new-report-package.md b/.changeset/37261-app-new-report-package.md new file mode 100644 index 00000000000..6c4bb56d962 --- /dev/null +++ b/.changeset/37261-app-new-report-package.md @@ -0,0 +1,14 @@ +--- +'@object-ui/app-shell': patch +--- + +fix(app-shell): a new report made from an app's reports list is saved in the app's package, as a new view is + +Clause-②: no +Metadata-protocol: none + +Studio redesign (epic #36890). + +- **New report from an app's reports list** now saves the report where a new view made in that app is saved: in the app's package when it is writable, or, for an installed app, in its customization package, so Studio's report list for that package shows it. Before, a report made this way belonged to no package. Reports opened from Studio's report list were already saved this way. +- **Where the app's customization package cannot be used** (for example, the deployment does not let a tenant administrator create one), the report is saved outside any package, as before, and a notice says Studio's report list does not show it. A new view falls back the same way. +- **Existing reports are not moved.** Only reports created from now on are placed in the app's package.