Skip to content

Commit 5c2826b

Browse files
committed
wip(ui): editor member threading, changeset
1 parent 50e5a03 commit 5c2826b

2 files changed

Lines changed: 21 additions & 27 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/data-objectstack': patch
3+
---
4+
5+
fix(data-objectstack): the metadata client's layered read, item and draft reads, publish and reset name the bundle member they address
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`MetadataClient.layered()`, `get()`, `getDraft()`, `publish()` and `reset()` take an optional `member` and send it as `?member=`, the selector the by-name doors read for a metadata type whose identity is a pair (today only `email_template`, `(name, locale)`). Omitted, every call sends exactly the URL it sent before and the door addresses the canonical member. The parameter is never sent empty.
11+
12+
`getDraft()` with a `member` skips the draft read when the pending-drafts ledger lists that name only as another member's draft.
13+
14+
Setup's metadata list now shows an email template's locale in its own column and links each row to its own member (`?member=LOCALE`), and the editor passes that member to its layered and draft reads and to its publish, reset and discard, so each language of a template opens and is edited on its own.

‎ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx‎

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ import {
126126
import { readDraftForSave, useDraftSaveGuard } from './DraftConflictDialog.js';
127127
import {
128128
BUNDLE_MEMBER_PARAM,
129-
bundleMemberOf,
130129
getMetadataResource,
131130
resolveResourceConfig,
132131
listAnchorsFor,
@@ -1175,7 +1174,10 @@ function MetadataResourceEditPageImpl({
11751174
setLoadFailed(false);
11761175
(async () => {
11771176
try {
1178-
const scope = { ...(ownerPackageId ? { packageId: ownerPackageId } : {}), ...memberScope };
1177+
const scope = {
1178+
...(ownerPackageId ? { packageId: ownerPackageId } : {}),
1179+
...(bundleMember ? { member: bundleMember } : {}),
1180+
};
11791181
// objectui#11773 — the draft is read at the address `doSave` writes
11801182
// (`readActivePackageBinding`, the folded `?package=`), so the version
11811183
// it serves is the one that save compares against.
@@ -1795,22 +1797,13 @@ function MetadataResourceEditPageImpl({
17951797
// Refresh layered + draft state after save — scope to the same package
17961798
// as the initial load (ADR-0048) so a same-name collision re-reads this
17971799
// package's own row, not another's.
1798-
// objectstack#26649 — the save is addressed by its body's own member, so
1799-
// the re-read follows the member it wrote, which is the URL's unless the
1800-
// author changed the body's member field.
1801-
const savedMember = config.bundleMemberField
1802-
? bundleMemberOf(itemToSave as Record<string, unknown>, config.bundleMemberField)
1803-
: bundleMember;
1804-
const refreshScope = {
1805-
...(ownerPackageId ? { packageId: ownerPackageId } : {}),
1806-
...(savedMember ? { member: savedMember } : {}),
1807-
};
1800+
const refreshScope = { ...(ownerPackageId ? { packageId: ownerPackageId } : {}), ...memberScope };
18081801
// objectui#11799 — this save went into a draft, which makes no layer. An
18091802
// item this page loaded with no layer still has none, and an item it
18101803
// just created has never been published (the page then navigates to the
18111804
// item, whose load reads it afresh). `/layers` answers 404 for both, so
18121805
// it is not asked: the answer already held stands.
1813-
const layerless = createMode || (savedName === name && savedMember === bundleMember && holdsNoLayer(layered));
1806+
const layerless = createMode || (savedName === name && holdsNoLayer(layered));
18141807
const [lay, draftResp] = await Promise.all([
18151808
layerless ? layered : client.layered<any>(type, savedName, refreshScope),
18161809
client.getDraft<any>(type, savedName, refreshScope).catch(() => null),
@@ -1853,23 +1846,10 @@ function MetadataResourceEditPageImpl({
18531846
// author was working in. Without this the param is dropped and the
18541847
// editor falls back to the user's default package, where the freshly
18551848
// saved draft doesn't exist — so it reloads a blank form.
1856-
// objectstack#26649 — and the member it created, so the page that
1857-
// opens next reads that member and not the canonical one.
1858-
const next = new URLSearchParams(searchParams);
1859-
if (savedMember) next.set(BUNDLE_MEMBER_PARAM, savedMember);
1860-
else next.delete(BUNDLE_MEMBER_PARAM);
1861-
const qs = next.toString();
1849+
const qs = searchParams.toString();
18621850
navigate(`../${encodeURIComponent(savedName)}${qs ? `?${qs}` : ''}`, {
18631851
relative: 'path',
18641852
});
1865-
} else if (savedMember !== bundleMember) {
1866-
// objectstack#26649 — the author moved the body's member field: the
1867-
// save wrote ANOTHER member, so the page now addresses that one, and
1868-
// its next publish, reset or discard cannot reach the member it left.
1869-
const next = new URLSearchParams(searchParams);
1870-
if (savedMember) next.set(BUNDLE_MEMBER_PARAM, savedMember);
1871-
else next.delete(BUNDLE_MEMBER_PARAM);
1872-
setSearchParams(next, { replace: true });
18731853
}
18741854
} catch (err: any) {
18751855
// `err` is the client's parsed `MetadataError`: `MetadataClient`'s

0 commit comments

Comments
 (0)