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
15 changes: 15 additions & 0 deletions .changeset/37082-studio-group-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

fix(studio): one name per group: the directory and a type page's badge say Platform / Access, like the menu

Clause-②: no
Metadata-protocol: none

ADR-0084 (amended) · part of the Studio redesign follow-ups.

- **The shared domain dictionary (`translateMetadataDomain`) names the `system` group Platform / 平台 and the `security` group Access / 访问**, the amended ADR-0084's group names. It used to say System / 系统 and Security / 安全 while the Studio left menu said Platform / Access.
- **Every place a group is named now reads that one dictionary:** the Studio left menu (`studioMenuGroupLabel` reads it instead of its own two keys), the All metadata directory's group headings and domain chips, and the domain badge on a type or item page (`PageShell`). Setup's datasource pages draw the same badge, so a datasource reads Platform / 平台 there too, the group ADR-0084 puts it in.
- The menu-only keys `engine.studio.menu.groupSystem` and `engine.studio.menu.groupSecurity` are removed from the `studio` namespace (en and zh); nothing reads them any more.
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#37082 — one name per group across Studio. The left menu, the All
* metadata directory's group headings and domain chips, and the domain badge
* on a type or item page (`PageShell`, which Setup's datasource pages draw too)
* name the `system` group Platform / 平台 and the `security` group Access / 访问
* (objectstack ADR-0084, amended 2026-11-24), in en and in zh-CN.
*
* Pinned over the real directory page and the real header, each word compared
* with the menu's own (`studioMenuGroupLabel`); CONTROL: the `data` group keeps
* Data / 数据, and the retired words System / 系统 and Security / 安全 are drawn
* nowhere.
*/

import '@testing-library/jest-dom/vitest';
import * as React from 'react';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup, within } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { MetadataAreaHostContext, type MetadataAreaHost } from './metadataAreaHost';
import type { RichMetadataTypeEntry } from './useMetadata';

const PKG = 'com.example.showcase';

const entry = (type: string, domain: string): RichMetadataTypeEntry =>
({ type, label: type, domain, allowEnvironmentOverlay: false, allowRuntimeCreate: true }) as RichMetadataTypeEntry;

const ENTRIES: RichMetadataTypeEntry[] = [
entry('object', 'data'),
entry('datasource', 'system'),
entry('translation', 'system'),
entry('permission', 'security'),
];

const CLIENT = { list: async () => [] };

/** The locale the page reads; each case sets it before rendering. */
let LOCALE = 'en';

vi.mock('./useMetadata', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useMetadataClient: () => CLIENT,
useMetadataTypes: () => ({ loading: false, error: null, entries: ENTRIES }),
useGlobalDiagnostics: () => ({
loading: false,
error: null,
summary: { entries: [], total: 0, scannedTypes: 0, scannedItems: 0 },
byType: {},
warnByType: {},
countsByType: {},
lockedByType: {},
packagesByType: Object.fromEntries(ENTRIES.map((e) => [e.type, [PKG]])),
allPackages: [PKG],
reload: () => {},
}),
}));
vi.mock('./i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useMetadataLocale: () => LOCALE,
}));
vi.stubGlobal(
'fetch',
vi.fn(async () =>
new Response(JSON.stringify({ success: true, data: { packages: [] } }), {
status: 200,
headers: { 'Content-Type': 'application/json' },
}),
),
);

import { MetadataDirectoryPage } from './DirectoryPage';
import { PageShell } from './PageShell';
import { studioMenuGroupLabel } from '../studio-design/studioMenuGroupLabel';

afterEach(() => {
cleanup();
});

const host: MetadataAreaHost = { packageId: PKG, readOnly: false, basePath: `/studio/${PKG}/metadata` };

const CASES = [
{ locale: 'en', data: 'Data', platform: 'Platform', access: 'Access', retired: ['System', 'Security'] },
{ locale: 'zh-CN', data: '数据', platform: '平台', access: '访问', retired: ['系统', '安全'] },
] as const;

function renderDirectory() {
return render(
<MetadataAreaHostContext.Provider value={host}>
<MemoryRouter>
<MetadataDirectoryPage />
</MemoryRouter>
</MetadataAreaHostContext.Provider>,
);
}

function renderShell(type: string, itemName?: string) {
const e = ENTRIES.find((x) => x.type === type);
return render(
<MemoryRouter>
<PageShell entry={e} itemName={itemName}>
<div />
</PageShell>
</MemoryRouter>,
);
}

describe.each(CASES)('one name per group ($locale, objectstack#37082)', (c) => {
it('the menu names the groups Platform and Access', () => {
expect(studioMenuGroupLabel('system', c.locale)).toBe(c.platform);
expect(studioMenuGroupLabel('security', c.locale)).toBe(c.access);
expect(studioMenuGroupLabel('data', c.locale)).toBe(c.data);
});

it('the directory\'s group headings use the menu\'s names', async () => {
LOCALE = c.locale;
renderDirectory();
await screen.findByText('datasource', { selector: 'code' });
const headings = screen.getAllByRole('heading', { level: 2 }).map((h) => (h.textContent ?? '').trim());
expect(headings).toEqual(
expect.arrayContaining([
`${studioMenuGroupLabel('data', c.locale)} (1)`,
`${studioMenuGroupLabel('security', c.locale)} (1)`,
`${studioMenuGroupLabel('system', c.locale)} (2)`,
]),
);
expect(headings).toEqual(expect.arrayContaining([`${c.platform} (2)`, `${c.access} (1)`, `${c.data} (1)`]));
for (const word of c.retired) expect(headings.join(' ')).not.toContain(word);
});

it('the directory\'s domain chips use the menu\'s names', async () => {
LOCALE = c.locale;
renderDirectory();
await screen.findByText('datasource', { selector: 'code' });
expect(screen.getByRole('button', { name: `${studioMenuGroupLabel('system', c.locale)} (2)` })).toBeInTheDocument();
expect(screen.getByRole('button', { name: `${studioMenuGroupLabel('security', c.locale)} (1)` })).toBeInTheDocument();
expect(screen.getByRole('button', { name: `${c.platform} (2)` })).toBeInTheDocument();
expect(screen.getByRole('button', { name: `${c.access} (1)` })).toBeInTheDocument();
expect(screen.getByRole('button', { name: `${c.data} (1)` })).toBeInTheDocument();
for (const word of c.retired) {
expect(screen.queryByRole('button', { name: new RegExp(`^${word} \\(`, 'u') })).toBeNull();
}
});

it('a type page\'s badge uses the menu\'s names', () => {
LOCALE = c.locale;
renderShell('datasource');
const title = document.querySelector('h1')!.parentElement!;
expect(within(title).getByText(studioMenuGroupLabel('system', c.locale))).toBeInTheDocument();
expect(within(title).getByText(c.platform)).toBeInTheDocument();
cleanup();
renderShell('permission');
expect(within(document.querySelector('h1')!.parentElement!).getByText(c.access)).toBeInTheDocument();
});

it('an item page\'s badge uses the menu\'s names (Setup\'s datasource item page draws this header)', () => {
LOCALE = c.locale;
renderShell('datasource', 'main_db');
const meta = screen.getByTestId('page-shell-header-meta');
expect(within(meta).getByText(studioMenuGroupLabel('system', c.locale))).toBeInTheDocument();
expect(within(meta).getByText(c.platform)).toBeInTheDocument();
cleanup();
renderShell('permission', 'sales_rep');
expect(within(screen.getByTestId('page-shell-header-meta')).getByText(c.access)).toBeInTheDocument();
for (const word of c.retired) expect(screen.getByTestId('page-shell-header-meta').textContent).not.toContain(word);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('PageShell compact header wraps instead of squeezing the breadcrumb (ob
const meta = screen.getByTestId('page-shell-header-meta');
expect(nav.nextElementSibling).toBe(meta);
// The chips, the subtitle, the stats and the actions all live in it.
expect(meta).toContainElement(screen.getByText('Security'));
expect(meta).toContainElement(screen.getByText('Access'));
expect(meta).toContainElement(screen.getByText('Can be added'));
expect(meta).toContainElement(screen.getByText('Permission set'));
expect(meta).toContainElement(screen.getByText('Objects granted'));
Expand Down
15 changes: 11 additions & 4 deletions ui/packages/app-shell/src/views/metadata-admin/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,22 @@ const TYPE_LABELS_ZH: Record<string, string> = {
picklist: '选项列表',
};

/**
* The group name each registered metadata `domain` is drawn with, everywhere a
* domain is named: the Studio menu, the All metadata directory's headings and
* chips, and the domain badge on a type or item page (Setup's datasource pages
* included). `system` is Platform / 平台 and `security` is Access / 访问, the
* names objectstack ADR-0084 (amended 2026-11-24) gives those two groups.
*/
const DOMAIN_LABELS_EN: Record<string, string> = {
data: 'Data',
ui: 'UI',
automation: 'Automation',
ai: 'AI',
system: 'System',
system: 'Platform',
platform: 'Platform',
identity: 'Identity',
security: 'Security',
security: 'Access',
other: 'Other',
};

Expand All @@ -195,10 +202,10 @@ const DOMAIN_LABELS_ZH: Record<string, string> = {
ui: '界面',
automation: '自动化',
ai: 'AI',
system: '系统',
system: '平台',
platform: '平台',
identity: '身份',
security: '安全',
security: '访问',
other: '其他',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null }));
vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null }));

import { StudioDesignSurface } from './StudioDesignSurface';
import { t } from '../metadata-admin/i18n';
import { translateMetadataDomain } from '../metadata-admin/i18n';
// The source under test reaches dynamic imports of `@objectstack/lint`; their first
// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`).
import '@objectstack/lint';
Expand All @@ -144,8 +144,8 @@ window.matchMedia = ((query: string) => ({

const key = (type: string, name: string) => `${type}/${name}`;

/** The menu's own name for the `security` group (the shared dictionary keeps "Security"). */
const ACCESS = t('engine.studio.menu.groupSecurity', 'en');
/** The `security` group's name, Access (objectstack ADR-0084, amended). */
const ACCESS = translateMetadataDomain('security', 'en');
const OBJECT_ENTRY = 'studio-menu-entry-type:object';
const PERMISSION_ENTRY = 'studio-menu-entry-type:permission';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@
/**
* The name the left menu draws for each of its six groups (objectstack
* ADR-0084, amended 2026-11-24; decision 11 of #36890): the registered domain's
* label, except two the amendment renames for the menu, `system` → Platform /
* 平台 and `security` → Access / 访问.
* name in the shared dictionary (`translateMetadataDomain`), which draws
* `system` as Platform / 平台 and `security` as Access / 访问.
*
* Menu-only on purpose. The shared dictionary (`translateMetadataDomain`) keeps
* System / 系统 and Security / 安全: it has readers outside the menu, Setup's
* datasource pages among them (`PageShell`'s domain badge), and no other
* Studio heading or chip is renamed by this.
* One dictionary, so the menu, the All metadata directory's headings and chips,
* and a type or item page's domain badge cannot name a group two ways.
*/

import { t, translateMetadataDomain } from '../metadata-admin/i18n.js';
import { translateMetadataDomain } from '../metadata-admin/i18n.js';
import type { StudioMenuGroup } from './studioMenuModel.js';

const MENU_GROUP_LABEL_KEYS: Partial<Record<StudioMenuGroup, string>> = {
system: 'engine.studio.menu.groupSystem',
security: 'engine.studio.menu.groupSecurity',
};

export function studioMenuGroupLabel(group: StudioMenuGroup, locale: string): string {
const key = MENU_GROUP_LABEL_KEYS[group];
return key ? t(key, locale) : translateMetadataDomain(group, locale);
return translateMetadataDomain(group, locale);
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,17 @@ describe('the menu search', () => {
});
});

describe('the group names: the menu\'s own, the shared dictionary unchanged', () => {
it('the menu names `system` Platform / 平台 and `security` Access / 访问; the other four as the dictionary does', () => {
describe('the group names: one dictionary for the menu and the directory (ADR-0084, amended)', () => {
it('the menu names `system` Platform / 平台 and `security` Access / 访问', () => {
expect(STUDIO_MENU_GROUPS.map((g) => studioMenuGroupLabel(g, 'en'))).toEqual(['Data', 'UI', 'Automation', 'Platform', 'Access', 'AI']);
expect(STUDIO_MENU_GROUPS.map((g) => studioMenuGroupLabel(g, 'zh-CN'))).toEqual(['数据', '界面', '自动化', '平台', '访问', 'AI']);
});

it('the shared dictionary keeps System / 系统 and Security / 安全 (Setup\'s datasource pages read it, `PageShell`\'s badge)', () => {
expect(translateMetadataDomain('system', 'en')).toBe('System');
expect(translateMetadataDomain('system', 'zh-CN')).toBe('系统');
expect(translateMetadataDomain('security', 'en')).toBe('Security');
expect(translateMetadataDomain('security', 'zh-CN')).toBe('安全');
it('the menu draws each group with the shared dictionary\'s word, in en and zh-CN', () => {
for (const locale of ['en', 'zh-CN']) {
for (const g of STUDIO_MENU_GROUPS) {
expect(studioMenuGroupLabel(g, locale), `${g} in ${locale}`).toBe(translateMetadataDomain(g, locale));
}
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*
* Six, one per domain the spec registers a metadata type under, in the
* amendment's order. A type's group is its served registry `domain`; the
* group's name is the menu's own (`studioMenuGroupLabel`), which draws
* `system` as Platform and `security` as Access (decision 11) while the shared
* dictionary keeps System and Security.
* group's name is the shared domain dictionary's (`studioMenuGroupLabel`), which
* draws `system` as Platform and `security` as Access (decision 11), the same
* names as the directory's headings and chips and a type page's badge.
*
* ## Entries
*
Expand Down
2 changes: 0 additions & 2 deletions ui/packages/i18n/src/namespaces/studio/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3504,8 +3504,6 @@ const STUDIO_EN: Record<string, string> = {
'engine.studio.menu.owd': 'Default sharing',
'engine.studio.menu.diagnostics': 'Diagnostics',
'engine.studio.menu.environment': 'Positions and permissions',
'engine.studio.menu.groupSystem': 'Platform',
'engine.studio.menu.groupSecurity': 'Access',
// objectstack#36502 — the notice on a retired Interfaces link's landing.
'engine.studio.interfacesRetired.sentence': 'Interface edits have moved into the app.',
'engine.studio.interfacesRetired.backToApp': 'Back to the app',
Expand Down
2 changes: 0 additions & 2 deletions ui/packages/i18n/src/namespaces/studio/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3095,8 +3095,6 @@ const STUDIO_ZH: Record<string, string> = {
'engine.studio.menu.owd': '默认共享',
'engine.studio.menu.diagnostics': '诊断',
'engine.studio.menu.environment': '岗位与权限',
'engine.studio.menu.groupSystem': '平台',
'engine.studio.menu.groupSecurity': '访问',
// objectstack#36502 — 旧「界面」链接落地时的提示。
'engine.studio.interfacesRetired.sentence': '界面的修改已经搬到应用里',
'engine.studio.interfacesRetired.backToApp': '回到应用',
Expand Down
Loading