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

fix(studio): the permission page title, the AI panel's 正在看 line and the field panel header use names, not internal names

Clause-②: no
Metadata-protocol: none

Three Studio surfaces still showed internal names. They now use the names the builder gave:

- **Permission page.** The open permission set's title is the set's label alone. The app's name is already in the top bar, so the title no longer starts with it. The line under the title reads 随应用提供 / "Included with the app" instead of 包内置 / "Package". The note at the right of the tab row reads 本应用对象 · 发布后生效 / "This app’s objects · live on publish" instead of 仅本包对象 · 保存为草稿. The Setup pages keep their own wording.
- **AI panel 正在看 line.** On the Access and Automations rails the line reads the rail's word and the open item's label, for example 「正在看:权限 · 组织成员」 or 「正在看:流程 · 新会议提醒」, as the Data rail's 「正在看:会议 · 记录」 does. It no longer shows `permission · app_…_member_access`. The type and machine name stay on the line's hover title. What the agent receives is unchanged.
- **Field properties panel.** One header row: 字段属性 (Field properties), the field's label, the field's actions and one close button. The field's machine name shows only under 开发者信息 (Developer info). The 「AI 助手 / 回到对话 →」 strip at the foot of the right panel is gone, because the 属性 | AI 助手 switch at the top does the same thing and carries the same pending count.

`@object-ui/i18n`: three new `studio` namespace keys (`engine.studio.access.origin.app`, `engine.studio.copilot.subject.access`, `engine.studio.copilot.subject.flow`). The en and zh values of `engine.studio.access.banner`, `engine.studio.access.bannerPair` and their hover texts (`engine.studio.access.bannerTitle`, `bannerTitlePair`, `bannerTitleReadOnly`) are reworded: they say "app" where they said "package", and no longer name a 「Save」 button.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
* a stray `managedBy` (an old stored row) must not move the answer.
*
* Both sites are pinned: the routed page's badge, and the Studio Access
* pillar's kind chip (`studio`). They read one derivation, so they agree.
* pillar's kind chip (`studio`). They read one derivation, so they agree; the
* Studio chip words the package answer for the builder (objectstack#35018:
* "Included with the app"), the page keeps "Package".
*/

import '@testing-library/jest-dom/vitest';
// The source under test reaches these through dynamic imports: their first load is paid at collection.
import '@objectstack/formula';
import '@objectstack/lint';
import '@objectstack/spec/identity';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
Expand Down Expand Up @@ -88,17 +94,19 @@ async function renderWith(site: Site, extra: Record<string, unknown>, packageId?
}

const badgeText = () => screen.getByTestId('perm-provenance-badge').textContent;
/** The package answer as each site words it (objectstack#35018). */
const PACKAGE_TEXT: Record<Site, string> = { page: 'Package', studio: 'Included with the app' };

describe.each<Site>(['page', 'studio'])('the provenance badge (%s site)', (site) => {
it('a set opened under a packageId reads "Package"', async () => {
await renderWith(site, {}, 'com.example.sales');
expect(badgeText()).toBe('Package');
expect(badgeText()).toBe(PACKAGE_TEXT[site]);
});

it('a set whose code layer is a package artifact reads "Package"', async () => {
codeLayer = { _packageId: 'com.example.sales', name: 'sales_perms' };
await renderWith(site, {});
expect(badgeText()).toBe('Package');
expect(badgeText()).toBe(PACKAGE_TEXT[site]);
});

it('a set with neither reads "Added"', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,6 @@ export interface PermissionStudioChrome {
chips?: React.ReactNode;
/** Before History in the header's actions (the pillar's Explain access). */
actions?: React.ReactNode;
/**
* objectstack#34795 — the open app's name. The header's title reads
* "app · set label"; without it, the set's label alone.
*/
appLabel?: string;
/**
* objectstack#32774 — told, for the set `name` this editor shows, the
* package the clone door must name to copy it (`holdingPackage` of the
Expand Down Expand Up @@ -2314,11 +2309,12 @@ export function PermissionMatrixEditPage({ type, name, packageId, onDraftSaved,
const chipButton =
'inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2.5 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground';
const facetTab = chrome.tab === 'rls' || chrome.tab === 'tabs' || chrome.tab === 'admin' ? chrome.tab : null;
// objectstack#34795 — the title is "app · set label", in the title row
// alone, so it is not cut: the set's machine name is the title's tooltip,
// and the provenance, default and lock labels are the line under it.
const setLabel = headerLabel || name;
const studioTitle = chrome.appLabel ? `${chrome.appLabel} · ${setLabel}` : setLabel;
// objectstack#35018 — the title is the set's label alone: the app's name
// is the top bar's, so it is not repeated here (objectstack#34795 put it
// in front). The title row holds nothing else, so it is not cut; the
// set's machine name is the title's tooltip, and the provenance, default
// and lock labels are the line under it.
const studioTitle = headerLabel || name;
return (
<div className="flex h-full flex-col">
<StudioItemHeader
Expand All @@ -2330,8 +2326,10 @@ export function PermissionMatrixEditPage({ type, name, packageId, onDraftSaved,
note={
<span className="inline-flex items-center gap-1.5" data-testid="perm-studio-title-note">
{/* Same test id and the same answer as the page's badge. */}
{/* objectstack#35018 — in the builder's words: a set the app
brings reads 「随应用提供」, not the package term 「包内置」. */}
<span data-testid="perm-provenance-badge">
{shippedByPackage ? t('perm.badge.package') : t('perm.badge.custom')}
{shippedByPackage ? t('engine.studio.access.origin.app') : t('perm.badge.custom')}
</span>
{!!draft.isDefault && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ describe('Studio adds a field to a read-only base object as an extension in its
// Wanted 3 — it shows in the Form at once, and its inspector edits the extension.
expect(cardOf('Region')).toHaveLength(1);
const inspector = await screen.findByTestId('data-field-inspector');
expect(within(inspector).getByText('region__c')).toBeInTheDocument();
// objectstack#35018 — the header names the field by its label; its machine name is under 开发者信息.
expect(within(inspector.querySelector('header') as HTMLElement).getByText('Region')).toBeInTheDocument();
expect(within(within(inspector).getByTestId('field-developer-section')).getByDisplayValue('region__c')).toBeInTheDocument();
const label = within(inspector).getByTestId('field-label-input');
expect(label).toBeEnabled();
expect(within(inspector).queryByTestId('field-base-patch-only')).toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ describe('Data pillar Field properties on a read-only package — the reason rea
const apiName = within(body).getByDisplayValue('priority');
expect(apiName).toBeDisabled();
// objectstack#34794 — Remove is the header ⋯ menu's entry; the menu is disabled.
expect(within(body).getByTestId('field-more-menu')).toBeDisabled();
// objectstack#35018 — that menu sits in the rail's one header row now.
expect(within(rail.querySelector('header') as HTMLElement).getByTestId('field-more-menu')).toBeDisabled();
});

it('hovering the disabled controls opens a tooltip with the reason', async () => {
Expand All @@ -131,7 +132,7 @@ describe('Data pillar Field properties on a read-only package — the reason rea
const user = userEvent.setup();
const rail = await openRail(true);
const body = rail.querySelector('[data-disabled-reason]') as HTMLElement;
// The rail header's own close button (the inspector inside has one too).
// The rail header's close button, the rail's only one (objectstack#35018).
within(rail.querySelector('header') as HTMLElement).getByRole('button', { name: L('engine.studio.close') }).focus();
await user.tab();
expect(body).toHaveFocus();
Expand All @@ -146,3 +147,45 @@ describe('Data pillar Field properties on a read-only package — the reason rea
expect(screen.queryByText(REASON)).toBeNull();
});
});

/** The text a reader sees in `root`: text in a `hidden` subtree (a collapsed section) is left out. */
function visibleText(root: HTMLElement): string {
const parts: string[] = [];
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
acceptNode: (node) => (node.parentElement?.closest('[hidden]') ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT),
});
for (let node = walker.nextNode(); node; node = walker.nextNode()) parts.push(node.textContent ?? '');
return parts.join('');
}

// objectstack#35018 — the Field properties rail draws ONE header row: the
// field's label as its title and ONE close button; the field's machine name is
// not on show until 开发者信息 is opened.
describe('Data pillar Field properties: one header row (objectstack#35018)', () => {
it('one header, one close button, titled by the field label', async () => {
const rail = await openRail(false);
const closes = within(rail).getAllByRole('button', { name: /^close$/i });
expect(closes).toHaveLength(1);
expect(rail.querySelectorAll('header')).toHaveLength(1);
const header = rail.querySelector('header') as HTMLElement;
expect(header).toContainElement(closes[0]);
expect(header).toHaveTextContent(L('engine.studio.data.fieldProps'));
expect(header).toHaveTextContent('Priority');
// The inspector draws no header strip of its own inside the rail.
expect(within(rail).getByTestId('inspector-shell-hosted')).toBeInTheDocument();
// Its actions (the ⋯ menu) are in the one header row.
expect(within(header).getByTestId('field-more-menu')).toBeInTheDocument();
});

it('the machine name is not on show by default; 开发者信息 holds it', async () => {
const rail = await openRail(false);
expect(visibleText(rail)).not.toContain('priority');
// CONTROL: the scan reads the rendered rail — the label is in it, and the
// collapsed developer section holds the API name input.
expect(visibleText(rail)).toContain('Priority');
const developer = within(rail).getByTestId('field-developer-section');
expect(within(developer).getByDisplayValue('priority')).not.toBeVisible();
fireEvent.click(within(developer).getByTestId('field-developer-toggle'));
expect(within(developer).getByDisplayValue('priority')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('the header’s provenance chip follows the rail’s mark (objectstack#
await copyOpen();
await waitFor(() => expect(railMarkOf('My contributor')).toBe('added'), { timeout: 8000 });
expect(chip()).toHaveTextContent(t('perm.badge.custom', 'en'));
expect(chip()).not.toHaveTextContent(t('perm.badge.package', 'en'));
expect(chip()).not.toHaveTextContent(t('engine.studio.access.origin.app', 'en'));
});

it('a set created in the pair: Custom in the header, Added in the rail', async () => {
Expand All @@ -320,6 +320,6 @@ describe('the header’s provenance chip follows the rail’s mark (objectstack#
// The read has answered: the copy's row is marked, the base set's is not.
await waitFor(() => expect(railMarkOf('My contributor')).toBe('added'), { timeout: 8000 });
expect(railMarkOf('Contributor')).toBeNull();
expect(chip()).toHaveTextContent(t('perm.badge.package', 'en'));
expect(chip()).toHaveTextContent(t('engine.studio.access.origin.app', 'en'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ describe('Access pillar — the open set is a header and five tabs (objectui#124
// objectstack#34795 — the api name is the title's tooltip, not a chip.
expect(header().getByRole('heading', { level: 1 })).toHaveAttribute('title', 'guest_portal');
expect(header().queryByText('guest_portal')).toBeNull();
expect(header().getByTestId('perm-provenance-badge')).toHaveTextContent(en('perm.badge.package'));
// objectstack#35018 — the Studio note reads the builder's words, not the package term.
expect(header().getByTestId('perm-provenance-badge')).toHaveTextContent(en('engine.studio.access.origin.app'));
expect(header().getByText('1 object granted · 0 field overrides')).toBeInTheDocument();
expect(header().getByRole('button', { name: en('engine.studio.access.explain.open') })).toBeInTheDocument();
expect(header().getByRole('button', { name: en('engine.edit.history') })).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* • an accepted member-access suggestion reads as one sentence, and its
* action reads 「取消默认授予」 while it makes the same call 撤销 made
* (the dismiss door on the accepted row, ADR-0090 D5/D9 unchanged);
* • the open set's title is "app · set label"; the set's machine name is
* • the open set's title is the set's label alone (objectstack#35018: the
* app's name is the top bar's, not repeated); the set's machine name is
* the title's tooltip, not page text, and the rail row's too;
* • every object row draws 「全选 · 只读 · 清空」 (and the CRUD arm as a
* fourth) without a hover, and each writes what All / R / None / CRUD
Expand Down Expand Up @@ -127,7 +128,7 @@ async function mountZh(withSuggestion = true) {
render(
<I18nProvider instance={i18n}>
<MemoryRouter>
<AccessPillar packageId={PKG} packageLabel="会议纪要" />
<AccessPillar packageId={PKG} />
</MemoryRouter>
</I18nProvider>,
);
Expand Down Expand Up @@ -169,20 +170,33 @@ describe('objectstack#34795 — the accepted suggestion reads as one business se
});

describe('objectstack#34795 — the open set: title, tooltip, terms', () => {
it('the title reads "app · set label"; the machine name is its tooltip and the rail row tooltip', async () => {
it('the title reads the set label alone — no app name; the machine name is its tooltip and the rail row tooltip', async () => {
api.list.mockResolvedValue([ACCEPTED]);
await mountZh();
const title = within(screen.getByTestId('access-item-header')).getByTestId('perm-studio-title');
expect(title).toHaveTextContent('会议纪要 · 组织成员');
// objectstack#35018 — the app's name is the top bar's; the title is the set's label, whole.
expect(title.textContent).toBe('组织成员');
expect(screen.getByTestId('access-item-header').textContent).not.toContain('会议纪要');
// CONTROL: the machine name stays reachable — on the title's tooltip and the rail row's.
expect(title).toHaveAttribute('title', SET);
expect(screen.getByTestId(`access-rail-set-${SET}`)).toHaveAttribute('title', SET);
// The three labels are the line under the title.
const note = screen.getByTestId('perm-studio-title-note');
expect(note).toHaveTextContent(zh('perm.badge.package'));
expect(note).toHaveTextContent(zh('engine.studio.access.origin.app'));
expect(note).toHaveTextContent(zh('perm.badge.default'));
});

it('objectstack#35018 — the note and the tab row say it in the builder words: no 包内置, no 本包', async () => {
api.list.mockResolvedValue([ACCEPTED]);
await mountZh();
const header = screen.getByTestId('access-item-header');
expect(within(header).getByTestId('perm-studio-title-note')).toHaveTextContent(
`${zh('engine.studio.access.origin.app')}·${zh('perm.badge.default')}`,
);
expect(header.textContent).not.toContain('包内置');
expect(header.textContent).not.toContain('本包');
});

it('the tabs read in the card words', async () => {
api.list.mockResolvedValue([]);
await mountZh(false);
Expand All @@ -208,7 +222,7 @@ describe('objectstack#34795 — the open set: title, tooltip, terms', () => {
expect(text).not.toContain('CRUD');
// CONTROL: the scan reads the rendered page — the sentence and the title are in it.
expect(text).toContain('所有成员默认拥有这个权限集');
expect(text).toContain('会议纪要 · 组织成员');
expect(text).toContain('组织成员');
expect(text).toContain('谁能看到哪些记录');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ window.matchMedia = ((query: string) => ({
disconnect() {}
};

const SET = 'b2r4_member_access';
const FLOW = 'b2r4_new_meeting_alert';

const NAV = [
{ id: 'nav_dash', type: 'dashboard', label: '客户仪表盘', dashboardName: 'b2r4_customer_dashboard' },
// A leaf the author never labelled.
Expand Down Expand Up @@ -157,6 +160,9 @@ beforeEach(() => {
if (path.startsWith('/api/v1/ai/conversations/')) return json({ id: 'conv_8219', messages: [] });
if (path === '/api/v1/meta/_drafts') return json([]);
if (path === '/api/v1/meta/app') return json([{ name: 'acme_app', label: '客户管理' }]);
// objectstack#35018 — the Access and Automations rails' items.
if (path === '/api/v1/meta/permission') return json([{ name: SET, label: '组织成员', isDefault: true }]);
if (path === '/api/v1/meta/flow') return json([{ name: FLOW, label: '新会议提醒', type: 'autolaunched' }]);
if (path === '/api/v1/meta/app/acme_app/layers') {
return json({
code: null,
Expand All @@ -177,10 +183,10 @@ afterEach(() => {
vi.unstubAllGlobals();
});

function renderStudio() {
function renderStudio(entry = `/studio/${PACKAGE_ID}/interfaces`) {
return render(
<I18nProvider config={{ defaultLanguage: 'zh', detectBrowserLanguage: false }}>
<MemoryRouter initialEntries={[`/studio/${PACKAGE_ID}/interfaces`]}>
<MemoryRouter initialEntries={[entry]}>
<Routes>
<Route path="/studio/:packageId/:tab" element={<StudioDesignSurface />} />
</Routes>
Expand Down Expand Up @@ -222,3 +228,29 @@ describe('Studio copilot chip reads the selected item label (objectui#8219 item
);
});
});

// objectstack#35018 — the Access and Automations rails report their open
// item's label too: the chip reads the rail's word and the label, as the Data
// rail's 「会议 · 记录」 does — never the type word (`permission` / `flow`) or
// the machine name, which stay on the tooltip and in the agent's data.
describe('objectstack#35018 — 正在看 on the Access and Automations rails reads a label', () => {
it('Access: 「正在看:权限 · 组织成员」, no type word, no machine name', async () => {
renderStudio(`/studio/${PACKAGE_ID}/access?surface=permission:${SET}`);
await waitFor(() => expect(chip.surfaceContextLabel).toBe('正在看:权限 · 组织成员'), { timeout: 6000 });
expect(String(chip.surfaceContextLabel)).not.toContain('permission');
expect(String(chip.surfaceContextLabel)).not.toContain(SET);
// CONTROL: the identity stays reachable on the tooltip, and the agent's data is the URL's.
expect(chip.surfaceContextTitle).toBe(`permission · ${SET}`);
expect(JSON.stringify(agentSurface())).toBe(
JSON.stringify({ pillar: 'access', artifact: { type: 'permission', name: SET } }),
);
});

it('Automations: 「正在看:流程 · 新会议提醒」, no type word, no machine name', async () => {
renderStudio(`/studio/${PACKAGE_ID}/automations?surface=flow:${FLOW}`);
await waitFor(() => expect(chip.surfaceContextLabel).toBe('正在看:流程 · 新会议提醒'), { timeout: 6000 });
expect(String(chip.surfaceContextLabel)).not.toContain('flow');
expect(String(chip.surfaceContextLabel)).not.toContain(FLOW);
expect(chip.surfaceContextTitle).toBe(`flow · ${FLOW}`);
});
});
Loading
Loading