Skip to content

Commit e728d7a

Browse files
feat(app-shell): the marketplace install dialog and the local-install confirm show which existing objects a package changes, platform objects flagged and acknowledged (#33017)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoBAnEyxhTeomXorDRe5XRUC)_ Fixes #31542 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:应用市场的托管安装对话框和本地安装确认框,现在会列出软件包要修改的已有对象(字段、显示补丁、校验规则、索引、标签),平台对象(`sys_*`)排在最前并醒目标出;只要涉及平台对象,必须勾选确认才能安装。 - 为什么改:之前管理员同意安装时完全看不到软件包会改哪些已有对象,而扩展 `sys_user`、`sys_session` 这类平台对象可能影响登录和用户资料。 - 风险与回滚:只改安装前的展示和一个确认勾选,安装请求本身不变;目录不给出该信息时退回读取已读的清单,读不到就明说"无法读取"。回滚即 revert 本 PR。 - 先看:`ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx`(`objectExtensions` 的取值顺序和安装按钮的禁用条件)、`ObjectExtensionDisclosure.tsx`、`installPreview.ts` 的 `objectExtensionsIn`。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.installPreview-30325.test.tsx packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.installMode-12288.test.tsx`,预期全绿。 - 需要你做的:无,席位落地。 - 席位意见:席位(domain:ui#4)审过,并已写声明面的契约复审记录(6843621467,PASS)。新增文案键都在按需加载的 marketplace 命名空间里,11 种语言齐全,没有改动或删除已有键;只改安装前的展示和一个确认勾选,不碰服务端和 cloud 仓库。目录给 `null` 时明说"无法读取"而不是"没有修改"。已知取舍:清单还在读取或读不到时不拦安装,这与卡上"null 只需明说"的约定一致。CI 全绿后按队列落地。 ## What changes **The catalog field (`marketplaceApi.ts`).** `MarketplacePackageVersion.object_extensions` is typed as the card states it (`readonly MarketplaceObjectExtension[] | null`, absent on a catalog that does not serve it). `MarketplaceObjectExtension` carries `object`, `platform`, `fields`, `field_patches`, `validations`, `indexes` and `relabels`. **One disclosure component (`ObjectExtensionDisclosure.tsx`, new, beside `PluginDisclosure`).** It draws what each value says: - a list: each target object with the fields it adds or replaces, the fields whose display it patches, the rules it adds or replaces, how many indexes it adds, and whether it overrides the label. A platform target gets a "Platform object" badge, an amber edge and a warning line. The component draws the order it is given; the producer serves platform targets first. - `[]`: nothing is drawn. - `null`: an amber note that what the package changes could not be read. It is never drawn as "changes nothing". - `undefined`: a muted "reading" line. When any target is a platform object and the surface passes `onAcknowledgedChange`, the component draws an acknowledgment checkbox. `needsPlatformAcknowledgment()` is the one rule both surfaces use to hold Install. **Both surfaces (`MarketplacePackagePage.tsx`).** - The hosted install dialog draws the disclosure for every package, not only for code plugins. Its Install is disabled while a platform target is unacknowledged. - The local-install confirm (`install-preview-dialog`) draws it below the counts. Its Install (`install-preview-confirm`) is disabled under the same rule. - The acknowledgment holds for one opening. An effect clears it once both surfaces are closed, because the dialog's own Close button calls `setInstallOpen(false)` and bypasses `onOpenChange`. - Where the list comes from, in order: the catalog's `object_extensions` on `latest_version` (the version both doors install). On a catalog without the key, it comes from the manifest the page already reads once before install (`getServedPackageBody`, the read the card's step 3 names). That read exists and returns `data.manifest` of `GET /packages/:id/versions/latest/manifest`. If this runtime has no manifest read (no install-local route and no cloud base) or the manifest cannot be read, the value is `null`. **The manifest reading (`installPreview.ts`).** `InstallPreview` gains `objectExtensions`. It is read from every package body the preview already walks (top level with a nested `manifest:` lifted, and each `packages[]` body), and from each body's `metadata.objectExtensions`. That is the set of surfaces the card names. There is one entry per target object, platform targets first. `fields` and `fieldPatches` contribute their keys. A validation contributes its `name`, or `(unnamed)` when it has none. `indexes` contributes a count. `label`, `pluralLabel` and `description` set `relabels`. **i18n.** The new `marketplace.objectExtensions.*` keys go in the lazy `marketplace` namespace (`ui/packages/i18n/src/namespaces/marketplace/*`) in all ten hand-written locales. `zh-Hant` is generated by `gen:zh-hant`. The claim's file surface first named `src/locales/*`; the seat amended it (6839906996) after I measured that every existing `marketplace.install.preview.*` and `marketplace.disclosure.*` key lives in the namespace. The eager English pack and its gz ceiling are untouched. The index count is an i18next count family in every pack (`count-families-11445` requires one), with each language's CLDR slots. **Changeset:** `.changeset/31542-install-object-extensions.md`, `@object-ui/app-shell` patch and `@object-ui/i18n` patch, both declaration lines. Clause-② is `yes (widening)` because `./namespaces/marketplace` is an exported subpath of `@object-ui/i18n`, so its new keys are published. ## Tests Final head `11d28d49`. The pins are top-level `describe`s in the existing shared harness files. - `__tests__/installPreview-30325.test.ts`: a new `describe` pins the manifest reading. A business target and a `sys_user` target come back platform first, with each field, patch, named and unnamed rule, index count and relabel. `metadata` and `packages[]` bodies are read and merged per object. A body that extends nothing reads `[]`, never `null`. The three existing `toEqual` cases gain `objectExtensions: []`. - `__tests__/MarketplacePackagePage.installPreview-30325.test.tsx` (local confirm), five cases: - business plus platform: both listed with the platform one first and flagged. Install is disabled, a click posts nothing, and after the acknowledgment one install posts. - `[]`: no section, and Install is enabled. - `null`: "could not read", and Install is enabled. - CONTROL: a catalog without the key reads the served manifest, and the same rule holds Install. - CONTROL: a catalog without the key plus an unreadable manifest gives "could not read". - `__tests__/MarketplacePackagePage.installMode-12288.test.tsx` (hosted dialog, metadata package with no `contains_code`), six cases: business plus platform; closing the dialog drops the acknowledgment; business only (not held); `[]`; `null`; CONTROL catalog without the key. The harness `Wire` gains `catalogVersion`, merged into `latest_version`. - Runs (all under `scripts/pm/os-verify-lock.sh`): - the three files: 72/72. - `pnpm --dir ui exec vitest run packages/app-shell/src/console/marketplace/ packages/i18n/` after the merge of `origin/main` and a fresh `@objectstack/spec` build: Test Files 160/160, Tests 2465 passed, 13 skipped. - `@object-ui/app-shell` and `@object-ui/i18n` `type-check` (src and test programs) after a full build of `@object-ui/app-shell^...`: exit 0. - eslint `--no-inline-config` over the changed ui files: 0 errors. The warnings are existing `no-explicit-any` hits in the touched files. <details><summary>Ablation: drop the platform-acknowledgment requirement</summary> `node scripts/ablation-replace.mjs` replaced `const extensionsUnacknowledged = needsPlatformAcknowledgment(objectExtensions) && !extensionsAcknowledged;` with `const extensionsUnacknowledged = false; /* ABLATION-31542 */` in `MarketplacePackagePage.tsx`. It reported anchor 1 → 0, marker 0 → 1, blob `adcf60f3358e` → `56992a90d3e9`. The two page harness files then went red: Tests 5 failed / 58 passed. The red pins were both "Install waits for the acknowledgment" cases, both CONTROL manifest cases, and "closing the dialog drops the acknowledgment". The tool restored the file: blob after restore `adcf60f3358e` equals the HEAD blob, and `git diff HEAD` is empty. The test subject is imported from source (`../MarketplacePackagePage`), so no dist was involved. </details> ## Acceptance notes - **Reading state does not hold Install.** While the manifest read is in flight on a catalog without the key, the dialog shows "reading" and Install is not held. Only a known platform target holds it, and `null` does not either. The card asks for the acknowledgment when a target is a platform object. Holding on "unknown" would block every install on a runtime with no manifest read. - **Merging per object in the fallback is my reading.** I could not read cloud's `package-object-extensions.ts` from this container. If the producer lists two extensions of one object separately, the catalog path draws them as served. Only the fallback merges. - **The code-consent checkbox keeps a pre-existing leak.** The dialog's Close button bypasses `onOpenChange`, so the existing code acknowledgment (`acknowledged`) and `installResult` survive a Close and reopen. I fixed it for the new acknowledgment only. The existing one is reported in the dev report, not changed here. - **Docs: deviation.** `ui/AGENTS.md` #2 (docs-driven) is not done in this PR: the claim's file surface does not include `content/docs/frontend/` or a README. - **Assignees: deviation.** The dispatch order asked for `pr_create` without assignees, so the PR has none. `.claude/agents/os-dev.md` rule 2 has the create carry the claim's `Account:`. The conflict is reported to the seat. <details><summary>Derived gates (dispatch-gates --commands, final head)</summary> All 39 derived families exit 0. `dispatch-gates --ran` reconciles them: 39 derived, 39 run, 0 NOT-MEASURED, and the zero is derived from the recorded exit codes. Thirty-eight ran on `11d28d49`. `pnpm --dir ui exec vitest run scripts/` ran on `c4ec26ca`, the pre-merge parent: Test Files 171 passed / 2 skipped, Tests 5062 passed / 2 skipped. The merge of `origin/main` brought in no file of this diff. ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:merge-driver :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:role-word :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibxGdEFi5dqU21THfm1)_ <!-- signed: domain:ui#4 · os-tesla · session_01L9qibvZYR36KAJUv44oXZw --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 994c7d6 commit e728d7a

19 files changed

Lines changed: 697 additions & 14 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(app-shell): the marketplace install dialog and the local-install confirm show which existing objects a package changes, platform objects flagged and acknowledged
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
- **`@object-ui/app-shell`:** a new `ObjectExtensionDisclosure` draws the catalog's `object_extensions` for the version being installed: each existing object the package extends, with the fields it adds or replaces, the fields whose display it patches, the validation rules it adds or replaces, how many indexes it adds and whether it overrides the object's label. A platform (`sys_*`) object is flagged and listed first. It is drawn in the hosted install dialog for every package (not only for a package that contains code) and in the local-install confirm, and when any target is a platform object the install waits for an acknowledgment checkbox. `[]` draws nothing; `null` says what the package changes could not be read, never that it changes nothing. On a catalog that does not serve the key yet, the same list is read from the manifest the page already reads before the install (`InstallPreview.objectExtensions`).
12+
- **`@object-ui/i18n`:** the lazy `marketplace` namespace (`@object-ui/i18n/namespaces/marketplace`) gains the `marketplace.objectExtensions.*` keys in every locale; `zh-Hant` is generated from `zh-Hans`. No key changes or leaves.

‎ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { useAdapter, useHasNotificationProvider } from '@object-ui/react';
6262
import { PackageIcon } from './PackageIcon.js';
6363
import { MarkdownText } from './MarkdownText.js';
6464
import { PluginDisclosure } from './PluginDisclosure.js';
65+
import { ObjectExtensionDisclosure, needsPlatformAcknowledgment, type ObjectExtensionsReading } from './ObjectExtensionDisclosure.js';
6566
import { MarketplaceAccessDenied } from './MarketplaceAccessDenied.js';
6667
import { MarketplaceResolving } from './MarketplaceResolving.js';
6768
import { MarketplaceDisabled } from './MarketplaceDisabled.js';
@@ -275,6 +276,9 @@ function MarketplacePackagePageBody() {
275276
// PD4: a code-bearing package requires explicit acknowledgement of its
276277
// requested permissions before the install button is enabled.
277278
const [acknowledged, setAcknowledged] = useState(false);
279+
// objectstack#31542 — a package that changes a platform (`sys_*`) object
280+
// waits for this acknowledgment, in the install dialog and the local confirm.
281+
const [extensionsAcknowledged, setExtensionsAcknowledged] = useState(false);
278282
const [installing, setInstalling] = useState(false);
279283
// objectstack#32040 — the hosted unmanaged install's target namespace: the
280284
// control plane's default as read for one package (`null` while the read is
@@ -345,6 +349,12 @@ function MarketplacePackagePageBody() {
345349
// = still reading. The confirm in front of a local Install draws it.
346350
const [previewRead, setPreviewRead] = useState<{ packageId: string; preview: InstallPreview | null } | null>(null);
347351
const [confirmLocalOpen, setConfirmLocalOpen] = useState(false);
352+
// objectstack#31542 — the platform-object acknowledgment is given for one
353+
// opening: however a surface closes (its own Close button included, which
354+
// bypasses `onOpenChange`), the next opening asks again.
355+
useEffect(() => {
356+
if (!installOpen && !confirmLocalOpen) setExtensionsAcknowledged(false);
357+
}, [installOpen, confirmLocalOpen]);
348358
// `undefined` until read, when the manifest declares none, or when it could
349359
// not be read: then no choice is drawn and no mode is sent, so the door's own
350360
// default and answer decide.
@@ -1474,6 +1484,19 @@ function MarketplacePackagePageBody() {
14741484
: undefined;
14751485
const installModeReasonId = 'install-mode-required-reason';
14761486
const localPreviewRead = previewRead && previewRead.packageId === packageId ? previewRead : null;
1487+
// objectstack#31542 — the existing objects the install changes: the catalog's
1488+
// `object_extensions` for the version installed (`latest`); on a catalog that
1489+
// does not serve the key, the same reading of the manifest read above. No
1490+
// manifest read on this runtime, or none readable: `null`, "could not read".
1491+
const catalogExtensions = pkg.latest_version?.object_extensions;
1492+
const objectExtensions: ObjectExtensionsReading = catalogExtensions !== undefined
1493+
? catalogExtensions
1494+
: !getRuntimeConfig().features.installLocal && !getCloudBase()
1495+
? null
1496+
: !localPreviewRead
1497+
? undefined
1498+
: localPreviewRead.preview?.objectExtensions ?? null;
1499+
const extensionsUnacknowledged = needsPlatformAcknowledgment(objectExtensions) && !extensionsAcknowledged;
14771500
const primaryAction = supportsLocal
14781501
? {
14791502
label: installingLocal
@@ -1841,10 +1864,17 @@ function MarketplacePackagePageBody() {
18411864
)}
18421865
</div>
18431866
)}
1867+
<ObjectExtensionDisclosure
1868+
extensions={objectExtensions}
1869+
acknowledged={extensionsAcknowledged}
1870+
onAcknowledgedChange={setExtensionsAcknowledged}
1871+
idPrefix="install-preview-object-extensions"
1872+
/>
18441873
<AlertDialogFooter>
18451874
<AlertDialogCancel>{t('common.cancel')}</AlertDialogCancel>
18461875
<AlertDialogAction
18471876
data-testid="install-preview-confirm"
1877+
disabled={extensionsUnacknowledged}
18481878
onClick={() => { void runInstallLocal(); }}
18491879
>
18501880
{localInstall ? t('marketplace.action.reinstall') : t('marketplace.action.install')}
@@ -2040,6 +2070,17 @@ function MarketplacePackagePageBody() {
20402070
</div>
20412071
)}
20422072

2073+
{/* objectstack#31542 — every package, not only code: the existing
2074+
objects it changes, platform objects flagged and acknowledged. */}
2075+
{!envsError && (
2076+
<ObjectExtensionDisclosure
2077+
extensions={objectExtensions}
2078+
acknowledged={extensionsAcknowledged}
2079+
onAcknowledgedChange={setExtensionsAcknowledged}
2080+
idPrefix="install-object-extensions"
2081+
/>
2082+
)}
2083+
20432084
{containsCode && !envsError && (
20442085
<div className="space-y-3">
20452086
<PluginDisclosure version={pkg.latest_version} />
@@ -2091,7 +2132,7 @@ function MarketplacePackagePageBody() {
20912132
{!envsError && (
20922133
<Button
20932134
onClick={doInstall}
2094-
disabled={!selectedEnv || installing || installResult?.ok === true || deploy !== null || (containsCode && !acknowledged) || namespaceLoading}
2135+
disabled={!selectedEnv || installing || installResult?.ok === true || deploy !== null || (containsCode && !acknowledged) || extensionsUnacknowledged || namespaceLoading}
20952136
>
20962137
{dialogUpdate
20972138
? (installing ? t('marketplace.action.updating') : t('marketplace.action.updateTo', { defaultValue: 'Update' }))
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+
* Which existing objects a package changes, shown before the install
5+
* (objectstack#31542): beside `PluginDisclosure`, in the hosted install dialog
6+
* for every package and in the local-install confirm.
7+
*
8+
* The list is the catalog's `object_extensions` for the version installed, or,
9+
* on a catalog that does not serve the key, the same reading of the served
10+
* manifest (`InstallPreview.objectExtensions`). What each value says:
11+
*
12+
* - a list: each target with the fields, field display patches, validation
13+
* rules and indexes it adds, and whether it overrides the object's label.
14+
* A platform (`sys_*`) target is flagged; platform targets come first.
15+
* - `[]`: the package changes no existing object, and nothing is drawn.
16+
* - `null`: what it changes could not be read. ⛔ Never drawn as "changes
17+
* nothing": an unread package may change platform objects too.
18+
* - `undefined`: still reading.
19+
*
20+
* When any target is a platform object and the surface passes
21+
* `onAcknowledgedChange`, an acknowledgment checkbox is drawn; the surface
22+
* holds its install until it is checked (`needsPlatformAcknowledgment`).
23+
*/
24+
25+
import { Badge, Checkbox, Label } from '@object-ui/components';
26+
import { AlertTriangle, Layers } from 'lucide-react';
27+
import { useObjectTranslation } from '@object-ui/i18n';
28+
import type { MarketplaceObjectExtension } from './marketplaceApi.js';
29+
30+
/** The extension list a surface draws: a list, `null` (could not read), or `undefined` (reading). */
31+
export type ObjectExtensionsReading = readonly MarketplaceObjectExtension[] | null | undefined;
32+
33+
/** True when the install changes a platform object, so it waits for the acknowledgment. */
34+
export function needsPlatformAcknowledgment(extensions: ObjectExtensionsReading): boolean {
35+
return !!extensions && extensions.some((e) => e.platform);
36+
}
37+
38+
function Names({ label, items }: { label: string; items: readonly string[] }) {
39+
if (items.length === 0) return null;
40+
return (
41+
<div>
42+
<span className="text-muted-foreground">{label}: </span>
43+
{items.map((it, i) => (
44+
<span key={it}>
45+
{i > 0 ? ' ' : null}
46+
<code className="font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all">{it}</code>
47+
</span>
48+
))}
49+
</div>
50+
);
51+
}
52+
53+
export function ObjectExtensionDisclosure({
54+
extensions,
55+
acknowledged = false,
56+
onAcknowledgedChange,
57+
idPrefix = 'object-extensions',
58+
}: {
59+
extensions: ObjectExtensionsReading;
60+
acknowledged?: boolean;
61+
onAcknowledgedChange?: (acknowledged: boolean) => void;
62+
/** Distinguishes the checkbox id when two surfaces could be mounted at once. */
63+
idPrefix?: string;
64+
}) {
65+
const { t } = useObjectTranslation();
66+
67+
if (extensions === undefined) {
68+
return (
69+
<p className="text-xs text-muted-foreground" data-testid="object-extensions-reading">
70+
{t('marketplace.objectExtensions.reading')}
71+
</p>
72+
);
73+
}
74+
if (extensions === null) {
75+
return (
76+
<div
77+
className="flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm"
78+
data-testid="object-extensions-unknown"
79+
>
80+
<AlertTriangle className="h-4 w-4 mt-0.5 shrink-0 text-amber-600" aria-hidden="true" />
81+
<span>{t('marketplace.objectExtensions.unknown')}</span>
82+
</div>
83+
);
84+
}
85+
if (extensions.length === 0) return null;
86+
87+
const platform = needsPlatformAcknowledgment(extensions);
88+
const ackId = `${idPrefix}-ack`;
89+
90+
return (
91+
<div
92+
className={`rounded-md border p-3 space-y-3 text-sm ${platform ? 'border-amber-500/40 bg-amber-500/5' : 'border-border'}`}
93+
data-testid="object-extensions"
94+
>
95+
<div className="flex items-center gap-2 font-medium">
96+
<Layers className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden="true" />
97+
{t('marketplace.objectExtensions.title')}
98+
</div>
99+
<p className="text-xs text-muted-foreground">{t('marketplace.objectExtensions.intro')}</p>
100+
{platform && (
101+
<p
102+
className="flex items-start gap-2 text-xs text-amber-700 dark:text-amber-400"
103+
data-testid="object-extensions-platform-warning"
104+
>
105+
<AlertTriangle className="h-3.5 w-3.5 mt-0.5 shrink-0" aria-hidden="true" />
106+
<span>{t('marketplace.objectExtensions.platformWarning')}</span>
107+
</p>
108+
)}
109+
<ul className="space-y-2">
110+
{extensions.map((ext) => (
111+
<li
112+
key={ext.object}
113+
data-testid="object-extension"
114+
data-object={ext.object}
115+
data-platform={ext.platform ? 'true' : 'false'}
116+
className={`space-y-1 rounded-sm border-l-2 pl-2 text-xs ${ext.platform ? 'border-amber-500' : 'border-muted'}`}
117+
>
118+
<div className="flex flex-wrap items-center gap-1.5">
119+
<code className="font-mono text-sm font-medium">{ext.object}</code>
120+
{ext.platform && (
121+
<Badge variant="outline" className="gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400">
122+
{t('marketplace.objectExtensions.platformBadge')}
123+
</Badge>
124+
)}
125+
</div>
126+
<Names label={t('marketplace.objectExtensions.fields')} items={ext.fields} />
127+
<Names label={t('marketplace.objectExtensions.fieldPatches')} items={ext.field_patches} />
128+
<Names label={t('marketplace.objectExtensions.validations')} items={ext.validations} />
129+
{ext.indexes > 0 && (
130+
<div className="text-muted-foreground">{t('marketplace.objectExtensions.indexes', { count: ext.indexes })}</div>
131+
)}
132+
{ext.relabels && <div className="text-muted-foreground">{t('marketplace.objectExtensions.relabels')}</div>}
133+
</li>
134+
))}
135+
</ul>
136+
{platform && onAcknowledgedChange && (
137+
<div className="flex items-start gap-2">
138+
<Checkbox
139+
id={ackId}
140+
checked={acknowledged}
141+
onCheckedChange={(c) => onAcknowledgedChange(c === true)}
142+
/>
143+
<Label htmlFor={ackId} className="text-sm font-normal cursor-pointer leading-snug">
144+
{t('marketplace.objectExtensions.acknowledge')}
145+
</Label>
146+
</div>
147+
)}
148+
</div>
149+
);
150+
}

‎ui/packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.installMode-12288.test.tsx‎

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ interface Wire {
128128
namespace?: { status: number; body: unknown };
129129
/** Holds the namespace answer until it settles, so the loading state is a reading, not a race. */
130130
namespaceGate?: Promise<void>;
131+
/** Merged into the catalog's `latest_version` (objectstack#31542 serves `object_extensions` there). */
132+
catalogVersion?: Record<string, unknown>;
131133
}
132134
let wire: Wire;
133135
let answered: string[] = [];
@@ -185,7 +187,8 @@ async function boot(installLocal = true, cloudUrl = '') {
185187
return answer(200, { success: true, data: { installed: false } });
186188
}
187189
if (path === '/api/v1/marketplace/packages/pkg_crm' && method === 'GET') {
188-
return answer(200, { success: true, data: CATALOG_PACKAGE });
190+
const latest = { ...CATALOG_PACKAGE.package.latest_version, ...wire.catalogVersion };
191+
return answer(200, { success: true, data: { ...CATALOG_PACKAGE, package: { ...CATALOG_PACKAGE.package, latest_version: latest } } });
189192
}
190193
return answer(404, { success: false, error: { code: 'NOT_FOUND', message: `no route ${method} ${path}` } });
191194
})();
@@ -797,3 +800,82 @@ describe('`installPackage()` and `getInstallNamespace()` on the hosted route (ob
797800
expect(urls).toEqual(['/api/v1/cloud-connection/install-namespace?package_id=pkg%2F1']);
798801
});
799802
});
803+
804+
describe('the hosted install dialog says which existing objects the install changes (objectstack#31542)', () => {
805+
// A metadata package (no `contains_code`): before this, the dialog drew no
806+
// disclosure for it at all.
807+
const installToCloud = () => screen.getByRole('button', { name: '«marketplace.action.installToCloud»' });
808+
const dialogInstall = (dialog: HTMLElement) => within(dialog).getByRole('button', { name: '«marketplace.action.install»' });
809+
const EXTENSIONS = [
810+
{ object: 'sys_user', platform: true, fields: ['name'], field_patches: [], validations: ['name_required'], indexes: 0, relabels: false },
811+
{ object: 'crm_account', platform: false, fields: ['ticket_count'], field_patches: [], validations: [], indexes: 0, relabels: false },
812+
];
813+
814+
async function openHostedDialog(catalogVersion: Record<string, unknown>) {
815+
wire.catalogVersion = catalogVersion;
816+
await boot(false, HOSTED_CLOUD);
817+
render(<MarketplacePackagePage />);
818+
await screen.findByRole('button', { name: '«marketplace.action.installToCloud»' });
819+
await waitFor(() => expect(answered).toContain(`GET ${MANIFEST_PATH}`));
820+
await act(async () => {});
821+
fireEvent.click(installToCloud());
822+
return screen.findByRole('dialog');
823+
}
824+
825+
it('a business and a platform object: both listed, the platform one first and flagged, and Install waits for the acknowledgment', async () => {
826+
const dialog = await openHostedDialog({ object_extensions: EXTENSIONS });
827+
828+
expect(within(dialog).getAllByTestId('object-extension').map((el) => `${el.getAttribute('data-object')}:${el.getAttribute('data-platform')}`))
829+
.toEqual(['sys_user:true', 'crm_account:false']);
830+
expect(within(dialog).getByTestId('object-extensions-platform-warning')).toBeInTheDocument();
831+
expect(dialogInstall(dialog)).toBeDisabled();
832+
833+
fireEvent.click(within(dialog).getByRole('checkbox', { name: '«marketplace.objectExtensions.acknowledge»' }));
834+
await waitFor(() => expect(dialogInstall(dialog)).toBeEnabled());
835+
fireEvent.click(dialogInstall(dialog));
836+
await waitFor(() => expect(cloudPosts).toHaveLength(1));
837+
});
838+
839+
it('closing the dialog drops the acknowledgment', async () => {
840+
const dialog = await openHostedDialog({ object_extensions: EXTENSIONS });
841+
fireEvent.click(within(dialog).getByRole('checkbox', { name: '«marketplace.objectExtensions.acknowledge»' }));
842+
await waitFor(() => expect(dialogInstall(dialog)).toBeEnabled());
843+
fireEvent.click(within(dialog).getByRole('button', { name: '«marketplace.action.close»' }));
844+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
845+
846+
fireEvent.click(installToCloud());
847+
const reopened = await screen.findByRole('dialog');
848+
expect(dialogInstall(reopened)).toBeDisabled();
849+
});
850+
851+
it('a business object only: listed, no platform flag, and Install is not held', async () => {
852+
const dialog = await openHostedDialog({ object_extensions: [EXTENSIONS[1]] });
853+
854+
expect(within(dialog).getAllByTestId('object-extension')).toHaveLength(1);
855+
expect(within(dialog).queryByTestId('object-extensions-platform-warning')).not.toBeInTheDocument();
856+
expect(dialogInstall(dialog)).toBeEnabled();
857+
});
858+
859+
it('`[]`: no extension section', async () => {
860+
const dialog = await openHostedDialog({ object_extensions: [] });
861+
862+
expect(within(dialog).queryByTestId('object-extensions')).not.toBeInTheDocument();
863+
expect(within(dialog).queryByTestId('object-extensions-unknown')).not.toBeInTheDocument();
864+
expect(dialogInstall(dialog)).toBeEnabled();
865+
});
866+
867+
it('`null`: "could not read", never "changes nothing"', async () => {
868+
const dialog = await openHostedDialog({ object_extensions: null });
869+
870+
expect(within(dialog).getByTestId('object-extensions-unknown')).toHaveTextContent('«marketplace.objectExtensions.unknown»');
871+
expect(dialogInstall(dialog)).toBeEnabled();
872+
});
873+
874+
it('CONTROL: a catalog without the key reads the served manifest', async () => {
875+
serveManifest(flatBody({ objectExtensions: [{ extend: 'sys_user', fields: { name: {} } }] }));
876+
const dialog = await openHostedDialog({});
877+
878+
expect(within(dialog).getAllByTestId('object-extension').map((el) => el.getAttribute('data-object'))).toEqual(['sys_user']);
879+
expect(dialogInstall(dialog)).toBeDisabled();
880+
});
881+
});

0 commit comments

Comments
 (0)