From e2c87b8676f1f173b927d0a6ed647271bab9d6ba Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 15:47:13 +0000 Subject: [PATCH 1/5] feat(studio): the Delete package dialog states what goes The dialog lists each object the package holds with the rows the data list counts, every other published item counted by type and the pending drafts, read from the package export door when it opens. Choosing to drop the data adds a line that the tables are dropped permanently and skip the recycle bin. Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude --- .../src/views/metadata-admin/PackagesPage.tsx | 62 +++++++ .../metadata-admin/packageRemovalContents.tsx | 158 ++++++++++++++++++ ui/packages/i18n/src/namespaces/studio/en.ts | 10 ++ ui/packages/i18n/src/namespaces/studio/zh.ts | 10 ++ 4 files changed, 240 insertions(+) create mode 100644 ui/packages/app-shell/src/views/metadata-admin/packageRemovalContents.tsx diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 6f906915a8a..7299b0a26f7 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -77,6 +77,12 @@ import { import { useMetadataLocale, t, tFormat } from './i18n.js'; import { useMetadataClient } from './useMetadata.js'; import { PackageFormDialog } from './PackageFormDialog.js'; +import { + PackageRemovalSummary, + readPackageRemovalContents, + type PackageRemovalState, +} from './packageRemovalContents.js'; +import { useAdapter } from '@object-ui/react'; import { PageHeader } from '../../layout/PageHeader.js'; import { errorCodeIs } from '@object-ui/types'; import { readEnvelopeFailureText } from '../../utils/apiErrorEnvelope.js'; @@ -554,6 +560,15 @@ export function PackageDetailSheet({ const [disableOpen, setDisableOpen] = React.useState(false); const [deleteMode, setDeleteMode] = React.useState(''); const [deleteTyped, setDeleteTyped] = React.useState(''); + // objectstack#31025 — what the delete removes, read when its dialog opens. + const [removal, setRemoval] = React.useState(null); + // The count reads key on the package id alone (AGENTS.md #10): the adapter + // is read through a ref, kept current from an effect. + const adapter = useAdapter(); + const adapterRef = React.useRef(adapter); + React.useEffect(() => { + adapterRef.current = adapter; + }); const [discardOpen, setDiscardOpen] = React.useState(false); const [dupOpen, setDupOpen] = React.useState(false); const [dupName, setDupName] = React.useState(''); @@ -590,6 +605,47 @@ export function PackageDetailSheet({ }; }, [open, pkg?.manifest.id]); + // objectstack#31025 — the Delete dialog states what goes: the export door's + // items (each object with the rows the data list counts), read each time + // the dialog opens. + const removalPackageId = deleteOpen ? pkg?.manifest.id : undefined; + React.useEffect(() => { + if (!removalPackageId) { + setRemoval(null); + return; + } + let cancelled = false; + setRemoval({ status: 'loading' }); + apiJson(`${API}/${encodeURIComponent(removalPackageId)}/export`) + .then((manifest) => { + if (cancelled) return; + const contents = readPackageRemovalContents(manifest); + setRemoval({ status: 'ready', contents, counts: {} }); + const source = adapterRef.current; + for (const { name } of contents.objects) { + const counted: Promise = + source && typeof source.find === 'function' + ? source + .find(name, { $top: 0 }) + .then((r) => (typeof r?.total === 'number' ? r.total : null)) + .catch(() => null) + : Promise.resolve(null); + void counted.then((count) => { + if (cancelled) return; + setRemoval((prev) => + prev?.status === 'ready' ? { ...prev, counts: { ...prev.counts, [name]: count } } : prev, + ); + }); + } + }) + .catch(() => { + if (!cancelled) setRemoval({ status: 'failed' }); + }); + return () => { + cancelled = true; + }; + }, [removalPackageId]); + if (!pkg) return null; const id = pkg.manifest.id; const enabled = pkg.enabled !== false && pkg.status !== 'disabled'; @@ -1290,6 +1346,12 @@ export function PackageDetailSheet({ +