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
11 changes: 11 additions & 0 deletions .changeset/39472-reinstall-up-to-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@object-ui/app-shell": patch
"@object-ui/i18n": patch
---

Clause-②: no
Metadata-protocol: none

The marketplace package page no longer offers Reinstall as the main button when this runtime already holds the latest version. It says "Up to date" (「已是最新版本」) instead, and Reinstall is in the "More install options" menu. A package that did not load, or is on an older version, keeps Reinstall as its button.

The confirm in front of a reinstall or an update now says that this environment's customizations of the package are kept: reinstalling replaces only the package's own metadata, and the changes saved in its customization package stay as they are.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* (objectui#12288, ADR-0131 D6).
*/

import { useEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import {
Button,
Expand Down Expand Up @@ -38,6 +38,7 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
RadioGroup,
RadioGroupItem,
Tooltip,
Expand Down Expand Up @@ -68,7 +69,7 @@ import { MarketplaceResolving } from './MarketplaceResolving.js';
import { MarketplaceDisabled } from './MarketplaceDisabled.js';
import { MarketplaceNotLoadedReason } from './MarketplaceRowActions.js';
import { localizePackage } from './usePackageL10n.js';
import { isNewerVersion } from './versionPrecedence.js';
import { compareVersionPrecedence, isNewerVersion } from './versionPrecedence.js';
import { updateTarget } from './installState.js';
import { UpdateAvailableBadge } from './UpdateAvailableBadge.js';
import {
Expand Down Expand Up @@ -1209,14 +1210,17 @@ function MarketplacePackagePageBody() {
<MarketplaceNotLoadedReason marker={localInstall.notLoaded} />
</p>
);
const localMenu = localInstall && (
// `leading`: an item drawn first, the catalog view's Reinstall of a current
// version (objectstack#39472); the marketplace-off view passes none.
const localMenuWith = (leading: ReactNode = null) => localInstall && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="lg" className="px-2.5" aria-label={t('marketplace.detail.moreOptions')}>
<MoreHorizontal className="h-4 w-4" aria-hidden="true" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-56">
{leading}
{/* objectui#11645 — re-seed and purge write and read the package's own
objects, which a package this runtime refused to load at startup
(`notLoaded`) never registered, so neither is offered for it. The
Expand Down Expand Up @@ -1508,7 +1512,7 @@ function MarketplacePackagePageBody() {
{localNotLoadedReason}
</div>
<div className="flex items-center gap-2 shrink-0 self-start">
{localMenu}
{localMenuWith()}
</div>
</div>
)}
Expand Down Expand Up @@ -1608,6 +1612,13 @@ function MarketplacePackagePageBody() {
// The `'installed'` sentinel (version unknown) has no precedence, so it never
// claims an update either.
const cloudUpdateAvailable = updateTarget(cloudInstalledVersion, latestVersion) !== null;
// objectstack#39472 — a loaded local install at the latest version (or one
// of higher precedence) has nothing to install: the page says so as a
// status, and Reinstall moves into the local menu. A not-loaded install, an
// older one and a version that does not compare keep Reinstall as the
// page's button: there it is the repair or the update.
const localUpToDate = !!localInstall && !localInstall.notLoaded && !!latestVersion
&& (compareVersionPrecedence(localInstall.version, latestVersion) ?? -1) >= 0;

// ADR-0131 D6 — where the package permits more than one mode, the install
// waits for the operator's pick.
Expand Down Expand Up @@ -1794,6 +1805,27 @@ function MarketplacePackagePageBody() {
</Tooltip>
</TooltipProvider>
) : primaryButton;
const upToDateStatus = (
<span
role="status"
data-testid="marketplace-up-to-date"
className="inline-flex h-11 items-center gap-1.5 rounded-md border px-4 text-sm font-medium text-muted-foreground"
>
{installingLocal
? <Loader2 className="h-4 w-4 animate-spin" aria-hidden="true" />
: <CheckCircle2 className="h-4 w-4 text-green-600" aria-hidden="true" />}
{installingLocal ? t('marketplace.action.working') : t('marketplace.detail.upToDate')}
</span>
);
const reinstallMenuItem = (
<>
<DropdownMenuItem onSelect={doInstallLocal} disabled={primaryDisabled} data-testid="marketplace-menu-reinstall">
<Download className="h-4 w-4 mr-2" aria-hidden="true" />
{t('marketplace.action.reinstall')}
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
);

return (
<div className="mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6">
Expand Down Expand Up @@ -1870,8 +1902,8 @@ function MarketplacePackagePageBody() {
{installModeChoice}
</div>
<div className="flex items-center gap-2 shrink-0 self-start">
{primaryControl}
{localMenu}
{localUpToDate ? upToDateStatus : primaryControl}
{localMenuWith(localUpToDate ? reinstallMenuItem : null)}
{/* Reseed / purge still POST cross-origin to the control plane, which
the browser blocks on a tenant subdomain. Only offer them when the
runtime IS the cloud (same-origin). On tenants the install state is
Expand Down Expand Up @@ -2033,6 +2065,15 @@ function MarketplacePackagePageBody() {
)}
</div>
)}
{/* objectstack#39472 — an install over this package (a reinstall or an
update) registers the package again and leaves its paired
customization package's items as they are: said before the click.
An unmanaged copy is another install, and says nothing here. */}
{localInstall && requestedInstallMode !== 'unmanaged' && (
<p className="text-sm text-muted-foreground" data-testid="install-preview-keeps-customizations">
{t('marketplace.install.preview.keepsCustomizations', { name: loc.displayName })}
</p>
)}
<ObjectExtensionDisclosure
extensions={objectExtensions}
acknowledged={extensionsAcknowledged}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const answer = (status: number, body: unknown) => ({

let calls: string[] = [];

async function boot(manifest: { status: number; body?: unknown }, catalog: unknown = CATALOG_PACKAGE) {
async function boot(manifest: { status: number; body?: unknown }, catalog: unknown = CATALOG_PACKAGE, installed: unknown[] = []) {
calls = [];
resetRuntimeConfigForTesting();
vi.stubGlobal('fetch', vi.fn(async (input: unknown, init?: { method?: string }) => {
Expand All @@ -99,7 +99,7 @@ async function boot(manifest: { status: number; body?: unknown }, catalog: unkno
branding: { productName: 'ObjectOS', productShortName: 'ObjectOS' },
});
}
if (path === INSTALL_PATH && method === 'GET') return answer(200, { success: true, data: { items: [], total: 0 } });
if (path === INSTALL_PATH && method === 'GET') return answer(200, { success: true, data: { items: installed, total: installed.length } });
if (path === INSTALL_PATH && method === 'POST') return answer(200, { success: true, data: MANAGED });
if (path === MANIFEST_PATH) {
// `status: 0`: the manifest read never answers, so the page stays "reading".
Expand Down Expand Up @@ -357,3 +357,96 @@ describe('the local confirm says which existing objects the install changes (obj
expect(within(dialog).getByTestId('install-preview-confirm')).toBeEnabled();
});
});

/** The install-local listing's entry for this package, at `version`. */
const installedAt = (version: string, extra: Record<string, unknown> = {}) => ({
packageId: PKG, versionId: `ver_${version}`, manifestId: PKG, version,
installedAt: '2026-11-05T00:00:00Z', withSampleData: false, ...extra,
});
const NOT_LOADED = { notLoaded: { code: 'OS_PROTOCOL_INCOMPATIBLE', requiredRange: '^99' } };

/** Open the local menu and pick its Reinstall. */
async function reinstallFromMenu() {
const trigger = await screen.findByRole('button', { name: '«marketplace.detail.moreOptions»' });
fireEvent.keyDown(trigger, { key: 'Enter' });
fireEvent.click(await screen.findByRole('menuitem', { name: '«marketplace.action.reinstall»' }));
return screen.findByTestId('install-preview-dialog');
}

describe('an installed, current version reads as up to date, with Reinstall in the local menu (objectstack#39472)', () => {
it('installed at the latest version: the status says so, no Install or Reinstall button, and the menu\'s Reinstall opens the confirm', async () => {
await boot({ status: 200, body: BUNDLE }, CATALOG_PACKAGE, [installedAt('6.0.0')]);
render(<MarketplacePackagePage />);

expect(await screen.findByTestId('marketplace-up-to-date')).toHaveTextContent('«marketplace.detail.upToDate»');
expect(screen.queryByRole('button', { name: '«marketplace.action.reinstall»' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '«marketplace.action.install»' })).not.toBeInTheDocument();

await waitFor(() => expect(calls).toContain(`GET ${MANIFEST_PATH}`));
await act(async () => {});
const dialog = await reinstallFromMenu();
expect(within(dialog).getByText('«marketplace.install.preview.reinstallTitle|name=Acme CRM»')).toBeInTheDocument();
expect(posts()).toHaveLength(0);
fireEvent.click(within(dialog).getByTestId('install-preview-confirm'));
await waitFor(() => expect(posts()).toHaveLength(1));
});

it('CONTROL: installed at an older version, Reinstall stays the page\'s button and no up-to-date status is drawn', async () => {
await boot({ status: 200, body: BUNDLE }, CATALOG_PACKAGE, [installedAt('5.0.0')]);
render(<MarketplacePackagePage />);

expect(await screen.findByRole('button', { name: '«marketplace.action.reinstall»' })).toBeInTheDocument();
expect(screen.queryByTestId('marketplace-up-to-date')).not.toBeInTheDocument();
});

it('CONTROL: installed at the latest version but not loaded, Reinstall stays the page\'s button (it is the repair)', async () => {
await boot({ status: 200, body: BUNDLE }, CATALOG_PACKAGE, [installedAt('6.0.0', NOT_LOADED)]);
render(<MarketplacePackagePage />);

expect(await screen.findByRole('button', { name: '«marketplace.action.reinstall»' })).toBeInTheDocument();
expect(screen.queryByTestId('marketplace-up-to-date')).not.toBeInTheDocument();
});
});

describe('the reinstall confirm says this environment\'s customizations are kept (objectstack#39472)', () => {
const KEPT = '«marketplace.install.preview.keepsCustomizations|name=Acme CRM»';

it('a reinstall of the current version says the customizations are kept', async () => {
await boot({ status: 200, body: BUNDLE }, CATALOG_PACKAGE, [installedAt('6.0.0')]);
render(<MarketplacePackagePage />);
await waitFor(() => expect(calls).toContain(`GET ${MANIFEST_PATH}`));
await act(async () => {});
const dialog = await reinstallFromMenu();

expect(within(dialog).getByTestId('install-preview-keeps-customizations')).toHaveTextContent(KEPT);
});

it('an install over an older version says it too', async () => {
await boot({ status: 200, body: BUNDLE }, CATALOG_PACKAGE, [installedAt('5.0.0')]);
render(<MarketplacePackagePage />);
await waitFor(() => expect(calls).toContain(`GET ${MANIFEST_PATH}`));
await act(async () => {});
fireEvent.click(await screen.findByRole('button', { name: '«marketplace.action.reinstall»' }));
const dialog = await screen.findByTestId('install-preview-dialog');

expect(within(dialog).getByTestId('install-preview-keeps-customizations')).toHaveTextContent(KEPT);
});

it('CONTROL: a first install has no customizations to keep, and says nothing about them', async () => {
await boot({ status: 200, body: BUNDLE });
const dialog = await openConfirm();

expect(within(dialog).queryByTestId('install-preview-keeps-customizations')).not.toBeInTheDocument();
});

it('CONTROL: an unmanaged copy over an install is not the reinstall that was measured, and says nothing about them', async () => {
await boot({ status: 200, body: { ...BUNDLE, manifest: { ...BUNDLE.manifest, installModes: ['unmanaged'] } } }, CATALOG_PACKAGE, [installedAt('5.0.0')]);
render(<MarketplacePackagePage />);
await waitFor(() => expect(calls).toContain(`GET ${MANIFEST_PATH}`));
await act(async () => {});
fireEvent.click(await screen.findByRole('button', { name: '«marketplace.action.reinstall»' }));
const dialog = await screen.findByTestId('install-preview-dialog');

expect(within(dialog).queryByTestId('install-preview-keeps-customizations')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,15 @@ function Shell({ page }: { page: boolean }) {

async function install(withProvider = false) {
const view = render(withProvider ? <Shell page /> : <MarketplacePackagePage />);
const button = await screen.findByRole('button', { name: /«marketplace\.action\.(install|reinstall)»/ });
const control = await screen.findByText(/«marketplace\.(action\.install|detail\.upToDate)»/);
await act(async () => {});
fireEvent.click(button);
if (control.closest('[data-testid="marketplace-up-to-date"]')) {
// objectstack#39472 — an install at the latest version offers Reinstall from the local menu.
fireEvent.keyDown(screen.getByRole('button', { name: '«marketplace.detail.moreOptions»' }), { key: 'Enter' });
fireEvent.click(await screen.findByRole('menuitem', { name: '«marketplace.action.reinstall»' }));
} else {
fireEvent.click(screen.getByRole('button', { name: '«marketplace.action.install»' }));
}
// objectstack#30325 — Install opens the confirm; its Install installs.
fireEvent.click(await screen.findByTestId('install-preview-confirm'));
return view;
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const ar = {
detail: {
homepage: "الصفحة الرئيسية",
installedV: "مثبت · v{{version}}",
upToDate: "محدَّث إلى أحدث إصدار",
about: "حول",
noReadme: "لا يوجد readme متاح.",
versions: "الإصدارات",
Expand Down Expand Up @@ -248,6 +249,7 @@ const ar = {
preview: {
title: "تثبيت {{name}}؟",
reinstallTitle: "إعادة تثبيت {{name}}؟",
keepsCustomizations: "يتم الاحتفاظ بتخصيصات {{name}} في هذه البيئة: تستبدل إعادة التثبيت بيانات الحزمة الوصفية الخاصة بها فقط، وتبقى التغييرات المحفوظة في حزمة التخصيص الخاصة بها كما هي.",
intro: "يضيف التثبيت ما يلي إلى وقت التشغيل هذا:",
reading: "جارٍ قراءة ما تضيفه هذه الحزمة…",
unreadable: "تعذّرت قراءة ما تضيفه هذه الحزمة قبل التثبيت. ستذكر نتيجة التثبيت ما تم تحميله.",
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const de = {
detail: {
homepage: "Startseite",
installedV: "Installiert · v{{version}}",
upToDate: "Aktuell",
about: "Über",
noReadme: "Kein Readme vorhanden.",
versions: "Versionen",
Expand Down Expand Up @@ -220,6 +221,7 @@ const de = {
preview: {
title: "{{name}} installieren?",
reinstallTitle: "{{name}} neu installieren?",
keepsCustomizations: "Die Anpassungen dieser Umgebung an {{name}} bleiben erhalten: Die Neuinstallation ersetzt nur die eigenen Metadaten des Pakets, die in seinem Anpassungspaket gespeicherten Änderungen bleiben unverändert.",
intro: "Die Installation fügt diesem Laufzeitsystem Folgendes hinzu:",
reading: "Es wird gelesen, was dieses Paket hinzufügt…",
unreadable: "Was dieses Paket hinzufügt, konnte vor der Installation nicht gelesen werden. Das Installationsergebnis nennt, was geladen wurde.",
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const en = {
detail: {
homepage: 'Homepage',
installedV: 'Installed · v{{version}}',
upToDate: 'Up to date',
about: 'About',
noReadme: 'No readme provided.',
versions: 'Versions',
Expand Down Expand Up @@ -192,6 +193,7 @@ const en = {
preview: {
title: "Install {{name}}?",
reinstallTitle: "Reinstall {{name}}?",
keepsCustomizations: "This environment's customizations of {{name}} are kept: reinstalling replaces only the package's own metadata, and the changes saved in its customization package stay as they are.",
intro: "Installing adds the following to this runtime:",
reading: "Reading what this package adds…",
unreadable: "What this package adds could not be read before install. The install result says what it loaded.",
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const es = {
detail: {
homepage: "Página de inicio",
installedV: "Instalado · v{{version}}",
upToDate: "Actualizado",
about: "Acerca de",
noReadme: "Sin readme disponible.",
versions: "Versiones",
Expand Down Expand Up @@ -227,6 +228,7 @@ const es = {
preview: {
title: "¿Instalar {{name}}?",
reinstallTitle: "¿Reinstalar {{name}}?",
keepsCustomizations: "Las personalizaciones de {{name}} en este entorno se conservan: reinstalar solo reemplaza los metadatos propios del paquete, y los cambios guardados en su paquete de personalización se mantienen tal como están.",
intro: "La instalación añade lo siguiente a este runtime:",
reading: "Leyendo lo que añade este paquete…",
unreadable: "No se pudo leer antes de instalar lo que añade este paquete. El resultado de la instalación indica lo que se cargó.",
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const fr = {
detail: {
homepage: "Page d'accueil",
installedV: "Installé · v{{version}}",
upToDate: "À jour",
about: "À propos",
noReadme: "Aucun readme disponible.",
versions: "Versions",
Expand Down Expand Up @@ -227,6 +228,7 @@ const fr = {
preview: {
title: "Installer {{name}} ?",
reinstallTitle: "Réinstaller {{name}} ?",
keepsCustomizations: "Les personnalisations de {{name}} dans cet environnement sont conservées : la réinstallation remplace uniquement les métadonnées propres au paquet, et les modifications enregistrées dans son paquet de personnalisation restent inchangées.",
intro: "L'installation ajoute ce qui suit à ce runtime :",
reading: "Lecture de ce que ce paquet ajoute…",
unreadable: "Ce que ce paquet ajoute n'a pas pu être lu avant l'installation. Le résultat de l'installation indique ce qui a été chargé.",
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/i18n/src/namespaces/marketplace/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const ja = {
detail: {
homepage: "ホームページ",
installedV: "インストール済み · v{{version}}",
upToDate: "最新バージョンです",
about: "概要",
noReadme: "READMEがありません。",
versions: "バージョン",
Expand Down Expand Up @@ -220,6 +221,7 @@ const ja = {
preview: {
title: "{{name}} をインストールしますか?",
reinstallTitle: "{{name}} を再インストールしますか?",
keepsCustomizations: "この環境での {{name}} のカスタマイズは保持されます。再インストールで置き換わるのはパッケージ自体のメタデータのみで、カスタマイズパッケージに保存された変更はそのまま残ります。",
intro: "インストールすると、このランタイムに次のものが追加されます。",
reading: "このパッケージが追加する内容を読み込んでいます…",
unreadable: "このパッケージが追加する内容をインストール前に読み取れませんでした。インストール結果に、読み込まれた内容が表示されます。",
Expand Down
Loading
Loading