Skip to content

Commit 1ae8358

Browse files
committed
Merge origin/main into claude/project-thread-uv3zpb
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jQpUMdR7QmHKTFR8iB
2 parents 6674886 + da6f0ce commit 1ae8358

8 files changed

Lines changed: 552 additions & 33 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(studio): "New similar" on a read-only base's permission set in the Access pillar, opening the copy where the clone door landed it
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A customer's own permission set is a new set in the package that holds their changes (ADR-0146 D6). Since the clone door lands a copy of a read-only package X's set in X's paired `X.custom`, Studio can offer that gesture where the base is designed.
12+
13+
- **New similar in Studio.** In the Access pillar of a read-only package, the open permission set offers "New similar". It asks for a machine name and a label (the same dialog as Setup's catalog) and posts exactly `{ name, label }` to `POST /security/permission-sets/:name/clone`. The client sends no package and no facet: the server decides where the copy lands.
14+
- **The copy opens where the answer says.** The door's answer names the package the copy was saved in. The pillar opens that package's Access pillar with the copy selected (`/studio/<package>/access?surface=permission:<copy>`), and shows the server's notice there as sent. An answer that names no package (absent or `null`) or no copy says so, and opens nothing.
15+
- **Refusals and gates.** A refusal (400, 403, 404, 409) is shown in the server's words in the dialog. Under a walled posture, or for a caller without `manage_metadata`, the action is drawn disabled with the console's own sentence for why. The base's sets stay read-only, and no override gesture is drawn on a permission set.
16+
- **One label.** The action reads "New similar" (zh: 新建类似) on Setup's catalog too, and the guidance strings that name it say the server saves the copy in the package that holds your changes. Setup's post-clone hop is unchanged.
17+
- **Access pillar keyed by package.** Like its sibling pillars, it remounts when the package changes, so opening the copy in another package's pillar no longer keeps the base's open set.

‎ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.cloneToCustomize.test.tsx‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

33
/**
4-
* "Clone to customize" — the locked permission matrix's primary action
4+
* "New similar" (formerly "Clone to customize") — the locked permission matrix's primary action
55
* (objectui#5987, the UI half of objectstack#11513), calling the server's
66
* clone door (objectui#7611, PR-4).
77
*
@@ -15,7 +15,7 @@
1515
* whole definition under a new name, "objectui calling it with a name and a
1616
* label". This suite pins that the editor:
1717
*
18-
* 1. renders "Clone to customize" as the locked editor's PRIMARY action, in
18+
* 1. renders "New similar" as the locked editor's PRIMARY action, in
1919
* the slot Save would occupy, and names cloning FIRST in its guidance
2020
* (en-US and zh-CN);
2121
* 2. asks for a new name and label, and POSTs exactly `{ name, label }` to
@@ -250,8 +250,10 @@ async function renderPlain(props?: { packageId?: string; readOnly?: boolean; emb
250250
await screen.findByText('Account');
251251
}
252252

253-
const CLONE_EN = /^Clone to customize$/;
254-
const CLONE_ZH = /^克隆后自定义$/;
253+
// objectstack#28573 (ADR-0146 D6) — the action reads "New similar" on Setup's
254+
// catalog as in Studio's Access pillar.
255+
const CLONE_EN = /^New similar$/;
256+
const CLONE_ZH = /^新建类似$/;
255257
const cloneButtons = () => screen.queryAllByRole('button', { name: CLONE_EN });
256258
const saveButton = () => screen.queryByRole('button', { name: /^Save$/ });
257259
const createCopy = () => screen.getByRole('button', { name: /^Create copy$/ });
@@ -284,24 +286,24 @@ afterEach(() => {
284286

285287
/* ────────────────────────────────────────────────────────────────────────── */
286288

287-
describe('PermissionMatrixEditPage — the locked editor offers Clone to customize (objectui#5987)', () => {
288-
it('renders "Clone to customize" as the primary action where Save would be, and no Save', async () => {
289+
describe('PermissionMatrixEditPage — the locked editor offers New similar (objectui#5987)', () => {
290+
it('renders "New similar" as the primary action where Save would be, and no Save', async () => {
289291
await renderRouted();
290292

291293
expect(saveButton()).toBeNull();
292294
const [clone] = cloneButtons();
293295
expect(clone).toBeInTheDocument();
294296
expect(clone).toBeEnabled();
295297
// The visible locked-state guidance names cloning.
296-
expect(screen.getByRole('note')).toHaveTextContent(/Clone to customize/);
298+
expect(screen.getByRole('note')).toHaveTextContent(/New similar/);
297299
});
298300

299301
it('the artifact badge hint names cloning FIRST; the former remedies follow as secondary routes', async () => {
300302
await renderRouted();
301303

302304
const badge = screen.getByText(/provided by a code package/);
303305
const hint = badge.getAttribute('title') ?? '';
304-
const clone = hint.indexOf('Clone to customize');
306+
const clone = hint.indexOf('New similar');
305307
expect(clone).toBeGreaterThan(-1);
306308
for (const secondary of ['redeploy', 'new runtime set']) {
307309
const at = hint.indexOf(secondary);
@@ -325,16 +327,16 @@ describe('PermissionMatrixEditPage — the locked editor offers Clone to customi
325327

326328
expect(screen.getByRole('button', { name: CLONE_ZH })).toBeInTheDocument();
327329
expect(cloneButtons()).toHaveLength(0);
328-
expect(screen.getByRole('note')).toHaveTextContent(/克隆后自定义/);
330+
expect(screen.getByRole('note')).toHaveTextContent(/新建类似/);
329331
// Exact: the guidance note above also says 由代码包提供.
330332
const badge = screen.getByText('只读(该权限集由代码包提供)', { exact: true });
331333
const hint = badge.getAttribute('title') ?? '';
332-
expect(hint.indexOf('克隆后自定义')).toBeGreaterThan(-1);
333-
expect(hint.indexOf('克隆后自定义')).toBeLessThan(hint.indexOf('重新部署'));
334+
expect(hint.indexOf('新建类似')).toBeGreaterThan(-1);
335+
expect(hint.indexOf('新建类似')).toBeLessThan(hint.indexOf('重新部署'));
334336
});
335337
});
336338

337-
describe('PermissionMatrixEditPage — Clone to customize calls the clone door with a name and a label (objectui#7611)', () => {
339+
describe('PermissionMatrixEditPage — New similar calls the clone door with a name and a label (objectui#7611)', () => {
338340
it('POSTs exactly { name, label } to the door for THIS set, and nothing else', async () => {
339341
await renderRouted();
340342
fireEvent.click(cloneButtons()[0]);
@@ -504,7 +506,7 @@ describe('PermissionMatrixEditPage — a save the server refuses as a packaged s
504506

505507
const alert = await screen.findByRole('alert');
506508
expect(alert).toHaveTextContent(/Save refused \(403 not_overridable\)/);
507-
expect(alert).toHaveTextContent(/Clone to customize instead/);
509+
expect(alert).toHaveTextContent(/New similar instead/);
508510
expect(within(alert).getByRole('button', { name: CLONE_EN })).toBeEnabled();
509511
// The server's own sentence is kept for diagnosis, not shown alone.
510512
expect(within(alert).getByText(SERVER_TEXT)).toBeInTheDocument();

‎ui/packages/app-shell/src/views/metadata-admin/packagedItemWriteGate-12169.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ describe('a hatch-elevated type: its PACKAGED item is read-only on every gate (o
244244
expect(screen.queryByRole('button', { name: /^Save$/ })).toBeNull();
245245
for (const box of screen.getAllByRole('checkbox')) expect(box).toBeDisabled();
246246
expect(screen.getByText(ARTIFACT_CAPTION)).toBeInTheDocument();
247-
expect(screen.getAllByRole('button', { name: /Clone to customize/ }).length).toBeGreaterThan(0);
247+
expect(screen.getAllByRole('button', { name: /New similar/ }).length).toBeGreaterThan(0);
248248
});
249249

250250
it('the badge claims no more: its tooltip says the hatch never opens an item a package ships', async () => {

‎ui/packages/app-shell/src/views/metadata-admin/permission-set-clone.ts‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111
* (objectstack#22881, ADR-0126 §7.1). The server reads the source set from the
1212
* security catalog, copies its WHOLE definition under the new name, drops the
1313
* keys it declares (the provenance envelope, `packageId`, `managedBy`,
14-
* `protection`, `adminScope`, `isDefault`), and saves the copy as an ordinary
15-
* permission set authored in this environment. It answers `{ permissionSet,
16-
* notice }`: the saved copy, and a sentence naming what was not copied.
14+
* `protection`, `adminScope`, `isDefault`), and saves the copy in the package
15+
* it decides (ADR-0146 D6, "new similar"): a set a read-only package X ships
16+
* lands in X's paired `<X>.custom`, a set in a writable package in that
17+
* package, an environment-authored set in no package. It answers
18+
* `{ permissionSet, package, notice }`: the saved copy, the package it landed
19+
* in (`null` for environment-wide), and a sentence saying where it went and
20+
* what was not copied.
21+
*
22+
* ⛔ The client never names the package. The body's optional `package` key is
23+
* the server's to default, and where the copy lands is read back off the
24+
* answer, never derived here from the source's package.
1725
*
1826
* So this module sends a name and a label and nothing else (the seat's ruling
1927
* on objectui#7611, 6097763840: "objectui calling it with a name and a label").
@@ -44,13 +52,21 @@ import { envelopeData, envelopeRefused } from '../setup/packagedFlows.js';
4452
export interface PermissionSetCloned {
4553
/** The copy's machine name, as the server saved it. */
4654
name: string;
55+
/**
56+
* The package the server saved the copy in: its id, `null` when the answer
57+
* says environment-wide, and `undefined` when the answer carries no
58+
* `package` at all (a server older than the "new similar" door). Read as
59+
* sent; a caller that opens the copy opens it only where this names.
60+
*/
61+
package?: string | null;
4762
/** The server's sentence on what was not copied; empty when it sent none. */
4863
notice: string;
4964
}
5065

5166
/**
5267
* Clone `source` through the door. Resolves to the saved copy's name (empty
53-
* when the answer names none) and the server's notice. A refusal rejects with
68+
* when the answer names none), the package it landed in, and the server's
69+
* notice. A refusal rejects with
5470
* the server's own message; `fallback` words one only when the answer has none.
5571
*/
5672
export async function clonePermissionSet(
@@ -70,8 +86,10 @@ export async function clonePermissionSet(
7086
if (!res.ok || envelopeRefused(json)) throw new Error(actionErrorDetail(json, fallback(res.status)));
7187
const data = envelopeData(json);
7288
const created = (data.permissionSet as { name?: unknown } | null | undefined)?.name;
89+
const landed = data.package;
7390
return {
7491
name: typeof created === 'string' ? created : '',
92+
package: typeof landed === 'string' && landed !== '' ? landed : landed === null ? null : undefined,
7593
notice: typeof data.notice === 'string' ? data.notice : '',
7694
};
7795
}

0 commit comments

Comments
 (0)