Repository navigation
Commit 847e424
feat(console): the list title switches views from a dropdown, a pinned view opens by default, and a starred view joins the sidebar favorites (#27943)
domain:ui#2 · os-bill · session_01Utp6CY2n1JmZZKrHgtp9jC
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgP6XkfpjCfyzzG2KwQPUZfy)_
Fixes #27594
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:对象列表的标题变成视图切换下拉「视图名 ▾ · 条数」(搜索框常在,分「📌 固定 · 最近 ·
全部」三段,全部里作者视图在前、用户保存的视图在后,底部「+ 新建视图」和管理员的「管理视图」);平铺视图页签行退役;📌
让某视图成为本人打开该对象时的默认视图(按对象按人存);☆ 把视图放进侧栏「收藏」组,可拖动排序,菜单里已有的视图 ☆
置灰并提示「已在菜单中」。
- 为什么改:每种元数据的视图数量不定,页签行五个就溢出,在 464px 的分屏列表里更挤(epic #26676 的卡)。
- 风险与回滚:只动 ui(app-shell 私有包 + i18n 十个语言包各加 7 个键 +
文档一节);不改元数据、协议、spec;收藏视图存进现有收藏库(type `view`),固定视图存本浏览器的
workspacePreference;回滚即 revert 本 PR。
- 先看:`views/objectViewTitleSwitcher.tsx`(下拉组件与组装它的
hook)、`ObjectView.tsx`(📌 默认视图的解析顺序:地址 > 固定 > 作者默认 >
第一个)、`layout/listViewFavorites.ts` 与 `layout/UnifiedSidebar.tsx`(☆
与收藏组拖序)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/ObjectView.titleViewSwitcher-27594.test.tsx
packages/app-shell/src/views/objectViewTitleSwitcher.test.tsx`,预期两个文件全绿。
- 需要你做的:无;epic 座位在控制台预览里验收(卡 Acceptance 3)。下方「Open
question」有一处前提偏差(对象路由没有面包屑)请座位定夺。
## What changes
Measured first, on `main` at `ddab8b99`: the object list page drew its
views as a flat tab row in the list's toolbar (`ViewTabBar`, handed to
`ListView` as `toolbarLeading`, objectui#12440), the page header's `h1`
read the object's plural, and a reader could not pin or star a view.
- **The title is the view switcher.** `ObjectViewTitleSwitcher` (new,
`views/objectViewTitleSwitcher.tsx`) is the page header's title: the
open view's label, ▾, and `· <count>` once the list reports its total
(`ListView.onTotalChange`, kept per view id). It opens a popover with a
search box (always), then **📌 Pinned**, **Recent** (at most three, the
pinned one excluded) and **All** (the authored views in their order,
then the views saved at runtime), each row with its view-type icon and,
on hover or focus, ☆ and 📌. Its foot is **+ New view** (the existing
create-view flow) and, for an admin, **Manage views** (the existing
dialog). A search lists the matching views flat, in All's order. The
split pane's list (#27545) is the same page, so it has the same
switcher; nothing is special-cased.
- **The flat tab row retires.** `objectViewTabBar.tsx` is deleted; the
list gets no `toolbarLeading`, and a chart view no longer draws its own
tab row above the chart. The filter / sort / display controls keep their
own row.
- **📌 Pinned = the reader's default.** `LIST_PINNED_VIEW_PREFERENCE`
(`list.view.pinned`, scope `object:NAME`) in #27052's
`workspacePreference` module. A bare list address opens the pinned view,
else the authored default (`isDefault`), else the first; a view in the
address still wins. A pin naming a view the list no longer offers is no
pin. Unpinning stores `null`.
- **☆ Starred views in the sidebar's Favorites (收藏).** A star is a
favorite of type `view` (id `view:OBJECT:VIEW`, href
`/apps/APP/OBJECT/view/VIEW`, the object's icon) in the existing
favorites store. The sidebar draws a view favorite only in the app its
address names, beside the object's icon, and the section's own rows
(views, records, objects, dashboards) can now be dragged into order, or
moved with Space and the arrow keys, through `reorderFavorites`
(`SortableFavoriteRows`, the same gesture as the pinned entries of
objectui#12059). A view an app navigation entry already opens (an
`object` entry with that `viewName`, as the member is shown it) shows
its ☆ disabled with 「已在菜单中」 / "Already in the menu".
- **The view description is shown once.** The tab row used to carry it
as the active tab's tooltip. A list face now draws it through
`ListView`'s own info control at the start of its toolbar row (its
behaviour for a host with no leading node); a chart face, which has no
toolbar row, carries it as the switcher's tooltip.
- i18n: `view.switcher.{label,pinned,recent,all,pin,unpin,inMenu}` in
all ten packs. Docs: `content/docs/ui/views.mdx` gains "Switching
views".
### Deviations from the card, each agreed with the seat before the code
- **File surface.** The card names `ui/packages/plugin-list/src/**` for
the tab row → switcher. The console's tab row is drawn by app-shell
(`objectViewTabBar.tsx`, `objectViewPageHeader.tsx`,
`objectViewViewCrud.tsx`), so the switcher lives in app-shell
(`objectViewTitleSwitcher.tsx`, new) and plugin-list is untouched. The
card's `components/UnifiedSidebar.tsx` is `layout/UnifiedSidebar.tsx`.
- **Where a star is stored (seat ruling B).** Target 4 says the 收藏 entry
is a "reader preference, same module, scope `app:NAME`". It is stored in
the existing favorites store instead (`FavoritesProvider`, the
`ui.favorites` user-preference row, type `view`), filtered by the app
its address names. Reason: the sidebar's 收藏 section already draws that
store (objectui#12427), so a second store would split one section into
two lists with two orders, and the favorites row follows the reader
across devices where `workspacePreference` is this browser's.
- **Recent** is read from the recent-items list the console already
keeps for list-view visits (`RecentViewItem`, objectui#12604).
- **Manage views** at the dropdown's foot (admins only) is an addition
the card did not name: the tab row's ▾ menu was the only way into that
dialog, and it retires with the row.
## Tests
New:
- `views/objectViewTitleSwitcher.test.tsx` (13): label and count;
authored-then-saved order in All; search box always there; Pinned →
Recent (≤3, without the pinned) → All; a pinned view the list no longer
offers draws no Pinned; case-insensitive search narrows flat; choosing
switches and closes; 📌 pin / unpin; ☆ toggles, and a menu view's ☆ is
disabled with its reason; no ☆ off an app route; the foot and its
CONTROL.
- `views/ObjectView.titleViewSwitcher-27594.test.tsx` (real
`ObjectView`): the title in the `h1` with the view label and count; no
tab bar, tab row or toolbar slot; the dropdown's order; search and its
empty state; pin stores `{"view":"v3","v":1}` at
`os:pref:list.view.pinned@object:crm_lead` and a bare route opens it on
remount; unpin returns to the default; a view in the address beats the
pin; the split pane (`?recordId=` with the split preference) shows the
same switcher.
- `views/ObjectView.starredView-27594.test.tsx`: ☆ writes the `view`
favorite (id, label, href, icon); an authored `viewName` entry's ☆ is
disabled with "Already in the menu".
- `layout/__tests__/UnifiedSidebar.starredViews-27594.test.tsx`: a
starred view of this app is drawn with its icon and address, one of
another app is not; a keyboard reorder saves the new order.
Updated (they read the retired tab row, a tab's text, or the plural
`h1`): `ObjectView.chartViewTabs-13114`, `viewRefusal-12112`,
`labelLessViewTab-12774`, `servedViewLabel-11295`,
`userListState-12418`, `viewWriteRefusal-11583`, `ufViewSwitch-11992`,
`createViewRefusal-11578`, `createKanbanView-11581`,
`createChartView-11576`, `recordOpenPreference-26677`,
`refreshInPlace-10035`, `externalRefreshSum-10572`,
`relayRungCensus-7559`, `listTitlePlural-11696`,
`managedByBadgeAuthoring-12194`, `setupListBadge-13385`,
`listActionsReadGate-12109`, `objectBoundActions-7234`, and console
`recordOpenFromEveryView-27057`.
`ObjectView.viewTabsInToolbar-12440.test.tsx` is replaced by
`ObjectView.titleViewSwitcher-27594.test.tsx` (the toolbar slot it
pinned is gone).
## Acceptance notes
- **Open question (premise drift).** The card says the object name
"stays in the breadcrumb and the sidebar highlight". An object route
draws no crumb (objectui#12461: the page header named the object, so a
crumb said it twice), so with the title naming the view the object is
named by the sidebar's active entry and the header's object icon. A
label-less view is still called by the plural (objectui#12774), and so
are the tests of #11696 and the badge tests, which now open such a view.
Restoring an object crumb on list routes is a one-line call for the
seat; this PR does not make it.
- Screenshots are on `examples/app-crm` (HotCRM is not in this
workspace), a deviation from Acceptance 2, and are kept in the project's
files for the seat rather than on an evidence branch; see Verification.
Two layout faults they showed were fixed before this PR opened: the
trigger's negative margin cut a four-character label by one, and its
outer focus ring was clipped by the title's truncation.
- The count is the list's reported total, so it is drawn for a view
whose list reports one (the paged grid); a board or calendar that does
not report a total shows the label and ▾ alone.
- The admin-shared `isPinned` flag of a saved view (the old tab row's
pin) is not drawn in the dropdown; 📌 is the reader's own pin.
- The phone keeps its app-bar view switcher
(`MobileViewSwitcherContext`); the page header with the title switcher
is `sm` and up, as before.
- Seen while taking the split-pane screenshot, not changed here: in the
split arm the list draws its own record-count bar and `ObjectView` draws
`record-count-footer` under it, so 「5 条记录」 shows twice
(`ObjectView.tsx`, the split pane's footer; untouched by this diff).
- `packages/spec/**` is untouched. One spec description still names the
tab strip: `view.list.tabs`' removal note says "the tab strip above an
object's records is the saved-view switcher (ViewTabBar)". It is prose
in the generated reference; noted for the spec lane, not changed here.
## Verification
<details><summary>Local runs (head 16c2570, after merging origin/main
04740b7 once)</summary>
All under `scripts/pm/os-verify-lock.sh`:
- `pnpm --dir ui exec vitest run` over the 238 test files that name
`ObjectView`, the retired tab bar or toolbar slot,
`FavoritesProvider`/`useFavorites`, `workspacePreference`,
`objectViewListRenderer`, `objectViewPageHeader`, `StarredApps` or
`list-view-switcher` (app-shell views, layout, context, utils, console
home and `AppContent` tests, console `recordOpenFromEveryView-27057`),
plus `packages/i18n/` → Test Files 330 passed (330), Tests 3335 passed,
13 skipped; `VITEST_EXIT=0`.
- `pnpm --filter @object-ui/app-shell run type-check` (both tsc
programs) → `TYPECHECK_EXIT=0`.
- `eslint` on every changed app-shell file → 0 errors (warnings carried
over from the deleted `objectViewTabBar.tsx`).
- `pnpm --dir ui run check:i18n-drift` → 0 en values changed, 7 keys
added; `check:i18n-keys` and `check:i18n-dead-keys` → exit 0; `pnpm
check:new-line-citations` (ui) → 0 new citations, exit 0.
- Not run locally, declared to CI: the whole Test UI shards, the console
type-check (no export of `@object-ui/app-shell` changed; one console
test file changed), and the rest of the lint farm.
</details>
<details><summary>Ablations (each through scripts/ablation-replace.mjs,
each restored to HEAD with an empty diff)</summary>
- `ObjectView.tsx`: the pin dropped from the open-view resolution
(`resolvedViewId || defaultViewId`) → `titleViewSwitcher-27594` 1 of 7
red (the pin is kept and the bare address opens it).
- `objectViewTitleSwitcher.tsx`: authored-first order dropped →
`objectViewTitleSwitcher.test` 1 of 13 red.
- `UnifiedSidebar.tsx`: view favorites not filtered by app →
`UnifiedSidebar.starredViews-27594` 2 of 2 red.
- `listViewFavorites.ts`: `inMenu` always false → `starredView-27594` 1
of 2 red.
- `UnifiedSidebar.tsx`: the sidebar's drop not saved (`onReorder={() =>
{}}`) → `UnifiedSidebar.starredViews-27594` 1 of 2 red.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `16c257005a` derived 66 families (the
same list as at `8aec374c05`); each run and recorded as `command :: exit
code` before any pipe; all 66 exit 0, including `node
scripts/check-sdui-manifest.mjs` and `pnpm --dir ui exec vitest run
scripts/` (run alone, nothing else running). `pnpm --filter
@objectstack/spec run check:skill-examples` exited 3 (NOT MEASURED:
stale `@objectstack/client-react` declarations) on the first pass at
`8aec374c05`; after `pnpm --filter @objectstack/client-react build` it
exited 0, and 0 again at `16c257005a`. `--ran` reconciliation: 66
derived, 66 run, 0 NOT-MEASURED, 0 UNRUN.
</details>
<details><summary>Screenshots (examples/app-crm, zh-CN, 1440 ×
900)</summary>
Backend `examples/app-crm` with `objectstack dev --seed-admin --fresh`
on its own port, Console from `ui/apps/console` (Vite, src) pointed at
it, driven by Playwright; both stopped afterwards. Eight PNGs in the
project's files for the seat (`ui-seat2/card-27594/shots/`):
- `00-list-title.png`: 「全部线索 ▾ · 5」 as the title; no tab row; the filter
/ sort / display controls on their own row.
- `01-dropdown-open.png`: the dropdown open, a row hovered with ☆ and 📌,
「新建视图」 and 「管理视图」 at the foot.
- `02-bare-address-opens-pinned.png`: after 📌 on 「线索看板」, the bare list
address opens the board.
- `03-dropdown-pinned-recent-all.png`: 「固定 · 最近 · 全部」.
- `04-dropdown-search.png`: searching 「看板」.
- `05-sidebar-starred-view.png`: 「收藏」 at the top of the sidebar with the
starred 「线索看板」 beside the object's icon.
- `06-split-pane.png`, `07-split-pane-dropdown.png`: a record open in
the split pane; the list beside it keeps the same switcher, and it opens
there.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CanDVECEsojSwtvSs7)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4bb5eea commit 847e424
51 files changed
Lines changed: 2206 additions & 560 deletions
File tree
- .changeset
- content/docs/ui
- ui
- apps/console/src/__tests__
- packages
- app-shell/src
- console/home
- context
- layout
- __tests__
- utils
- views
- i18n/src/locales
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
360 | 375 | | |
361 | 376 | | |
362 | 377 | | |
| |||
491 | 506 | | |
492 | 507 | | |
493 | 508 | | |
494 | | - | |
| 509 | + | |
495 | 510 | | |
496 | 511 | | |
497 | 512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | | - | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| |||
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
| |||
184 | 200 | | |
185 | 201 | | |
186 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
187 | 225 | | |
188 | 226 | | |
189 | | - | |
190 | | - | |
191 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
192 | 230 | | |
193 | 231 | | |
194 | 232 | | |
| |||
505 | 543 | | |
506 | 544 | | |
507 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
508 | 558 | | |
509 | 559 | | |
510 | 560 | | |
| |||
522 | 572 | | |
523 | 573 | | |
524 | 574 | | |
| 575 | + | |
525 | 576 | | |
526 | | - | |
| 577 | + | |
527 | 578 | | |
528 | 579 | | |
529 | 580 | | |
| |||
559 | 610 | | |
560 | 611 | | |
561 | 612 | | |
| 613 | + | |
562 | 614 | | |
563 | 615 | | |
564 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
0 commit comments