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
18 changes: 18 additions & 0 deletions .changeset/34714-studio-landing-env-customizations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@object-ui/i18n': patch
---

feat(console): the Studio landing lists every change this environment made to its installed apps in one panel

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

The Studio landing gains a **Customizations in this environment** panel under the installed apps, so "what did we change here" no longer means opening each app.

- One row per change, read from each installed app's customization read (`GET /api/v1/packages/:id/customizations`, the read its card already makes): items the app's customization package overrides read **Changed**, fields, validation rules and indexes it adds read **Added**, the app's items switched off in this environment read **Switched off**. What other packages contribute is not this environment's change and makes no row.
- Each row names the item (its label where the app's list gives one, else its name), its kind and its app, and opens it in Studio.
- Tabs narrow the list (All, New fields, Forms and views, Flows, Switched off), a search narrows it by text, and the rows can be grouped by app. The first six rows show; the rest are behind "Show all".
- The panel's total equals the cards' "customized" plus "switched off": one read per app now serves both the card and the panel.
- With no change anywhere the panel is one line. An app whose read fails (a 403 included) is named as unreadable, never counted as 0.

New keys under `engine.studio.landing.envCustomizations.*` in the studio namespace (en, zh). No server change.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ vi.mock('./packages-io', async (importOriginal) => {
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
// A read-only base's customization read (ADR-0146 D3) is not under test here:
// it stays pending, so no request leaves the file.
vi.mock('./packageCustomizations-io', () => ({
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
}));
// One flow belongs to no package, so the landing draws that entry (objectstack#34715).
vi.mock('./packageSurfaces', async (importOriginal) => {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ vi.mock('./packages-io', async (importOriginal) => {
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
// A read-only base's customization read (ADR-0146 D3) is not under test here:
// it stays pending, so no request leaves the file.
vi.mock('./packageCustomizations-io', () => ({
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
}));

vi.mock('./packageSurfaces', async (importOriginal) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ vi.mock('./packages-io', async (importOriginal) => {
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
// A read-only base's customization read (ADR-0146 D3) is not under test here:
// it stays pending, so no request leaves the file.
vi.mock('./packageCustomizations-io', () => ({
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
}));

// The package-less flow count the landing draws (objectstack#34715) is not under
Expand Down Expand Up @@ -127,6 +128,7 @@ describe('Studio landing → recent packages (objectui#11863)', () => {
await screen.findByText('Recently viewed');
expect(screen.getAllByRole('heading', { level: 2 }).map((h) => h.textContent)).toEqual([
'Installed apps',
'Customizations in this environment',
'Your own apps',
'Recently viewed',
'Outside any app',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ vi.mock('./packages-io', async (importOriginal) => {
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
// A read-only base's customization read (ADR-0146 D3) is not under test here:
// it stays pending, so no request leaves the file.
vi.mock('./packageCustomizations-io', () => ({
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
}));

// The package-less flow count the landing draws (objectstack#34715) is not under
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,25 @@ vi.mock('./packages-io', async (importOriginal) => {
};
});
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
vi.mock('./packageCustomizations-io', () => ({
fetchPackageCustomizationCounts: vi.fn(async (id: string) => counts.byId[id] ?? { customized: 0, switchedOff: 0 }),
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
// A served answer whose lists are as long as the counts asked for: `customized` view overrides, `switchedOff` flows.
fetchPackageCustomizations: vi.fn(async (id: string) => {
const { customized, switchedOff } = counts.byId[id] ?? { customized: 0, switchedOff: 0 };
return {
packageId: id,
overrides: Array.from({ length: customized }, (_, i) => ({ type: 'view', name: `view_${i}` })),
extensions: [],
switchedOff: Array.from({ length: switchedOff }, (_, i) => ({ type: 'flow', name: `flow_${i}` })),
contributions: [],
counts: { overrides: customized, extensions: 0, switchedOff, contributions: 0 },
};
}),
}));
// The panel's label read (objectstack#34714) is not under test here: rows keep their names.
vi.mock('./landingCustomizations-io', async (importOriginal) => ({
...(await importOriginal<typeof import('./landingCustomizations-io')>()),
loadCustomizationLabels: vi.fn(async () => ({})),
}));
vi.mock('./packageSurfaces', async (importOriginal) => {
const mod = await importOriginal<typeof import('./packageSurfaces')>();
Expand Down Expand Up @@ -102,7 +119,7 @@ describe('Studio landing: ordered by what the author came to do (objectstack#347
renderLanding();

await screen.findByText('HotCRM');
expect(headings()).toEqual(['Installed apps', 'Your own apps', 'Outside any app']);
expect(headings()).toEqual(['Installed apps', 'Customizations in this environment', 'Your own apps', 'Outside any app']);
const installed = screen.getByTestId('studio-landing-installed');
// DOM order: each installed card precedes the author's own card.
const own = screen.getByTestId('studio-landing-own');
Expand Down
45 changes: 40 additions & 5 deletions ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ import { t, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js';
import { PackageFormDialog } from '../metadata-admin/PackageFormDialog.js';
import { isMarketplaceEnabled } from '../../runtime-config.js';
import { fetchPackages, fetchListedPackageIds, duplicatePackage, isSpecPackageId, type PkgEntry } from './packages-io.js';
import { fetchPackageCustomizationCounts, type PackageCustomizationCounts } from './packageCustomizations-io.js';
import {
customizationCountsOf,
fetchPackageCustomizations,
type PackageCustomizationCounts,
type PackageCustomizations,
} from './packageCustomizations-io.js';
import { LandingCustomizationsPanel, type AppCustomizationRead } from './LandingCustomizationsPanel.js';
import { customizationPackageId, isCustomizationPackage } from '@objectstack/spec/kernel';
import { PackageIdInput } from './PackageIdInput.js';
import { studioOrgScopePath } from './studioScope.js';
Expand All @@ -61,7 +67,7 @@ const RECENT_PACKAGES_SHOWN = 3;
* read. No entry means the read has not answered: the line shows no number.
*/
type CustomizationLine =
| { kind: 'read'; counts: PackageCustomizationCounts }
| { kind: 'read'; counts: PackageCustomizationCounts; read: PackageCustomizations }
| { kind: 'failed'; message: string };

/** A package's Studio address on one pillar, the way `open` below spells it. */
Expand Down Expand Up @@ -170,9 +176,14 @@ export function BuilderLanding(): React.ReactElement {
if (!customizationTargetKey) return;
let cancelled = false;
for (const id of customizationTargetKey.split('\n')) {
fetchPackageCustomizationCounts(id).then(
(counts) => {
if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', counts } }));
// objectstack#34714 — the whole answer is kept: the card draws its two
// numbers off it and the "Customizations in this environment" panel its
// rows, so one read serves both and the panel's total is the cards' sum.
fetchPackageCustomizations(id).then(
(read) => {
if (!cancelled) {
setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', counts: customizationCountsOf(read), read } }));
}
},
(e: unknown) => {
const message = e instanceof Error ? e.message : String(e);
Expand All @@ -184,6 +195,21 @@ export function BuilderLanding(): React.ReactElement {
cancelled = true;
};
}, [customizationTargetKey]);
// objectstack#34714 — the panel's apps are the cards' bases, in card order;
// its reads are the same answers the cards draw.
const customizationApps = React.useMemo(
() => readonly.filter((p) => !isCustomizationPackage(p.id)).map((p) => ({ id: p.id, name: p.name })),
// eslint-disable-next-line react-hooks/exhaustive-deps
[customizationTargetKey, pkgs],
);
const customizationReads = React.useMemo(() => {
const out: Record<string, AppCustomizationRead> = {};
for (const [id, line] of Object.entries(customizationLines)) {
out[id] = line.kind === 'read' ? { kind: 'read', read: line.read } : line;
}
return out;
}, [customizationLines]);

// objectui#11553 — how many flows belong to no package: the same published
// and draft union the package-less scope lists (`loadPackageLessSurfaces`).
// The entry is drawn once the read says there is at least one; a failed read
Expand Down Expand Up @@ -416,6 +442,15 @@ export function BuilderLanding(): React.ReactElement {
</section>
)}

{/* objectstack#34714 — every change this deployment made to its
* installed apps, in one list, under the apps themselves. */}
<LandingCustomizationsPanel
apps={customizationApps}
reads={customizationReads}
locale={locale}
headingClass={headingClass}
/>

<h2 className={headingClass}>{t('engine.studio.landing.ownHeading', locale)}</h2>
<div data-testid="studio-landing-own" className="mb-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3">
{writable.map((p) => (
Expand Down
Loading
Loading