diff --git a/.changeset/37360-studio-all-types.md b/.changeset/37360-studio-all-types.md new file mode 100644 index 00000000000..7490f8e2992 --- /dev/null +++ b/.changeset/37360-studio-all-types.md @@ -0,0 +1,13 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(studio): 「全部类型」 All types ends the 高级 fold, and the type directory lists every type a package could hold + +Clause-②: no +Metadata-protocol: none + +Studio's 高级 Advanced fold lists a type only when the package holds one, so a new app showed no way to make its first email template, document, book, field mapping, seed data or AI context pack. The fold now ends with one row under no group, 全部类型 All types, which opens the type directory. On a package that page lists the types the package holds, as before, and after them in each group every other type of the menu's six groups, marked None yet (zh: 还没有) with the word that says what can be done there; a tile opens the type's list, whose New makes the first item. Types that cannot be made in Studio are listed as read-only, and Hide read-only drops them. The fold's own rule is unchanged: a 高级 type appears in it once the package holds one. The directory is the row's current page. + +New locale keys in the studio catalogue (en, zh): `engine.studio.menu.allTypes`, `engine.directory.notHeld`, `engine.directory.notHeldTitle`, `engine.directory.notHeldReadOnlyTitle`. No props or entry exports change. diff --git a/docs/adr/0084-application-builder-information-architecture.md b/docs/adr/0084-application-builder-information-architecture.md index 065d2c37902..f2281174404 100644 --- a/docs/adr/0084-application-builder-information-architecture.md +++ b/docs/adr/0084-application-builder-information-architecture.md @@ -217,6 +217,8 @@ The menu also holds four entries that open no type's list. Each sits in the grou | **Diagnostics** | 平台 Platform | decision 11 | | **The cross-package environment directory** (the `~all` leg) | 访问 Access | **drafted here, not ruled** — [item 1](#amendment-silent) below | +*(Amended 2026-11-25, card [#37360](https://github.com/objectstack-ai/objectstack/issues/37360), ruling record [comment 7177310364](https://github.com/objectstack-ai/objectstack/issues/37360#issuecomment-7177310364), maintainer, verbatim: 「37360 同意」: on a package the menu holds a fifth entry, **全部类型 All types**, the last row of the 高级 Advanced fold, below its groups — the one entry that sits under no group. It opens the type directory, which lists every type of the six groups: the ones the package holds, and the ones it holds none of yet, each marked so with what can be done there. The fold's rule stands — a 高级 type is drawn when the package holds one.)* + ### What stands, and what the amendment replaces {#amendment-stands} | The 2026-07-01 text | Since the amendment | diff --git a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.allTypes-37360.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.allTypes-37360.test.tsx new file mode 100644 index 00000000000..ce4d42df116 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.allTypes-37360.test.tsx @@ -0,0 +1,231 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#37360 — 全部类型 All types (ADR-0084, amended 2026-11-25). The + * 高级 fold's last row opens the area's type directory, and on a package that + * page lists every type of the menu's six groups: + * + * - the types the package holds, drawn as before: an item count, no mark; + * - after them in each group, the types it holds none of yet, each marked + * "None yet", with no count, and with the state word that says what can be + * done there — a type that cannot be made in Studio reads read-only; + * - a not-held type's tile opens its list, which carries New; + * - CONTROL: a type outside the six groups and a hidden type are not listed; + * a sweep that failed marks nothing; the cross-package leg lists only the + * environment catalog, as before. + * + * Pinned over the real directory page and the real list page; only the + * metadata reads and the network are doubled. + */ + +// Paid at collection, not inside a case's clock (check:test-source-alias). +import '@objectstack/lint'; +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +import '@objectstack/spec/identity'; +import { MetadataAreaHostContext, type MetadataAreaHost } from './metadataAreaHost'; +import type { RichMetadataTypeEntry } from './useMetadata'; + +const PKG = 'com.example.app'; + +const entry = (type: string, domain: string, allowEnvironmentOverlay: boolean, allowRuntimeCreate: boolean): RichMetadataTypeEntry => + ({ type, label: type, domain, allowEnvironmentOverlay, allowRuntimeCreate, overrideSource: 'registry' }) as RichMetadataTypeEntry; + +/** Served in the server's order: by domain, then by type. The registry's own flags. */ +const ENTRIES: RichMetadataTypeEntry[] = [ + entry('field', 'data', false, true), + entry('hook', 'data', false, true), + entry('object', 'data', false, true), + entry('api', 'system', false, false), + entry('doc', 'system', false, true), + entry('email_template', 'system', true, true), + entry('legacy_thing', 'identity', false, true), +]; + +/** What the doubled sweep answers; each case may change it before rendering. */ +const sweep = vi.hoisted(() => ({ + error: null as string | null, + packagesByType: {} as Record, + countsByType: {} as Record, +})); + +const CLIENT = { + list: async (type: string) => (type === 'package' ? [{ manifest: { id: PKG, name: 'App', scope: 'project' } }] : []), +}; + +vi.mock('./useMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataClient: () => CLIENT, + useMetadataTypes: () => ({ loading: false, error: null, entries: ENTRIES }), + useGlobalDiagnostics: () => ({ + loading: false, + error: sweep.error, + summary: { entries: [], total: 0, scannedTypes: 0, scannedItems: 0 }, + byType: {}, + warnByType: {}, + countsByType: sweep.countsByType, + lockedByType: {}, + packagesByType: sweep.packagesByType, + allPackages: [PKG], + reload: () => {}, + }), +})); +vi.mock('./i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataLocale: () => 'en-US', +})); +vi.mock('../../hooks/useCanAuthorMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useCanAuthorMetadata: () => true, +})); + +import { MetadataDirectoryPage, directoryNotHeldEntries } from './DirectoryPage'; +import { MetadataResourceListPage } from './ResourceListPage'; +import { registerDefaultMetadataSchemas } from './default-schemas'; +import { t } from './i18n'; + +registerDefaultMetadataSchemas(); + +const fetchMock = vi.fn(async (url: string) => { + const json = (status: number, body: unknown) => + new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } }); + const u = String(url); + if (u === '/api/v1/packages') { + return json(200, { success: true, data: { packages: [{ manifest: { id: PKG, name: 'App', scope: 'project' }, writable: true }] } }); + } + if (u.startsWith('/api/v1/data/sys_metadata_activation')) { + return json(200, { object: 'sys_metadata_activation', records: [], hasMore: false }); + } + return json(404, { success: false }); +}); + +beforeEach(() => { + fetchMock.mockClear(); + vi.stubGlobal('fetch', fetchMock); + // The package holds objects and hooks, and nothing of the Platform group. + sweep.error = null; + sweep.packagesByType = { object: [PKG], hook: [PKG], doc: ['com.other.pkg'] }; + sweep.countsByType = { object: 3, hook: 1 }; +}); +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); +}); + +const HOST: MetadataAreaHost = { packageId: PKG, readOnly: false, basePath: `/studio/${PKG}/metadata` }; + +function Location() { + const l = useLocation(); + return
{`${l.pathname}${l.search}`}
; +} + +function mount(host: MetadataAreaHost = HOST) { + const base = host.basePath; + return render( + + + + } /> + } /> + + + + + , + ); +} + +const tile = (type: string) => screen.getByTestId(`directory-tile-${type}`); +const listedTypes = () => + screen.queryAllByTestId(/^directory-tile-[a-z_]+$/).map((el) => el.getAttribute('data-testid')!.replace('directory-tile-', '')); +const word = (type: string) => tile(type).querySelector('[data-state-word]')?.getAttribute('data-state-word'); + +describe('全部类型 All types: the directory lists every type of the six groups on a package (objectstack#37360)', () => { + it('the held types as before, then in each group the ones the package holds none of yet', async () => { + mount(); + await screen.findByTestId('directory-tile-object'); + // Data: the held hook and object, in served order. Platform: none held, so all three follow. + expect(listedTypes()).toEqual(['hook', 'object', 'api', 'doc', 'email_template']); + for (const held of ['hook', 'object']) { + expect(tile(held)).not.toHaveAttribute('data-held'); + expect(screen.queryByTestId(`directory-tile-not-held-${held}`)).toBeNull(); + } + expect(within(tile('object')).getByTitle('3 item(s) of this type')).toHaveTextContent('3'); + }); + + it('a type held by none is marked "None yet", with no count, and with the word that says what can be done', async () => { + mount(); + await screen.findByTestId('directory-tile-object'); + for (const type of ['api', 'doc', 'email_template']) { + expect(tile(type)).toHaveAttribute('data-held', 'false'); + expect(screen.getByTestId(`directory-tile-not-held-${type}`)).toHaveTextContent('None yet'); + expect(within(tile(type)).queryByTitle(/item\(s\) of this type/)).toBeNull(); + } + expect(word('email_template')).toBe('writable'); + expect(word('doc')).toBe('addable'); + expect(screen.getByTestId('directory-tile-not-held-doc')).toHaveAttribute( + 'title', + 'This package holds none yet: open the list to make the first', + ); + // Cannot be made in Studio: listed, read-only, and its mark says none can be made here. + expect(word('api')).toBe('readOnly'); + expect(screen.getByTestId('directory-tile-not-held-api')).toHaveAttribute( + 'title', + 'This package holds none, and none can be made here', + ); + }); + + it('"Hide read-only" drops the types that cannot be made here, held or not', async () => { + mount(); + await screen.findByTestId('directory-tile-object'); + fireEvent.click(screen.getByRole('button', { name: /^Hide read-only/ })); + expect(listedTypes()).toEqual(['hook', 'object', 'doc', 'email_template']); + }); + + it("a not-held type's tile opens its list, which carries New", async () => { + mount(); + await screen.findByTestId('directory-tile-email_template'); + expect(tile('email_template')).toHaveAttribute('href', `/studio/${PKG}/metadata/email_template?package=${PKG}`); + fireEvent.click(tile('email_template')); + await waitFor(() => + expect(screen.getByTestId('location')).toHaveTextContent(`/studio/${PKG}/metadata/email_template?package=${PKG}`), + ); + expect(await screen.findByTestId('metadata-list-create')).toBeInTheDocument(); + // The header's New and the empty list's own: the package holds none yet. + expect(screen.getAllByRole('button', { name: t('engine.list.create', 'en-US') }).length).toBeGreaterThan(0); + }); + + it('CONTROL: a type outside the six groups and a hidden type are never listed', async () => { + mount(); + await screen.findByTestId('directory-tile-object'); + expect(screen.queryByTestId('directory-tile-legacy_thing')).toBeNull(); + expect(screen.queryByTestId('directory-tile-field')).toBeNull(); + }); + + it('CONTROL: a sweep that failed said nothing of what the package holds — nothing is marked', async () => { + sweep.error = 'not found'; + sweep.packagesByType = {}; + mount(); + await screen.findByText(t('engine.directory.noMatches', 'en-US')); + expect(listedTypes()).toEqual([]); + expect(screen.queryAllByTestId(/^directory-tile-not-held-/)).toEqual([]); + }); + + it('CONTROL: the cross-package leg lists the environment catalog only, with no mark', async () => { + mount({ packageId: null, readOnly: false, basePath: '/studio/~all/metadata' }); + await screen.findByRole('heading', { level: 1 }); + expect(listedTypes()).toEqual([]); + expect(screen.queryAllByTestId(/^directory-tile-not-held-/)).toEqual([]); + }); +}); + +describe('directoryNotHeldEntries (objectstack#37360)', () => { + it('every served type of the six groups the package does not hold, in served order; none off a package', () => { + const held = ENTRIES.filter((e) => e.type === 'object'); + expect(directoryNotHeldEntries(ENTRIES, held, true).map((e) => e.type)).toEqual(['hook', 'api', 'doc', 'email_template']); + expect(directoryNotHeldEntries(ENTRIES, held, false)).toEqual([]); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx index 619acee1ed3..d98cc96df79 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx @@ -13,6 +13,18 @@ * Item counts are lazy — we only fetch when the user lands on a * domain that has it. For MVP we just show "—" until the user clicks * into a type. Pre-fetching all 27 counts on page load is wasteful. + * + * ## 全部类型 All types (ADR-0084, amended 2026-11-25; objectstack#37360) + * + * Under Studio's area on a package this page is what the 高级 fold's last row + * opens. It lists the types the package holds — the one rule it shares with + * the menu (`scopeDirectoryEntries`), drawn as before — and, after them in + * each group, every other type of the menu's six groups, each marked as one + * the package holds none of yet, with the state word that says what can be + * done there. A tile opens the type's list, whose New makes the first item. + * The types that cannot be made in Studio are listed too, read-only, so a + * builder learns they exist and come from code; "Hide read-only" drops them. + * The cross-package leg and Setup list as before. */ import * as React from 'react'; @@ -40,11 +52,30 @@ import { import { buildPackageScopeOptions } from './package-scope.js'; import { diagnosticsHeaderTone, type DiagnosticsHeaderTone } from './diagnostics-tone.js'; import { SETUP_DATASOURCES_PATH, useMetadataAreaHost } from './metadataAreaHost.js'; -import { scopeDirectoryEntries } from './directoryScope.js'; +import { HIDDEN_DIRECTORY_TYPES, scopeDirectoryEntries } from './directoryScope.js'; import { WritabilityBadge, typeStateWord } from './PageShell.js'; import { ENVIRONMENT_SCOPE_QUERY } from './catalog-scope.js'; import { usePackageCustomizations } from '../studio-design/CustomizationMark.js'; import { customizationCountsByType, customizationTotal } from '../studio-design/customizationMarks.js'; +import { STUDIO_MENU_GROUPS } from '../studio-design/studioMenuModel.js'; + +/** + * objectstack#37360 — on a package under Studio's area, the types this page + * lists besides the ones the package holds: every other served type of the + * menu's six groups, in served order. Empty in any other scope. + */ +export function directoryNotHeldEntries( + entries: readonly T[], + held: readonly T[], + onPackage: boolean, +): T[] { + if (!onPackage) return []; + const heldTypes = new Set(held.map((e) => e.type)); + const groups: ReadonlySet = new Set(STUDIO_MENU_GROUPS); + return entries.filter( + (e) => !heldTypes.has(e.type) && !HIDDEN_DIRECTORY_TYPES.has(e.type) && groups.has(e.domain ?? ''), + ); +} /** * The "View all issues" link's look per sweep tone (objectui#12768). The @@ -157,6 +188,7 @@ export function MetadataDirectoryPage() { lockedByType, packagesByType, loading: diagLoading, + error: diagError, } = useGlobalDiagnostics(client, 'warning', activePackage ?? undefined); const diagTone = diagnosticsHeaderTone(diagSummary.entries); @@ -182,24 +214,33 @@ export function MetadataDirectoryPage() { }), [host, entries, activePackage, packagesByType], ); + // objectstack#37360 — on a package under the area, every other type of the + // six groups follows the held ones, each marked as held by none yet. A sweep + // that failed said nothing of what the package holds: nothing is marked. + const notHeldEntries = React.useMemo( + () => directoryNotHeldEntries(entries, scopedEntries, !!host && host.packageId !== null && !diagError), + [host, entries, scopedEntries, diagError], + ); + const notHeldTypes = React.useMemo(() => new Set(notHeldEntries.map((e) => e.type)), [notHeldEntries]); + const listedEntries = React.useMemo(() => [...scopedEntries, ...notHeldEntries], [scopedEntries, notHeldEntries]); // Counts per domain for the filter chip bar. const domainCounts = React.useMemo(() => { - const c: Record = { all: scopedEntries.length }; - for (const e of scopedEntries) { + const c: Record = { all: listedEntries.length }; + for (const e of listedEntries) { const d = e.domain ?? 'other'; c[d] = (c[d] ?? 0) + 1; } return c; - }, [scopedEntries]); + }, [listedEntries]); // objectstack#29705 — a tile's word answers "what can I do here" in the // package's context: a read-only package's overlay type can be customized, // never "writable". The filter hides the types that word marks read-only. const packageReadOnly = !!host?.readOnly; - const actionableCount = scopedEntries.filter((e) => typeStateWord(e, packageReadOnly) !== 'readOnly').length; + const actionableCount = listedEntries.filter((e) => typeStateWord(e, packageReadOnly) !== 'readOnly').length; - const filtered = scopedEntries.filter((e) => { + const filtered = listedEntries.filter((e) => { if (hideReadOnly && typeStateWord(e, packageReadOnly) === 'readOnly') return false; if (domainFilter !== 'all' && (e.domain ?? 'other') !== domainFilter) return false; if (query) { @@ -357,6 +398,7 @@ export function MetadataDirectoryPage() { warnCount={warnByType[e.type] ?? 0} lockedCount={lockedByType[e.type] ?? 0} itemCount={totalCount} + notHeld={notHeldTypes.has(e.type)} customizedCount={customizedByType?.[e.type]} packageReadOnly={packageReadOnly} packageFilter={activePackage ?? undefined} @@ -422,6 +464,7 @@ function TypeTile({ href: hrefOverride, customizedCount, packageReadOnly = false, + notHeld = false, }: { entry: RichMetadataTypeEntry; locale?: string; @@ -440,6 +483,8 @@ function TypeTile({ href?: string; /** The type's served customization count (ADR-0146 D3); absent while unread, failed, or none. */ customizedCount?: number; + /** The package holds no item of this type yet (objectstack#37360): marked so, with no count. */ + notHeld?: boolean; }) { // Prefer the locale-table translation; fall back to server's `label` (typically English). const label = translateMetadataType(entry.type, locale, entry.label); @@ -452,8 +497,11 @@ function TypeTile({ return ( 0 ? 'border-destructive/40 hover:border-destructive' : 'hover:border-primary') @@ -477,13 +525,29 @@ function TypeTile({
- - {itemCount} - + {notHeld ? ( + + {t('engine.directory.notHeld', locale ?? 'en')} + + ) : ( + + {itemCount} + + )} {customizedCount !== undefined && customizedCount > 0 && ( { const kernel: MetadataAreaHost = { packageId: PLATFORM, readOnly: true, basePath: `/studio/${PLATFORM}/metadata` }; mount(kernel, `/studio/${PLATFORM}/metadata?package=${PLATFORM}`, ); // Setup would repair this URL onto a project package; the area keeps its own. - expect(await screen.findByText(t('engine.directory.noMatches', 'en-US'))).toBeInTheDocument(); + // objectstack#37360 — rewritten on purpose: the kernel package holds none of these types, so the + // directory lists each as one it holds none of yet (全部类型 All types), scoped to the kernel package. + // It read "No matches". + expect((await tile('flow')).getAttribute('href')).toBe(`/studio/${PLATFORM}/metadata/flow?package=${PLATFORM}`); + expect(screen.getByTestId('directory-tile-not-held-flow')).toBeInTheDocument(); expect(where()).toBe(`/studio/${PLATFORM}/metadata?package=${PLATFORM}`); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx index e52440c27ad..d3a9bd336b5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx @@ -221,8 +221,9 @@ describe('Studio: the "All metadata" area in the builder (objectstack#28561)', ( host: { packageId: PACKAGE_ID, readOnly: false, basePath: `/studio/${PACKAGE_ID}/metadata` }, }); expect(where()).toBe(`/studio/${PACKAGE_ID}/metadata?package=${PACKAGE_ID}`); - // The directory is no one entry's page; the builder's menu stays beside it. - expect(menu().queryByRole('link', { current: 'page' })).toBeNull(); + // objectstack#37360 — rewritten on purpose: the directory is 全部类型 All types' page, the 高级 fold's + // last row. It read "The directory is no one entry's page". The builder's menu stays beside it. + expect(menu().getByRole('link', { current: 'page' })).toHaveAttribute('data-testid', 'studio-menu-entry-allTypes'); expect(menu().getByTestId('studio-menu-group-data')).toBeInTheDocument(); expect(screen.queryByTestId('studio-pillar-not-found')).toBeNull(); // The surface and the area share the one package-list read. diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx index 84ed1e89eea..31da8145ae3 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx @@ -23,6 +23,11 @@ * 8. The 常用 types are listed on a package that holds none of them. * 9. `~org` and `~all` draw no fold. * + * objectstack#37360 — 全部类型 All types (ADR-0084, amended 2026-11-25): + * 10. The fold's last row, below its groups and under no group's label; it + * opens the area's type directory and is current there. CONTROL: a 高级 + * type the package holds none of is still not in the fold. + * * The provider, the sidebar primitive and the router are real; only the * metadata reads are doubled. */ @@ -422,3 +427,62 @@ describe('~org and ~all draw no fold (objectstack#37201)', () => { expect(within(automation).getAllByRole('link').map((a) => a.getAttribute('data-testid'))).toEqual(['studio-menu-entry-orgFlows']); }); }); + +describe('全部类型 All types (objectstack#37360, ADR-0084 amended 2026-11-25)', () => { + it('is the fold\'s last row, below its groups and under no group\'s label, and opens the type directory', () => { + renderAt(`/studio/${PKG}/data`); + fireEvent.click(fold()); + const row = entry('allTypes'); + expect(row).toBeVisible(); + expect(row).toHaveTextContent(/^All types$/); + expect(row).toHaveAttribute('href', `/studio/${PKG}/metadata`); + // Last: no link of the fold comes after it, and every group of the fold comes before it. + const links = within(foldRegion()).getAllByRole('link'); + expect(links[links.length - 1]).toBe(row); + const groups = [...foldRegion().querySelectorAll('[data-testid^="studio-menu-advanced-group-"]')]; + expect(groups.length).toBeGreaterThan(0); + for (const g of groups) expect(g.compareDocumentPosition(row) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + // Under no group: no group holds it, and no group label sits over it. + expect(row.closest('[data-testid^="studio-menu-advanced-group-"], [data-testid^="studio-menu-group-"]')).toBeNull(); + expect(row.closest('[data-sidebar="group"]')).toBeNull(); + expect(screen.getByTestId('studio-menu-all-types').querySelector('[data-sidebar="group-label"]')).toBeNull(); + }); + + it('on the type directory it is the current page, and the fold opens by itself without writing its cookie', () => { + renderAt(`/studio/${PKG}/metadata`); + expect(fold()).toHaveAttribute('aria-expanded', 'true'); + expect(entry('allTypes')).toHaveAttribute('aria-current', 'page'); + expect(cookie(STUDIO_MENU_ADVANCED_COOKIE)).toBeUndefined(); + }); + + it('a search lists it last when its name matches, and not otherwise', () => { + renderAt(`/studio/${PKG}/data`); + const search = screen.getByTestId('studio-menu-search'); + fireEvent.change(search, { target: { value: 'all types' } }); + expect(within(screen.getByTestId('studio-menu')).getAllByRole('link').map((a) => a.getAttribute('data-testid'))).toEqual([ + 'studio-menu-entry-allTypes', + ]); + expect(screen.queryByTestId('studio-menu-no-matches')).toBeNull(); + fireEvent.change(search, { target: { value: 'flow' } }); + expect(screen.queryByTestId('studio-menu-entry-allTypes')).toBeNull(); + }); + + it('CONTROL: the fold still leaves out a 高级 type the package holds none of', () => { + reads.entries = [...SERVED, { type: 'email_template', domain: 'system' }]; + renderAt(`/studio/${PKG}/data`); + fireEvent.click(fold()); + expect(entry('allTypes')).toBeVisible(); + expect(entry('type:hook')).toBeVisible(); + expect(screen.queryByTestId('studio-menu-entry-type:email_template')).toBeNull(); + expect(screen.queryByTestId('studio-menu-entry-type:position')).toBeNull(); + }); + + it.each([ + ['~org', '/studio/~org/metadata/flow?source=runtime'], + ['~all', '/studio/~all/metadata'], + ])('%s draws no fold and no 全部类型 row', (segment, path) => { + renderAt(path, segment); + expect(screen.queryByTestId('studio-menu-entry-allTypes')).toBeNull(); + expect(screen.queryByTestId('studio-menu-all-types')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx index fc4179bfa17..bc5cf651a78 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx @@ -29,6 +29,12 @@ * the hook list), without writing the cookie. * - A search ignores it: the matches of both tiers are listed flat. * - `~org` and `~all` draw no fold: their entries are listed flat. + * + * The fold's last row, below its groups and under no group's label, is + * 全部类型 All types (ADR-0084, amended 2026-11-25; objectstack#37360): it + * opens the area's type directory, where every type of the six groups is + * listed, the ones the package holds none of yet included. A search lists it + * last, after the matching groups. */ import * as React from 'react'; @@ -64,6 +70,7 @@ import { STUDIO_MENU_COOKIE, buildStudioMenu, readStudioMenuAdvancedCookie, + studioMenuAllTypesEntry, studioMenuCurrentKey, studioMenuEntryMatches, studioMenuScope, @@ -202,6 +209,9 @@ function StudioMenuBody({ const matching = menu .map((g) => ({ ...g, entries: g.entries.filter((e) => studioMenuEntryMatches(e, labelOf(e), query)) })) .filter((g) => g.entries.length > 0); + // objectstack#37360 — 全部类型 All types: a package's, under no group. + const allTypes = studioMenuAllTypesEntry(scope); + const allTypesMatches = !!allTypes && studioMenuEntryMatches(allTypes, labelOf(allTypes), query); // The fold is a package's: a search, `~org` and `~all` list their entries flat. const folded = scope.kind === 'package' && !searching; const tiers = studioMenuTiers(menu); @@ -210,7 +220,8 @@ function StudioMenuBody({ // page is one of its entries — until the author closes it on that page. const [remembered, setRemembered] = React.useState(readAdvancedCookie); const [closedOn, setClosedOn] = React.useState(null); - const currentIsAdvanced = tiers.advanced.some((g) => g.entries.some((e) => e.key === current)); + const currentIsAdvanced = + tiers.advanced.some((g) => g.entries.some((e) => e.key === current)) || (!!allTypes && allTypes.key === current); const advancedOpen = remembered || (currentIsAdvanced && closedOn !== current); const toggleAdvanced = () => { const next = !advancedOpen; @@ -280,6 +291,13 @@ function StudioMenuBody({ ); }); + // The fold's last row, under no group: no label above it, no group around it. + const renderAllTypes = (entry: StudioMenuEntry) => ( +
+ {renderEntry(entry)} +
+ ); + return (