Skip to content

Commit c1b35c3

Browse files
feat(console): Save to this view on a shared view asks once, then saves and publishes it; layout and row colour join the list draft (#35955 PR 2) (#36123)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuG6LywHEovAnGuZpiKQEc2W)_ repo:objectstack#1 · os-sales · session_01L6bhgWyeXh2Keywo6oK1Nn Part of #35955 (PR 2 of three: PR 1 #36026 made a list change a draft; PR 3 retires the server-side list preference and runs in parallel. The card stays open.) Clause-②: yes (widening) — five new `console.objectView.draft.*` keys in every `@object-ui/i18n` locale pack (`saveToViewConfirmTitle`, `saveToViewConfirm`, `saveToViewConfirmButton`, `savedForEveryone`, `pendingDraft`); `@object-ui/plugin-list` `ListView` gains the optional host prop `onRowColorChange` and two optional `viewDefaults` members, `viewType` and `rowColor`; nothing removed or renamed Metadata-protocol: none ## 维护者速读 - 共享视图上,能改这个视图的人(管理员,且视图所在的包接受保存)在「保存 ▾」里也看到「保存到这个视图」:先问一次「所有用这个视图的人都会看到」,确认后存并立刻发布,提示「已保存,所有人可见」。选项菜单里的「保存」同一条路。 - 这个视图已有没发布的修改(谁存的都算)时什么都不写,提示先去视图设置里发布或放弃;不替任何人发布。保存人的行高、列宽不会写进共享视图。 - 显示面板的「布局」「行颜色」现在也是草稿:点开记录再回来还在,两条「保存」都会存进去,「放弃」还原成视图自己的。 ## What changes **Save to this view on a shared view** (`ObjectView.tsx`, `objectViewViewCrud.tsx`, `runtime-metadata-persistence.ts`) - Offered when `canSaveToSharedView`: not an environment list, not a personal view, and the same test the footer calculation's pick uses (`isAdmin && !activeViewPackageRefusesSaves && isSavedViewId(savedViews, id)`), so a read-only package's view and the fallback tab never get it. A personal view keeps its own save. The phone / narrow `Save ▾` is the same component; the options menu's Save calls the same handler. - It asks once through `confirmHandler` (`saveToViewConfirmTitle` / `saveToViewConfirm` naming the view / `saveToViewConfirmButton`, cancel `console.objectView.cancel`). - The body is the view's own config with the draft laid over it (`layListStateOverView`, split out of `buildPersonalViewConfig`), then `buildViewConfigSaveBody`, the body the view settings panel saves. The reader's row height is left out (`rowHeight: undefined` on the laid preference, F5); column widths never travel. - New `saveAndPublishRuntimeMetadata(type, name, body, ctx)`: a draft write with the first-write pin (`{ mode: 'draft', ifNoneMatch: '*' }`), then `publish`. A `409 METADATA_CONFLICT` on the write means a draft is already pending; it resolves `'pending-draft'` and nothing is written or published. A publish the server refuses discards the draft this save wrote (`reset(type, name, { state: 'draft' })`) and rethrows. Caches are invalidated and the draft ledger announced on both paths. - `handleViewSaveAndPublish` shows the saved body at once (`setViewDraft`) and lets `handleDraftBarChange` drop it when the saved-views re-read lands (#36031), so the list does not flash the old sort. On `'published'` the list draft is dropped (`handleResetView`) and "Saved, visible to everyone" is toasted; on `'pending-draft'` the draft stays and `pendingDraft` is toasted. - Using the server's pin instead of a client read of the draft closes the read-then-write window the premise read named (P4). The window left is between this save's draft write and its publish: the view settings panel writes its draft without the pin, so a settings save landing in those milliseconds would overwrite this draft and be published with it. A known edge, not closed here: card #36137. **Layout and row colour join the draft** (`objectViewListRenderer.tsx`, `ListView.tsx`, `personalViews.ts`) - The renderer wires the published `onViewChange` to `listDraft.patch({ viewType })` and the new `onRowColorChange` to `listDraft.patch({ rowColor })`; picking the view's own value drops the entry. The draft's values go to `ListView` as `schema.viewType` / `schema.rowColor`, and the view's own through `viewDefaults.viewType` / `viewDefaults.rowColor`, so the `layout` / `rowColor` parts and the Display count still judge against the view after a remount. - `ListView`: `onRowColorChange` fires on a pick in the row colour panel (the rule in force) and on Clear (`null`), never at mount or for a reset. Each new `viewDefaults` member is read only when its key is present; without them nothing changes. - Both saves read them: `PersonalViewListState.display` carries `viewType` and `rowColor`; a layout switch retypes the view and fills the kanban / gallery mirror from the saved columns when the block lacks one (`IN_PLACE_COLUMN_MIRRORS`). Save as my view builds from `listDraft.draft.viewType ?? activeView.type` and passes the row colour. **i18n**: the five keys in all ten hand-written packs; zh-Hant regenerated (`pnpm gen:zh-hant`). **Docs**: `ui/packages/plugin-list/README.md` (new host-props section), `content/docs/ui/views.mdx` (§ "A user's list state never writes the view"), `docs/qa/platform-checklist/areas/records-forms.json` `records-forms.adhoc-filter-sort-builder` revision 14 (steps[8], acceptance[5], negative[4]; not loosened). ## Tests - New `ObjectView.sharedViewSave-35955.test.tsx` (8): confirm, then `save(... { mode: 'draft', ifNoneMatch: '*' })` then `publish`, body carries the draft sort and the view's own row height `short` while the reader's stored one is `tall`; cancel writes nothing; pending draft (409 `METADATA_CONFLICT`) writes nothing more and toasts; refused publish resets the draft; a read-only package's view is not offered; layout and row colour laid into the schema and `viewDefaults` and kept across a remount; picking the view's own value drops it; the save retypes to kanban with its columns mirror and the row colour. - `runtime-metadata-persistence.test.ts` (+4): published; pending-draft; a `409` with another code (`DESTRUCTIVE_CHANGE`) rethrows; refused publish resets and rethrows. - `ListView.personalization-28950.test.tsx` (+4): the `rowColor` part judged against `viewDefaults`, a control without them, `onRowColorChange` on pick and on Clear (`null`), and no call at mount. - `ObjectView.personalViews-29635.test.tsx` (+1): the draft row colour reaches the personal save and Save as my view. - L1-b S1 (`ObjectView.sharedViewSave-35955.test.tsx` +3, `ObjectView.personalViews-29635.test.tsx` +2): the confirm and Save as my view's default name read the view's tab label (`listLabel`, `viewTabLabel`), with a view that has no label and one whose label is a locale map (plus a plain-label control on the confirm). Ablated: the raw label turns the locale-map confirm case and both copy-name cases red. In the shared-view harness a stored view with no label already arrives named by its name, so that case is a pin, not a discriminator. - `ObjectView.listUrlState-11860.test.tsx` (+2, G2): a reload whose address was rewritten before the seed applies its `uf_*` state; a reload on a record page then Back applies the list entry's `uf_*` state. Pins of current behaviour, no behaviour change. ## Acceptance notes - P3 (seat 14:28Z): any pending draft refuses, the saver's own earlier draft too; the server does not record a draft's author. - F5: a shared save never carries the saver's row height or column widths; a personal save still carries the row height, as on main. - The view settings panel and the footer calculation still save a shared view as a draft that the view settings publish (ruling 7045525672 unchanged). - Not touched: where column widths, row height and the view order are stored (PR 3). - Landing order with #36133 (PR 3): both bump `records-forms.adhoc-filter-sort-builder` to revision 14 and edit the same section of `content/docs/ui/views.mdx`. Whichever lands second renumbers to 15 and merges the two history entries. - L1-b N1 taken: the pending-draft test is `isDraftVersionConflict` from `DraftConflictDialog.tsx`, the predicate the other draft-door callers use. ## Verification CI and local runs at head `da8b797b`; the S1 commit's tests and type check at `0ada6797`. - CI: every check green (54 passed, 10 skipped by path), mergeable clean. The first head (`433d7c02`) went red on four pins, each fixed in its own commit: the `rowColor` firing control in `object-view-unmirrored-keys-7779.test.ts` now reads `const viewOwnRowColor = viewDef.rowColor ?? listSchema.rowColor;` (the relay reads the view's own rule once, so the draft's can lie over it); the de quote-pair count in `de-quote-pairing-3876.test.ts` goes 120 to 121 for `saveToViewConfirm` („{{name}}“); three `viewDefaults` equalities in `ObjectView.userListState-12418.test.tsx` gain `viewType`; a checker narrowing in the new test is read through a cast. No pin was loosened: each asserts the same thing at the new spelling. - Local (`pnpm --dir ui exec vitest run` over `app-shell/src/views/ObjectView*`, `runtime-metadata*`, `personalViews*`, `listDraft*`, `plugin-list/src/__tests__/ListView*`): 237 files, 2290 tests; the only 3 failures were the `viewDefaults` equalities above, 40/40 after the fix. `packages/i18n`: 105 files, 1962 passed. `packages/types` 7779: 236/236. - `pnpm --dir ui/packages/app-shell run type-check` exit 0; `pnpm --dir ui/packages/plugin-list run type-check` exit 0 (both include `tsconfig.test.json`). - eslint on every changed `ui/` source and test: 0 errors. `check:i18n-keys`, `check:i18n-drift`, `check:control-bytes`, `check:vi-mock-specifiers`, `check:vi-mock-override-shape`, `check:metadata-write-doors`, `check:changeset-claims`, `check:pending-changeset-literals`, `check:readme-exports`, `check:new-line-citations` exit 0; `node scripts/check-platform-checklist.mjs` OK. - `node scripts/pm/overlap-check.mjs --base=origin/main`: clean against main `dc10b3b4` and open #36114, #36105, #36096, #36024. - Clause-② measured on the built `ui/packages/plugin-list/dist/ListView.d.ts`: `onRowColorChange` and the two `viewDefaults` members are added, optional; no member removed or narrowed. The seat runs the declaration L2. - Browser, at `0ada6797` (showcase `objectstack dev`, the `ui/` HMR console pointed at it; checklist `records-forms.adhoc-filter-sort-builder` steps[8]), on a shared view the admin created and published (`showcase_task.team_tasks`, package `com.example.showcase.custom`): - admin, sort by Priority: Save offers "Save to this view"; the confirm reads "Everyone who uses “Team tasks” will see these changes."; confirming sends `PUT /api/v1/meta/view/showcase_task.team_tasks?mode=draft` with `If-None-Match: *` (200) then `POST …/publish` (200) and toasts "Saved, visible to everyone"; Discard and Save go. - a second reader who is not an administrator (`phone.demo@example.com`) opens the view sorted by Priority, and after a sort of their own is offered only "Save as my view". Control: on the read-only package's `showcase_task.in_progress` the admin is offered only "Save as my view" too. - with a draft of the view already pending, the admin's confirmed save gets `409` on the pinned `PUT`, sends no publish, toasts the pending-draft hint and keeps Discard and Save; the pending draft is still there afterwards and the live view unchanged. - Not driven in the browser: the row height (F5) and the layout and row colour round trip, pinned in the unit tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgWyeXh2Keywo6oK1Nn --- _Generated by [Claude Code](https://claude.ai/code)_ <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgWyeXh2Keywo6oK1Nn --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 92e0475 commit c1b35c3

30 files changed

Lines changed: 970 additions & 53 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
'@object-ui/plugin-list': patch
5+
---
6+
7+
feat(console): Save to this view on a shared view asks once, then saves and publishes it; the layout and row colour are part of a list's draft
8+
9+
Clause-②: yes (widening) — new `console.objectView.draft.*` keys in every `@object-ui/i18n` locale pack (`saveToViewConfirmTitle`, `saveToViewConfirm`, `saveToViewConfirmButton`, `savedForEveryone`, `pendingDraft`); `@object-ui/plugin-list` `ListView` gains the optional host prop `onRowColorChange` and two optional `viewDefaults` members, `viewType` and `rowColor`; nothing removed or renamed
10+
Metadata-protocol: none
11+
12+
On a Console object list, **Save to this view** is now offered on a shared view to a reader who may edit it (an administrator, on a stored view whose package takes saves). It asks once ("everyone who uses this view will see these changes"), then saves the view and publishes it in the same step, so other readers see it on their next read, and says "Saved, visible to everyone". The options menu's Save does the same.
13+
14+
- When the view already has unpublished changes (a draft saved from the view settings, by anyone), nothing is written: the Console says so and points to the view settings to publish or discard that draft first. The draft write is sent with the first-write pin (`If-None-Match: *`), so the server refuses it when a draft is pending; that draft is never published on someone else's behalf. A publish the server refuses discards the draft the save wrote.
15+
- The reader's row height and column widths are never written into a shared view: it keeps its own.
16+
- The Display panel's layout and row colour are part of the list's draft: they survive opening a record and coming back, and both Save to this view and Save as my view keep them (a layout switch retypes the saved view). Discard puts back the view's own.
17+
18+
`@object-ui/plugin-list`: `ListView` reports a pick in its row colour panel through the new optional host prop `onRowColorChange` (the rule in force, or `null` for none), never at mount or for a reset. A host that lays the reader's layout or row colour into `schema` passes the view's own in `viewDefaults.viewType` / `viewDefaults.rowColor`, and the `layout` / `rowColor` parts and the Display count are judged against them; each is read only when its key is present. Without them nothing changes.
19+
20+
No metadata key, value or default changes. The view settings panel and the footer calculation still save a shared view as a draft that the view settings publish.

‎content/docs/ui/views.mdx‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,26 @@ reader's right-column and panel choices on it, are described in
619619
620620
### A user's list state never writes the view
621621
622-
A header sort, a filter change, grouping, the search, Hide Fields, an added field and a
623-
column drag apply at once and are a **draft**: they are kept nowhere and never write the
624-
view metadata, so they work even where the tenant's metadata is read-only. While the list
625-
holds a draft, **Discard** and **Save** sit at the end of the condition row (one **Save**
626-
whose menu also holds Discard on a narrow list or a phone).
627-
628-
- **Save** names what is unsaved and keeps the sort, filters, columns and hidden fields:
629-
**Save to this view** on a view of the user's own, or **Save as my view**, which asks a
630-
name first (the view's name with "copy") and then opens the new view. Either says
631-
"Saved", and the buttons go while the conditions stay.
622+
A header sort, a filter change, grouping, the search, Hide Fields, an added field, a
623+
column drag and the Display panel's layout and row color apply at once and are a **draft**:
624+
they are kept nowhere and never write the view metadata, so they work even where the
625+
tenant's metadata is read-only. While the list holds a draft, **Discard** and **Save** sit at
626+
the end of the condition row (one **Save** whose menu also holds Discard on a narrow list or
627+
a phone).
628+
629+
- **Save** names what is unsaved and keeps the sort, filters, columns, hidden fields, layout
630+
and row color: **Save to this view**, or **Save as my view**, which asks a name first (the
631+
view's name with "copy") and then opens the new view. Either says "Saved", and the buttons
632+
go while the conditions stay.
633+
- **Save to this view** on a view of the user's own saves it at once. On a shared view it is
634+
offered to a user who may edit the view (an administrator, on a stored view whose package
635+
takes saves). It asks once ("everyone who uses this view will see these changes"), then
636+
saves the view and publishes it in the same step, so every user sees it on their next read,
637+
and says "Saved, visible to everyone". It never writes the user's row height or column
638+
widths into the view. When the view already has unpublished changes (a draft saved from
639+
the view settings, by anyone), nothing is saved: the Console says so and points to the view
640+
settings to publish or discard that draft first. Every other change to a shared view still
641+
goes to a draft that the view settings publish.
632642
- **Discard** puts the list back as its view declares it, the Display panel's layout and row
633643
color included, and removes the list's `uf_*` parameters from the address bar.
634644
- The draft survives opening a record and coming back. Opening another view or object,

‎docs/qa/platform-checklist/areas/records-forms.json‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,7 @@
29332933
"title": "User-built FilterBuilder/SortBuilder toolbar merges with the view filter, restores across nav, and reproduces rows from the URL",
29342934
"since": "v16",
29352935
"status": "active",
2936-
"revision": 13,
2936+
"revision": 14,
29372937
"priority": "P1",
29382938
"surface": "browser",
29392939
"personas": [
@@ -2958,7 +2958,8 @@
29582958
"read where the toolbar filter and sort are kept: nowhere durable. Since objectstack#35955 they are the list's DRAFT, held in this tab's memory (ui/packages/app-shell/src/views/listDraftStore.ts): the signed-in user's sys_user_preference row keyed ui.list.showcase_task (GET /api/v1/data/sys_user_preference filtered to that key) gains no filters, sort or search from the change — it holds only what is remembered for the reader (perView.<view>.columnState.widths, rowHeight, viewOrder) — and localStorage gains no list-filters:<userId>:showcase_task:<viewId> key. Reload the page: the list opens as the view declares it",
29592959
"sign out through the account menu (the avatar menu's Log out, user.logout in ui/packages/app-shell/src/layout/AppHeader.tsx; never by clearing storage). That Log out itself removes the signed-out user's list-state:* and list-filters:* keys from localStorage (purgeSignedOutUserClientState, ui/packages/auth/src/ActiveOrganizationStorage.ts, run by AuthProvider's sign-out), so the first account's keys are gone by the time the second signs in; the clause holds by that wipe AND by the user-keyed row. Sign in as the SECOND account; open the same object+view; confirm the first account's cached toolbar filter does NOT appear",
29602960
"userFilters/URL: where UserFilters are hosted (an interface page or the userFilters surface — NOT a bare object list, ADR-0053), apply a quick-filter; copy the URL; open it in a fresh tab; confirm the uf_<field> params (comma-joined, URI-encoded) reproduce the same rows and uf__tab carries the active preset (ADR-0047)",
2961-
"negative sweep: confirm tabs-element userFilters (preset chips, uf__tab) do NOT leak onto the bare object list view — dropdown chips the object view itself declares are allowed there (ADR-0047 amendment) and their uf_<field> params are not a leak"
2961+
"negative sweep: confirm tabs-element userFilters (preset chips, uf__tab) do NOT leak onto the bare object list view — dropdown chips the object view itself declares are allowed there (ADR-0047 amendment) and their uf_<field> params are not a leak",
2962+
"shared-view save (objectstack#35955): as the seeded admin on the in_progress saved view (a stored view the showcase package takes saves into), change the sort, pick Kanban in the Display panel's layout and a row colour, open a record and come back with Back (the layout and the row colour are part of the draft and are still there), then set the row height to Spacious on the options menu's Row height level. Press 「Save」 at the condition row's end (Save to this view): it asks once, 「Save to this view?」, saying everyone who uses the view will see the changes. Confirm; capture the two writes: PUT /api/v1/meta/view/<view> as a draft carrying If-None-Match: *, then POST /api/v1/meta/view/<view>/publish. The console toasts 「Saved, visible to everyone」 and the condition row's 「Discard」/「Save」 go away. Sign in as the second account and open the same view: it shows the saved sort and the Kanban layout, with the second account's own row height. Back as the admin, change something in the view settings and save it there as a draft without publishing it; change the sort and press 「Save」 again: the console says the view has unpublished changes, to publish or discard them in the view settings first, and writes nothing. Discard that settings draft afterwards"
29622963
],
29632964
"acceptance": [
29642965
{
@@ -2990,13 +2991,20 @@
29902991
"oracle": "network",
29912992
"verify": "opening the copied URL fresh issues the same filtered data request and returns the same rows (app-shell/src/views/userFilterUrlState.ts parseUserFilterParams/applyUserFilterParams)",
29922993
"evidence": "the shared URL + the reproduced rows"
2994+
},
2995+
{
2996+
"clause": "Save to this view on a shared view (objectstack#35955) is offered only to a reader who may edit the view, asks once, then saves the draft and publishes it in one step so every reader sees it on their next read; it never writes the saver's row height into the view, and it never publishes a draft someone else left pending: with one pending it writes nothing and says so",
2997+
"oracle": "network",
2998+
"verify": "the confirmed save issues PUT /api/v1/meta/view/<view> (a draft, If-None-Match: *) then POST /api/v1/meta/view/<view>/publish, and the published view carries the new sort, the kanban type and the row colour but not rowHeight tall; the second account's read of the view shows them; with a settings draft pending the second Save issues no PUT and no publish (or only a PUT the server refuses 409 METADATA_CONFLICT) and the pending draft is still there, unpublished (ui/packages/app-shell/src/views/runtime-metadata-persistence.ts saveAndPublishRuntimeMetadata)",
2999+
"evidence": "the two captured writes + the published view body + the second account's screenshot + the refused second save"
29933000
}
29943001
],
29953002
"negative": [
29963003
"a toolbar filter that REPLACES the view's stored filter (rows appear that the view filter should exclude) is a FAIL — buildEffectiveFilter merges, it does not overwrite the base",
29973004
"tabs-element userFilters (preset chips, the uf__tab preset) leaking onto a bare OBJECT list view is a FAIL — ADR-0053 suppresses them there by design, as amended by ADR-0047: on an object list view only `element: 'tabs'` userFilters (and quickFilters) are ignored — objectui app-shell warnSuppressedListNav.ts, which logs the suppression — while `element: 'dropdown'` value chips ARE allowed there (examples/app-showcase/src/ui/views/project.view.ts ships them on All Projects, QA run #24616) (the list-view-capabilities item flags the same regression). The reserved list-state params an object list writes for ITSELF — uf__filter, uf__search, uf__sort, uf__group (objectui#11860, userFilterUrlState.ts), e.g. uf__sort after a toolbar sort — are the list's own state mirrored into the URL, not userFilters, and do not count",
29983005
"a cached toolbar filter from account A visible to account B on the same browser (A signed out through the account menu's Log out, never by clearing storage) is a FAIL — the key embeds the user id precisely to prevent that leak",
2999-
"an incomplete FilterBuilder row emitted as [field, op, ''] (which matches only empty and silently excludes everything) instead of being dropped is a FAIL — convertFilterGroupToAST skips valueless rows (#1964)"
3006+
"an incomplete FilterBuilder row emitted as [field, op, ''] (which matches only empty and silently excludes everything) instead of being dropped is a FAIL — convertFilterGroupToAST skips valueless rows (#1964)",
3007+
"a Save to this view that publishes a view draft which was already pending before the save (saved from the view settings, by anyone) is a FAIL — the draft write carries the first-write pin, so a pending draft refuses it; a shared save that writes the saver's row height into the view is a FAIL too"
30003008
],
30013009
"traps": [
30023010
"hydration-race",
@@ -3092,6 +3100,12 @@
30923100
"date": "2026-11-21",
30933101
"change": "steps[3], steps[4], acceptance[2] (clause, verify, evidence), acceptance[3] (clause, verify, evidence) and source[1] re-pointed to the list draft (objectstack#35955): a toolbar filter, sort and search are a draft held in the tab's memory, kept on opening a record and coming back and dropped on opening another object or view or on a reload; they are no longer stored in the user's ui.list.<object> row. The in-app-navigation restore of revision 3 is replaced by the record round trip, and the user-scope clause now reads that nothing is stored at all. Not loosened: a second account must still see none of the first account's filters",
30943102
"ref": "#35955"
3103+
},
3104+
{
3105+
"revision": 14,
3106+
"date": "2026-11-21",
3107+
"change": "steps[8], acceptance[5] and negative[4] added for the shared-view save (objectstack#35955 PR 2): Save to this view on a stored view an administrator may edit asks once, then saves the draft and publishes it; the saver's row height stays theirs; a pending view draft is never published on anyone's behalf. steps[8] also reads the Display panel's layout and row colour back across a record round trip, since they are now part of the draft. Not loosened: every earlier clause is unchanged",
3108+
"ref": "#35955"
30953109
}
30963110
]
30973111
},

‎ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,32 @@ describe('objectstack#35955 — a reload drops a list\'s address state only when
396396
await mountHost([address]);
397397
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
398398
});
399+
400+
// The two edges of the address match (objectstack#35955, PR 2's known
401+
// edges): each is pinned as it behaves, not changed.
402+
it('edge: a reload whose address is rewritten before the list seeds counts as no reload of the list, so the address state applies', async () => {
403+
// The reload asked for one address; the list opens on another (a landing
404+
// redirect, a view segment filled in) that carries the same `uf_*` state.
405+
const reloaded = link(VIEW, { filter: URGENT });
406+
const address = link(`${VIEW}/all`, { filter: URGENT });
407+
stubNavigation('reload', new URL(reloaded, window.location.origin).href);
408+
window.history.replaceState(null, '', address);
409+
const host = await mountHost([address]);
410+
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
411+
expect(new URLSearchParams(host.search()).has(LIST_FILTER_PARAM)).toBe(true);
412+
});
413+
414+
it('edge: a reload of a record page, then Back to the list: the list\'s history entry applies its `uf_*` state', async () => {
415+
const record = `${VIEW}/all/record/1`;
416+
const address = link(`${VIEW}/all`, { filter: URGENT });
417+
window.history.replaceState(null, '', record);
418+
stubNavigation('reload', new URL(record, window.location.origin).href);
419+
const host = await mountHost([record]);
420+
window.history.replaceState(null, '', address);
421+
await host.go(address);
422+
expect(filterOf(lastQuery())).toContain('"priority","=","urgent"');
423+
expect(new URLSearchParams(host.search()).has(LIST_FILTER_PARAM)).toBe(true);
424+
});
399425
});
400426

401427
describe('a malformed or stale param is dropped — the list opens and nothing throws (objectui#11860)', () => {

‎ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,4 +789,48 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r
789789
await waitFor(() => expect(screen.queryByTestId('list-draft')).toBeNull());
790790
expect(draftOf('v1')).toEqual({});
791791
});
792+
793+
it.each([
794+
['no label', undefined, 'Leads copy'],
795+
['a label given as a locale map', { en: 'Hot list', 'zh-CN': '热门' }, 'Hot list copy'],
796+
])('objectstack#35955 L1-b S1 — 「Save as my view」 names the copy by the view\'s tab label when it has %s', async (_case, label, expected) => {
797+
const v1 = LEAD.listViews.v1 as Record<string, unknown>;
798+
const authored = v1.label;
799+
if (label === undefined) delete v1.label;
800+
else v1.label = label;
801+
try {
802+
mountLeads(romeLink('/apps/crm/crm_lead/view/v1'));
803+
await listToolbar();
804+
fireEvent.pointerDown(await screen.findByTestId('list-draft-save'), { button: 0, ctrlKey: false, pointerType: 'mouse' });
805+
fireEvent.click(await screen.findByTestId('list-draft-save-as'));
806+
// Never 「 copy」 or 「[object Object] copy」: the name the tab draws.
807+
expect(await screen.findByDisplayValue(expected)).toBeInTheDocument();
808+
} finally {
809+
v1.label = authored;
810+
}
811+
});
812+
813+
it('objectstack#35955 — the draft\'s row colour is saved too: into the reader\'s own view, and into a view of their own', async () => {
814+
const RED = { field: 'status', colors: { open: 'red' } };
815+
storeListState({ perView: { pv_mine: { sort: [{ field: 'name', order: 'desc' }], rowColor: RED } } });
816+
const { dataSource } = mountLeads('/apps/crm/crm_lead/view/pv_mine');
817+
await listToolbar();
818+
await saveToThisView();
819+
await waitFor(() => expect(dataSource.update).toHaveBeenCalledTimes(1));
820+
const patch = dataSource.update.mock.calls[0][2];
821+
expect(patch.config.rowColor).toEqual(RED);
822+
expect(patch.config.sort).toEqual([{ field: 'name', order: 'desc' }]);
823+
expect(ListViewSchema.safeParse(patch.config).success).toBe(true);
824+
cleanup();
825+
826+
storeListState({ perView: { v1: { sort: [{ field: 'name', order: 'desc' }], rowColor: RED } } });
827+
const second = mountLeads('/apps/crm/crm_lead/view/v1');
828+
await listToolbar();
829+
fireEvent.pointerDown(await screen.findByTestId('list-draft-save'), { button: 0, ctrlKey: false, pointerType: 'mouse' });
830+
fireEvent.click(await screen.findByTestId('list-draft-save-as'));
831+
await screen.findByDisplayValue('View 1 copy');
832+
fireEvent.click(screen.getByTestId('personal-view-name-submit'));
833+
await waitFor(() => expect(second.dataSource.create).toHaveBeenCalledTimes(1));
834+
expect(second.dataSource.create.mock.calls[0][1].config.rowColor).toEqual(RED);
835+
});
792836
});

0 commit comments

Comments
 (0)