diff --git a/.changeset/35878-list-toolbar-two-rows.md b/.changeset/35878-list-toolbar-two-rows.md new file mode 100644 index 00000000000..086dc3520bf --- /dev/null +++ b/.changeset/35878-list-toolbar-two-rows.md @@ -0,0 +1,19 @@ +--- +'@object-ui/plugin-list': patch +'@object-ui/plugin-grid': patch +'@object-ui/i18n': patch +--- + +feat(list): the list page's toolbar is two rows: 「Object / View ▾ · View settings … Search · New · ⋮」 and a resident condition row + +Clause-②: yes (widening) +Metadata-protocol: none + +The console's object list drew three rows above the table: the object's name with ⋮ More and New, the view bar with Filter N, Sort N, Options and search, and a condition row that appeared only once a sort or filter was set. It now draws two: + +- The view bar starts with the object's icon and name, 「/」 and the view switcher, then 「View settings」. Its right end is the search, the page's toolbar actions, New, and ⋮ More last at the right edge. While rows are selected the right end shows what the selection offers, and ⋮ More keeps its place and its icon (⋮, also in the selection face). +- The Filter N and Sort N buttons are gone from the bar. The condition row is always there: with nothing set it shows dashed 「Sort」 and 「Filter」 buttons; a sort of any number of levels is one chip, 「Sorted by X」 with 「+N」 for the further levels, which opens the sort panel; each filter is its own chip with ×, followed by 「+」. The row's right end is 「Personalized」 and 「Reset」 while the list differs from its view. The table no longer moves down when the first condition is set. +- 「Options」 is renamed 「View settings」 and sits beside the view name. Its first level shows the content itself: the view's name, the shown columns (drag to reorder, the eye to hide) and 「+ Add column」, then Layout, Group, Row height and Row color where offered, and Save, Restore defaults and export in its footer. The More level and its inline edit switch, and Refresh, are gone. +- As the list narrows, 「View settings」 folds to its icon first, then the word 「Personalized」 goes, then 「Reset」 folds to its icon. The condition row stays one line and scrolls sideways. + +For hosts of `ListView`: two optional host props, `toolbarTrailing(tools)` (the bar's right end, given the list's search) and `conditionRowEnd` (the condition row's right end, drawn in place of the row's own Reset). A host that passes neither gets the search alone at the bar's end and the row's own Reset. diff --git a/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index c5ef69d11e8..9bba7b25ae3 100644 --- a/docs/qa/platform-checklist/areas/records-forms.json +++ b/docs/qa/platform-checklist/areas/records-forms.json @@ -621,7 +621,7 @@ "title": "List-view capability matrix: filter, search, sort, pagination, saved views, inline edit, export, visualization switcher, bulk/row actions, conditional formatting", "since": "v15", "status": "active", - "revision": 12, + "revision": 13, "priority": "P1", "surface": "browser", "personas": [ @@ -657,12 +657,12 @@ "open the tabular saved view (sort [{field: 'estimate_hours', order: 'desc'}] — the array form: #17053 retired the bare string clause 'estimate_hours desc' platform-wide, so the objectui#2601 string-crash fixture no longer exists on stock); confirm it renders and the request carries the sort as sort=-estimate_hours", "load a list past its first window. No stock list holds more rows than the 50-row window (the largest seeded task and contact lists are under it), so stage one first: POST /api/v1/data/showcase_inquiry/createMany with a bare JSON array of 55 rows (name + email + message each — showcase_inquiry requires `message` too, and a name + email body answers 400 \"Message is required\", QA run #24616). A list view that declares no `pagination` (the stock Inquiries list) draws NO pager since #35554: it loads as it scrolls, so scroll the Inquiries list to its end and capture `top`/`skip` on every data request (top=50, then top=50&skip=50); the count beside the view name reads the server total. Then page a view that DECLARES `pagination` (stage one: PUT a view with pagination: {pageSize: 50} on showcase_inquiry) past page 1 and capture the same; confirm no unpaged full fetch on either", "in the grid saved view (inlineEdit: true), edit one cell in place; save; capture the PATCH; re-read the row via API", - "on in_progress, with the export grant from fixtures.requires[3] bound, open the view bar's Options (选项) popover — the Display popover, a text trigger since objectstack#35548 — Export sits in its footer ('Export as CSV / XLSX / JSON'), not as a separate toolbar button — and export each declared format (csv, xlsx, json); capture the requests and files. Without the grant the Export entries are absent and the route answers 403 EXPORT_NOT_PERMITTED — the opt-in working as designed, not a fail of the export variant", + "on in_progress, with the export grant from fixtures.requires[3] bound, open the 视图设置 (View settings) popover beside the view name — the Display popover, named 选项 (Options) until objectstack#35878 moved it there — Export sits in its footer ('Export as CSV / XLSX / JSON'), not as a separate toolbar button — and export each declared format (csv, xlsx, json); capture the requests and files. Without the grant the Export entries are absent and the route answers 403 EXPORT_NOT_PERMITTED — the opt-in working as designed, not a fail of the export variant", "open the visualization switcher on All Tasks; enumerate the offered types; switch through each", - "on bulk_actions, select rows that are NOT done and run showcase_mark_done (per-record) — its visible gate, has(record.done) && record.done != true, judges each selected row, so a done row in the selection drops Mark Done from the selection actions the page bar shows (since #35554 the list page has no bottom bulk bar), or, over a mixed selection, the confirm reports the done rows not eligible and skipped (QA run #27438); either way the dispatch count stops matching the selection — and showcase_recalc_selection (aggregate — ONE dispatch: an api-type action, which the console sends through the action door, POST /api/v1/actions/showcase_task/showcase_recalc_selection with body {params:{_selectedIds:[…]}}; the server forwards those params flat to the action's own target /api/v1/apps/showcase/recalc in-process, buildApiActionRequest in packages/runtime/src/action-execution.ts, so the browser's network log shows the door request and no /recalc request); on legacy_row_actions confirm both named row actions resolve to live menu entries", + "on bulk_actions, select rows that are NOT done and run showcase_mark_done (per-record) — its visible gate, has(record.done) && record.done != true, judges each selected row, so a done row in the selection drops Mark Done from the selection actions the view bar's right end shows (since #35554 the list page has no bottom bulk bar; since #35878 the selection face is the view bar's right end, with ⋮ still last), or, over a mixed selection, the confirm reports the done rows not eligible and skipped (QA run #27438); either way the dispatch count stops matching the selection — and showcase_recalc_selection (aggregate — ONE dispatch: an api-type action, which the console sends through the action door, POST /api/v1/actions/showcase_task/showcase_recalc_selection with body {params:{_selectedIds:[…]}}; the server forwards those params flat to the action's own target /api/v1/apps/showcase/recalc in-process, buildApiActionRequest in packages/runtime/src/action-execution.ts, so the browser's network log shows the door request and no /recalc request); on legacy_row_actions confirm both named row actions resolve to live menu entries", "on Field Zoo, confirm the conditionalFormatting row highlight applies to Specimen — Full (f_lookup set) and not Specimen — Minimal", - "at 1280×800 on a zh-CN session, read the list frame on All Tasks, then on its kanban view: a 44px page bar with the object's icon and name on the left and ⋮ (description, import, favorite) and 「+ 新建」 on the right; a 40px view bar with ONE switcher trigger reading type icon → view name → record count → caret on the left and 「筛选」「排序」「选项」 plus the search icon on the right; no condition row height while no condition is set; on the grid a 32px header and 33px rows at 13px; and, on a view whose columns declare a `summary`, each total under its own column with 「计数 N」 leftmost and no doubled colon. The kanban view draws the same two bars (objectstack#35548; the count beside the view name returns, after objectstack#34603 removed it)", - "at 1280×800 with the sidebar open, read the left edges of the list page on All Tasks (a list whose columns fit) and on a list that scrolls sideways (stage one by showing every field of showcase_task through 选项 → 字段): the page bar's object icon, the view bar's view icon, the header's select-all box, each row's checkbox and the footer's record count each start 16px from the main area's left; the selection column is 40px on both lists and stays 40px, pinned at the left, after scrolling to the far right and back; no row shows a number and each row's checkbox shows without a hover; the view bar's last trigger label and the page bar's 「+ 新建」 end 16px from the right; at 375 wide no leading item sits closer than 12px to the left (objectstack#35663)" + "at 1280×800 on a zh-CN session, read the list frame on All Tasks, then on its kanban view: no page bar (objectstack#35878): a 40px view bar with the object's icon and name, 「/」, ONE switcher trigger reading type icon → view name → record count → caret, and 「视图设置」 on the left, and the search icon, 「+ 新建」 and ⋮ (description, import, favorite) last on the right; under it a 40px condition row that is always drawn — dashed 「排序」 and 「筛选」 while no condition is set, one 「按 X 排序」 chip (with +N) and the filter chips once set — so the table's header does not move when a condition is set or reset; on the grid a 32px header and 33px rows at 13px; and, on a view whose columns declare a `summary`, each total under its own column with 「计数 N」 leftmost and no doubled colon. The kanban view draws the same two rows (objectstack#35548; the count beside the view name returns, after objectstack#34603 removed it)", + "at 1280×800 with the sidebar open, read the left edges of the list page on All Tasks (a list whose columns fit) and on a list that scrolls sideways (stage one by showing every field of showcase_task through 视图设置 → 添加列): the view bar's object icon, the header's select-all box, each row's checkbox and the footer's record count each start 16px from the main area's left; the selection column is 40px on both lists and stays 40px, pinned at the left, after scrolling to the far right and back; no row shows a number and each row's checkbox shows without a hover; the view bar's last control, ⋮, ends its icon 16px from the right; at 375 wide no leading item sits closer than 12px to the left (objectstack#35663)" ], "acceptance": [ { @@ -726,15 +726,15 @@ "evidence": "menu screenshot + dispatch traces" }, { - "clause": "the list frame holds its geometry: page bar 44, view bar 40, header 32, rows 33, 13px on the header, the cells and the bar buttons, the first data row top at or above 168px under the 48px shell bar, the switcher read type icon → name → count → caret, every column total's right edge on its column's (±1px), no doubled colon in the summary row, and the kanban view under the same two bars", + "clause": "the list frame holds its geometry: no page bar, view bar 40, condition row 40 and always drawn (the header's top does not move when a condition is set or reset), header 32, rows 33, 13px on the header, the cells and the bar buttons, the first data row top at or above 168px under the 48px shell bar, the switcher read type icon → name → count → caret, every column total's right edge on its column's (±1px), no doubled colon in the summary row, and the kanban view under the same two rows", "oracle": "dom", "verify": "read getBoundingClientRect and the computed font size of each part at 1280×800 zh-CN (the geometry and order halves are pinned by ui/e2e/list-frame-geometry-35548.spec.ts over the real class strings; the kanban half by ui/packages/plugin-list/src/__tests__/ListView.viewBarLeading-35548.test.tsx); the summary half needs a view whose columns declare `summary`, which task.view.ts does not, so stage one in the showcase's customization pair as negative[0] does", "evidence": "light and dark screenshots of the grid and the kanban, plus the measured heights" }, { - "clause": "the list page has one left edge: page-bar icon, view-bar icon, select-all box, row checkboxes and footer count each at 16px (±1) from the main area on a list that fits and on one that scrolls sideways; the selection column is 40px on both and keeps its width and its left pin after a sideways scroll and back, with no gap between frozen cells; no row numbers; every row checkbox visible at rest; at 375 no leading item closer than 12px", + "clause": "the list page has one left edge: the view bar's object icon, select-all box, row checkboxes and footer count each at 16px (±1) from the main area on a list that fits and on one that scrolls sideways; the selection column is 40px on both and keeps its width and its left pin after a sideways scroll and back, with no gap between frozen cells; no row numbers; every row checkbox visible at rest; at 375 no leading item closer than 12px", "oracle": "dom", - "verify": "read getBoundingClientRect of each item from the main area's left at 1280×800 on both lists, and the computed opacity of the row checkboxes with the pointer off the table (pinned by ui/e2e/list-left-edge-35663.spec.ts over the real ObjectGrid, PageHeader and view-bar classes)", + "verify": "read getBoundingClientRect of each item from the main area's left at 1280×800 on both lists, and the computed opacity of the row checkboxes with the pointer off the table (pinned by ui/e2e/list-left-edge-35663.spec.ts over the real ObjectGrid and view-bar classes, the view bar's object name read off VIEW_BAR_OBJECT_NAME in objectViewPageHeader.tsx)", "evidence": "screenshots of both lists at rest and scrolled, plus the measured edges" } ], @@ -831,7 +831,8 @@ "date": "2026-11-19", "change": "steps[11] and its acceptance clause added: the list page's left edge (objectstack#35663, epic #35547). The page bar's icon, the view bar's icon, the select-all box, every row's checkbox and the footer's count share one 16px line, the selection column is 40px at any width and under a sideways scroll, and the grid draws no row numbers (each row's checkbox shows at rest). No earlier clause changed", "ref": "#35663" - } + }, + { "revision": 13, "date": "2026-11-20", "change": "steps[6], [8], [10], [11] and the clauses acceptance[10] and acceptance[11] follow #35878: the list page draws two rows, not three. There is no page bar; the view bar leads with the object's icon and name, then the switcher and 「视图设置」 (was 「选项」), and ends with search, 「+ 新建」 and ⋮ last (#35678). The condition row is always drawn at 40px, so the frame clause reads condition row 40 where it read 'no condition row height', and the left-edge clause's first item is the view bar's object icon where it was the page bar's (the view icon no longer leads the bar). Filter N and Sort N left the bar for the condition row", "ref": "#35878" } ] }, { @@ -2924,7 +2925,7 @@ "title": "User-built FilterBuilder/SortBuilder toolbar merges with the view filter, restores across nav, and reproduces rows from the URL", "since": "v16", "status": "active", - "revision": 11, + "revision": 12, "priority": "P1", "surface": "browser", "personas": [ @@ -2943,7 +2944,7 @@ }, "steps": [ "sign in as admin; open showcase_task and switch to the in_progress saved view (stored filter status=in_progress); screenshot", - "open the toolbar's Filter (a text trigger from sm up, data-testid toolbar-filter-trigger, whose accessible name gains the badge count once a condition is active; Sort is the trigger beside it, ui/packages/plugin-list/src/ListView.tsx). Since objectstack#35549 / #35550 each opens the shared field list (the fields the view shows first, a search box, a type icon per row): Filter → a field → its values applies at once, with no Apply, and each condition shows as a chip in the condition row under the view bar; Sort → the direction on top → a field adds a level, shown as a sort chip before the filter chips. The full builders are one click further, behind the field list's footer: 「Advanced filter」 opens the FilterBuilder (no 「Where」 label any more) and 「All sort levels」 the SortBuilder. Add 2 conditions that leave at least TWO rows, so the sort clause has an order to read — on the stock seed priority = high AND estimate_hours > 4 leaves ONE row on in_progress, a single-datapoint for acceptance[1] (QA run #24616): check the count first and pick a pair that keeps ≥ 2; open the SortBuilder and add a sort (due_date desc); type a term into the list's quick search that keeps rows (acceptance[2] reads it back; QA run #29890 used 'pipeline'); capture the data request", + "open Filter in the condition row under the view bar (since objectstack#35878 the bar has no Filter or Sort button: the row is always there, with a dashed 「Filter」 button while no filter of the reader's own is set and a 「+」 after the filter chips once one is, both data-testid condition-add-filter; Sort is the row's first control, the dashed 「Sort」 button or, once sorted, the one sort chip 「Sorted by X +N」, data-testid condition-sort, ui/packages/plugin-list/src/conditions/ListConditionControls.tsx). Since objectstack#35549 / #35550 each opens the shared field list (the fields the view shows first, a search box, a type icon per row): Filter → a field → its values applies at once, with no Apply, and each condition shows as a chip in the condition row under the view bar; Sort → the direction on top → a field adds a level, the sort chip before the filter chips counting it as 「+N」. The full builders are one click further, behind the field list's footer: 「Advanced filter」 opens the FilterBuilder (no 「Where」 label any more) and 「All sort levels」 the SortBuilder. Add 2 conditions that leave at least TWO rows, so the sort clause has an order to read — on the stock seed priority = high AND estimate_hours > 4 leaves ONE row on in_progress, a single-datapoint for acceptance[1] (QA run #24616): check the count first and pick a pair that keeps ≥ 2; open the SortBuilder and add a sort (due_date desc); type a term into the list's quick search that keeps rows (acceptance[2] reads it back; QA run #29890 used 'pipeline'); capture the data request", "assert the request's `filter` param is the MERGE of the view's stored rule AND the two toolbar conditions (buildEffectiveFilter/mergeFilterNodes), and `sort` carries the toolbar sort (e.g. sort=-due_date) — the console spells its list params without a `$`; the returned rows satisfy view-filter AND toolbar conditions", "navigate away via an in-app nav link to another object (the link carries no query string, so the URL state is dropped), then navigate back to showcase_task in_progress through the Tasks nav entry and the view switcher (it lands on /view/showcase_task.in_progress). ⛔ Not the sidebar's 'In-Progress Tasks' Data Slices link: it opens /showcase_task/data?filter[status]=in_progress, a different surface from the saved view; screenshot; confirm the toolbar filter + sort restored", "read where the toolbar filter and sort are kept: the signed-in user's own sys_user_preference row keyed ui.list.showcase_task (GET /api/v1/data/sys_user_preference filtered to that key; its value's perView. carries the filters and the sort — objectui ListPreferencesProvider.tsx, objectui#12418), and its localStorage write-through cache list-state::showcase_task. Confirm both are the signed-in user's: the row's user_id, and the cache key's user segment. (Only the search term stays under the older list-filters::showcase_task: key)", @@ -3071,6 +3072,12 @@ "date": "2026-11-19", "change": "steps[1] and acceptance[2].verify re-pointed to the list redo (objectstack#35549 filter, objectstack#35550 sort): Filter and Sort open the shared field list, conditions show as chips in the condition row under the view bar, and the FilterBuilder / SortBuilder sit behind the field list's 「Advanced filter」 / 「All sort levels」 footers; the FilterBuilder's 「Where」 label is gone. The clauses are unchanged: the merge, the sort param, the restore and the user scope read the same state", "ref": "#35549" + }, + { + "revision": 12, + "date": "2026-11-20", + "change": "steps[1] re-pointed to the two-row list toolbar (objectstack#35878): the view bar has no Filter or Sort button; Filter is the condition row's dashed 「Filter」 button or its 「+」 (condition-add-filter) and Sort its dashed 「Sort」 button or its one sort chip (condition-sort).", + "ref": "#35878" } ] }, @@ -3819,7 +3826,7 @@ "title": "Select-all-matching covers every matching id across pages (server total, not the rendered page); clear resets both selection sources", "since": "v16", "status": "active", - "revision": 10, + "revision": 11, "priority": "P2", "surface": "browser", "personas": [ @@ -3838,8 +3845,8 @@ }, "steps": [ "open the showcase_task 'Bulk Actions' view (…/showcase_task/view/bulk_actions) with the scratch tasks in place and quick-search their shared prefix so the match set exceeds one page (e.g. 'QA bulk' → 55 rows); screenshot; note the list shows its first N loaded rows and the count beside the view name shows the server total M (M > N); the view declares no `pagination`, so it loads as it scrolls (#35554) — leave it at its first window", - "tick the header checkbox (every loaded row); the page bar swaps to 「已选 N 条」 and offers 「已选当前加载的 N 条。」 with 「选择全部 M 条」 (en 'All N loaded records are selected.' / 'Select all M')", - "click 「选择全部 M 条」; the page bar's count reads the whole match set ('M selected (all matches)')", + "tick the header checkbox (every loaded row); the view bar's right end swaps to 「已选 N 条」 and offers 「已选当前加载的 N 条。」 with 「选择全部 M 条」 (en 'All N loaded records are selected.' / 'Select all M')", + "click 「选择全部 M 条」; the selection face's count reads the whole match set ('M selected (all matches)')", "dispatch a bulk action; capture the requests — resolveBulkRows fans out a paged find (dropping $top/$skip, paging 500) collecting every matching id ACROSS pages", "cross-check the collected id count against a direct API count for the same search: GET /api/v1/data/showcase_task?$search=…&$top=0 (or the response total)", "confirm the AGGREGATE action (showcase_recalc_selection) carries every matching id in `_selectedIds` — it is an api-type action, so the ONE request is the action door, POST /api/v1/actions/showcase_task/showcase_recalc_selection with body {params:{_selectedIds:[…]}} (the grid hands them to the action runner as params._selectedIds, ui/packages/plugin-grid/src/ObjectGrid.tsx; since #27611 the console sends a declared same-origin api action through the door, and the server forwards the params flat to /api/v1/apps/showcase/recalc in-process, buildApiActionRequest in packages/runtime/src/action-execution.ts); the run dialog then reads 'N / 55 processed' for ~15 s (QA run #24616); a per-record action (showcase_mark_done) fans out one dispatch per matching id", @@ -3848,7 +3855,7 @@ ], "acceptance": [ { - "clause": "the select-all offer in the page bar reports the SERVER total (totalMatching from the find result.total), not the loaded row count — and only appears when every loaded row is selected and more matching rows exist past them", + "clause": "the select-all offer in the view bar's selection face reports the SERVER total (totalMatching from the find result.total), not the loaded row count — and only appears when every loaded row is selected and more matching rows exist past them", "oracle": "network", "verify": "the offer's count equals the data request's response total (SelectionPageBar totalMatching; ListView hands result.total down as rowCount, read by ObjectGrid as resolvedTotalMatching)", "evidence": "banner screenshot + the find response total" @@ -3962,7 +3969,8 @@ "date": "2026-11-19", "change": "steps[0]–[2] and acceptance[0] follow #35554: the bottom bulk bar is retired on the list page and the selection is shown in the page bar (「已选 N 条」, the cross-window offer 「已选当前加载的 N 条。」 + 「选择全部 M 条」); a list with no declared `pagination` loads as it scrolls, so 'the whole page' is now 'every loaded row'. The cap strings of acceptance[5] are unchanged and the page bar names the cap with the same keys. Read at base 93fa4f97", "ref": "#35554" - } + }, + { "revision": 11, "date": "2026-11-20", "change": "steps[1], steps[2] and the clause acceptance[0] follow #35878: the list page has no page bar, so the selection face (「已选 N 条」, the cross-window offer) is the view bar's right end, with ⋮ still last. What it reports is unchanged", "ref": "#35878" } ] }, { diff --git a/ui/e2e/list-condition-row-35549.spec.ts b/ui/e2e/list-condition-row-35549.spec.ts index ec6dff4af1e..f7d918df238 100644 --- a/ui/e2e/list-condition-row-35549.spec.ts +++ b/ui/e2e/list-condition-row-35549.spec.ts @@ -12,15 +12,15 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * GEOMETRY and INTERACTION pin for the list's condition row (objectstack#35549 * filter, objectstack#35550 sort), on the REAL list: `ListView` with its * toolbar, the `list-condition-row` slot objectstack#35548 laid under the view - * bar, and the grid. The Filter and Sort triggers open the shared field list; - * the slot holds the sort chips, then the reader's filter chips, 「Add filter」 - * and 「Reset」; with nothing to show it takes no height at all. + * bar, and the grid. Since objectstack#35878 the slot is resident: the one + * sort chip (the dashed 「Sort」 with nothing set), then the reader's filter + * chips and 「+」 (the dashed 「Filter」 with none), and 「Reset」; it keeps its + * 40 px whether or not a condition is set, so the table does not move. * * ## Why a Playwright spec and not a vitest test * - * "Takes no height", "one row of 24 px chips" and "a real drag reorders" are - * layout and pointer facts; happy-dom lays nothing out and fires no native - * drag. The vitest pins (`plugin-list/src/conditions/__tests__/ + * "Keeps its height", "one row of 24 px chips" and "chips on one line" are + * layout facts; happy-dom lays nothing out. The vitest pins (`plugin-list/src/conditions/__tests__/ * listConditions.test.tsx`, `ListView.conditionRow-35549.test.tsx`) hold the * logic; this spec holds it in Chromium. The bundling follows * `e2e/list-header-narrow-35446.spec.ts`. @@ -255,7 +255,7 @@ async function mount(page: Page): Promise { ); await page.goto('http://localhost/list-condition-row'); await page.addScriptTag({ content: bundle, type: 'module' }); - await page.getByTestId('toolbar-filter-trigger').waitFor({ state: 'attached', timeout: 30_000 }); + await page.getByTestId('condition-add-filter').waitFor({ state: 'attached', timeout: 30_000 }); await page.getByTestId('data-table-summary-lead').waitFor({ state: 'attached', timeout: 30_000 }); await style(page); } @@ -267,6 +267,8 @@ async function click(page: Page, testId: string): Promise { } const slot = (page: Page) => page.getByTestId('list-condition-row'); +/** The resident row's height (`min-h-10`, objectstack#35878). */ +const ROW_HEIGHT = 40; const slotHeight = (page: Page) => slot(page).evaluate((el) => el.getBoundingClientRect().height); /** The number the grid's footer row leads with (objectstack#35702), once the list has answered. */ const count = async (page: Page) => (await page.getByTestId('data-table-summary-lead').textContent())?.match(/\d+/)?.[0]; @@ -279,19 +281,25 @@ test.describe('list condition row under the view bar (objectstack#35549, objects bundle = await bundlePage(); }); - test('CONTROL: with no sort and no filter the row takes no height', async ({ page }) => { + // objectstack#35878: the row is resident. With nothing set it holds the + // dashed 「Sort」 and 「Filter」 and keeps its height, so the table never + // moves when the first condition is set or after Reset. + test('CONTROL: with no sort and no filter the row is drawn with dashed Sort and Filter, 40 px tall', async ({ page }) => { test.setTimeout(120_000); await mount(page); await expect.poll(() => count(page)).toBe('12'); - expect(await slotHeight(page)).toBe(0); - expect(await slot(page).evaluate((el) => el.childElementCount)).toBe(0); + expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT); + await expect(page.getByTestId('condition-sort')).toHaveAttribute('data-levels', '0'); + await expect(page.getByTestId('condition-sort')).toHaveText('Sort'); + await expect(page.getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true'); + await expect(page.getByTestId('condition-add-filter')).toHaveText('Filter'); }); test('filter: Filter → Stage → Negotiation is three clicks; the chip names field and value, reopens on click, × removes', async ({ page }) => { test.setTimeout(120_000); await mount(page); await expect.poll(() => count(page)).toBe('12'); - await click(page, 'toolbar-filter-trigger'); + await click(page, 'condition-add-filter'); await click(page, 'filter-panel-fields-item-stage'); await page.getByTestId('filter-panel-values-option-negotiation').getByRole('checkbox').click(); await style(page); @@ -299,10 +307,8 @@ test.describe('list condition row under the view bar (objectstack#35549, objects await expect.poll(() => count(page)).toBe('3'); const chip = page.getByTestId('filter-chip-stage'); await expect(chip).toHaveText(/Stage: Negotiation/); - // the row is one line of 24 px chips: 24 + 2 × 6 padding + 1 border - const h = await slotHeight(page); - expect(h).toBeGreaterThanOrEqual(36); - expect(h).toBeLessThanOrEqual(38); + // the row is one line of 24 px chips at its resident height (min-h-10) + expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT); const chipBox = await chip.boundingBox(); expect(Math.round(chipBox!.height)).toBe(24); await page.keyboard.press('Escape'); @@ -315,34 +321,51 @@ test.describe('list condition row under the view bar (objectstack#35549, objects await page.keyboard.press('Escape'); await click(page, 'filter-chip-remove-stage'); await expect.poll(() => count(page)).toBe('12'); - expect(await slotHeight(page)).toBe(0); + // the row stays, back to its dashed 「Filter」, at the same height + expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT); + await expect(page.getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true'); }); - test('sort: Sort → Descending → Amount is three clicks; chips come before filter chips; a drag reorders; a handle in a chip panel reorders; a header menu pick shows as a chip; Reset restores', async ({ page }) => { + // objectstack#35878: a sort of any number of levels is ONE chip, 「Sorted by + // X」 with 「+N」, before the filter chips. With no sort the dashed 「Sort」 + // opens the sort panel; with one, the chip opens every level in one panel + // (objectstack#35876), where a level is added and a handle reorders. + test('sort: Sort → Descending → Amount is three clicks; one chip with +N comes before the filter chips; its panel adds a level and a handle reorders; a header menu pick shows on it; Reset restores', async ({ page }) => { test.setTimeout(120_000); await mount(page); await expect.poll(() => count(page)).toBe('12'); - await click(page, 'toolbar-sort-trigger'); + await click(page, 'condition-sort'); await click(page, 'sort-panel-order-desc'); await click(page, 'sort-panel-fields-item-amount'); expect(await sortNow(page)).toEqual(['amount:desc']); - await expect(page.getByTestId('sort-chip-open-amount')).toHaveText('Amount'); - await expect(page.getByTestId('sort-chip-open-amount')).toHaveAttribute('title', 'High → Low'); - // a second level - await click(page, 'toolbar-sort-trigger'); - await click(page, 'sort-panel-fields-item-stage'); - expect(await sortNow(page)).toEqual(['amount:desc', 'stage:asc']); - // a filter chip joins after the sort chips - await click(page, 'toolbar-filter-trigger'); + const sortChip = page.getByTestId('condition-sort'); + await expect(sortChip).toHaveAttribute('data-levels', '1'); + await expect(sortChip).toHaveText('Sorted by Amount'); + // a second level, from the chip's panel of every level: still one chip, now carrying +1 + await click(page, 'condition-sort'); + const panel = page.getByTestId('sort-chip-panel'); + await panel.getByRole('button', { name: 'Add sort' }).click(); + await expect.poll(async () => (await sortNow(page)).length).toBe(2); + const levels = await sortNow(page); + expect(levels[0]).toBe('amount:desc'); + await expect(sortChip).toHaveAttribute('data-levels', '2'); + await expect(page.getByTestId('sort-chip-more')).toHaveText('+1'); + // a real drag of the second level's handle onto the first row puts it first + await expect(panel.getByTestId('sort-builder-handle')).toHaveCount(2); + await panel.getByTestId('sort-builder-handle').nth(1).dragTo(panel.getByTestId('sort-builder-row').first()); + await expect.poll(() => sortNow(page)).toEqual([levels[1], levels[0]]); + await page.keyboard.press('Escape'); + // a filter chip joins after the sort chip + await click(page, 'condition-add-filter'); await click(page, 'filter-panel-fields-item-stage'); await page.getByTestId('filter-panel-values-option-proposal').getByRole('checkbox').click(); await page.keyboard.press('Escape'); await style(page); const order = await page.getByTestId('condition-chips').evaluate((row) => - [...row.querySelectorAll('[data-testid^="sort-chip-"][data-priority], [data-testid^="filter-chip-"]:not([data-testid*="-open-"]):not([data-testid*="-remove-"])')] + [...row.querySelectorAll('[data-testid="condition-sort"], [data-testid^="filter-chip-"]:not([data-testid*="-open-"]):not([data-testid*="-remove-"])')] .map((el) => el.getAttribute('data-testid')), ); - expect(order).toEqual(['sort-chip-amount', 'sort-chip-stage', 'filter-chip-stage']); + expect(order).toEqual(['condition-sort', 'filter-chip-stage']); // all chips on one line, Reset at the right end of the slot const tops = await page.getByTestId('condition-chips').evaluate((row) => [...new Set([...row.children].map((el) => Math.round(el.getBoundingClientRect().top)))], @@ -351,33 +374,22 @@ test.describe('list condition row under the view bar (objectstack#35549, objects const reset = await page.getByTestId('condition-reset').boundingBox(); const slotBox = await slot(page).boundingBox(); expect(slotBox!.x + slotBox!.width - (reset!.x + reset!.width)).toBeLessThanOrEqual(17); - // a real drag: the second sort chip onto the first - await page.getByTestId('sort-chip-stage').dragTo(page.getByTestId('sort-chip-amount')); - expect(await sortNow(page)).toEqual(['stage:asc', 'amount:desc']); - // a chip opens every level in one panel (objectstack#35876); a real drag of - // the second level's handle onto the first row puts it first - await click(page, 'sort-chip-open-stage'); - const panel = page.getByTestId('sort-chip-panel'); - await expect(panel.getByTestId('sort-builder-handle')).toHaveCount(2); - expect(await sortNow(page)).toEqual(['stage:asc', 'amount:desc']); - await panel.getByTestId('sort-builder-handle').nth(1).dragTo(panel.getByTestId('sort-builder-row').first()); - await expect.poll(() => sortNow(page)).toEqual(['amount:desc', 'stage:asc']); - await page.keyboard.press('Escape'); - // Reset puts the list back as saved: no sort, no filter + // Reset puts the list back as saved: no sort, no filter, the same row height await click(page, 'condition-reset'); expect(await sortNow(page)).toEqual([]); await expect.poll(() => count(page)).toBe('12'); - expect(await slotHeight(page)).toBe(0); + expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT); + await expect(sortChip).toHaveAttribute('data-levels', '0'); // a click on a column header opens its menu and sorts nothing // (objectstack#35876); the entry chosen there sorts, and the row shows it - // as a chip + // on the one chip await page.getByRole('columnheader', { name: /Amount/ }).click(); const columnMenu = page.getByTestId('column-context-menu'); await expect(columnMenu).toBeVisible(); expect(await sortNow(page)).toEqual([]); await columnMenu.getByRole('menuitem', { name: 'Sort descending' }).click(); await style(page); - await expect(page.getByTestId('sort-chip-amount')).toBeVisible(); + await expect(sortChip).toHaveText(/^Sorted by Amount/); expect(await sortNow(page)).toEqual(['amount:desc']); }); }); diff --git a/ui/e2e/list-frame-geometry-35548.spec.ts b/ui/e2e/list-frame-geometry-35548.spec.ts index bdfb431f41a..da3e45ed67d 100644 --- a/ui/e2e/list-frame-geometry-35548.spec.ts +++ b/ui/e2e/list-frame-geometry-35548.spec.ts @@ -6,12 +6,16 @@ import path from 'node:path'; import { uiRoot } from '../scripts/ui-root.mjs'; /** - * GEOMETRY pin for objectstack#35548 (epic #35547): the list page's frame. + * GEOMETRY pin for objectstack#35548 (epic #35547), as redrawn by + * objectstack#35878 (two rows): the list page's frame. * - * page bar 44 · view bar 40 · empty condition row 0 · header 32 · row 33, - * 13px on the header, the cells and the bar buttons, the view switcher as one - * trigger (type icon → name → count → caret), and each column total under - * its own column, right edge on the column's right edge. + * view bar 40 (the object's name as the page's heading, the switcher and + * View settings on the left; search, New and ⋮ on the right) · condition + * row 40, resident · header 32 · row 33, 13px on the heading, the header, + * the cells and the bar buttons, the view switcher as one trigger (type + * icon → name → count → caret), and each column total under its own + * column, right edge on the column's right edge. No page bar is drawn + * above the view bar. * * ⚠️ A Playwright spec, not a vitest test: jsdom has no layout engine, so a * height read there is 0 and a class-shape assertion would pass against @@ -20,10 +24,11 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * ## What is real here and what is a fixture * * REAL, read out of the sources at run time and compiled with the installed - * `tailwindcss`: the page bar's classes (`PageHeader.tsx`, list posture) and + * `tailwindcss`: the view bar's object name (`objectViewPageHeader.tsx`) and * the 「新建」 button's (`objectViewHeaderChrome.tsx`); the view bar's row, - * cluster and text-trigger constants (`listToolbarRow.ts`) and its condition - * row (`ListView.tsx`); the switcher trigger and the order of its children + * cluster and text-trigger constants (`listToolbarRow.ts`), the View settings + * trigger that reads that constant (`ViewSettingsPopover.tsx`) and the + * condition row (`ListView.tsx`); the switcher trigger and the order of its children * (`objectViewTitleSwitcher.tsx`); the grid's density constant and default * row arm (`ObjectGrid.tsx`), the row ⋮ trigger (`RowActionMenu.tsx`), the * header label and summary cell classes (`data-table.tsx`), the Shadcn table @@ -40,7 +45,9 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * ## The live reading this was cut from * CRM 商机 at 1280×800 zh-CN, light and dark: top bar 48, page bar 44, view * bar 40, header 32, first data row top 164, rows 33, 13px throughout, totals - * on their columns' right edges. The kanban view draws the same two bars — + * on their columns' right edges. After objectstack#35878 (showcase tasks at + * 1312, light and dark): top bar 48, view bar 40, condition row 40, the + * header's top at 128 with and without a condition set. The kanban view draws the same two bars — * pinned in `ListView.viewBarLeading-35548.test.tsx`, where the bars are * drawn for every view type by one component. */ @@ -49,7 +56,8 @@ const ROOT = uiRoot(); const read = (rel: string) => readFileSync(path.join(ROOT, rel), 'utf8'); const FILES = { - pageHeader: 'packages/app-shell/src/layout/PageHeader.tsx', + pageBar: 'packages/app-shell/src/views/objectViewPageHeader.tsx', + viewSettings: 'packages/plugin-list/src/components/ViewSettingsPopover.tsx', chrome: 'packages/app-shell/src/views/objectViewHeaderChrome.tsx', row: 'packages/plugin-list/src/listToolbarRow.ts', list: 'packages/plugin-list/src/ListView.tsx', @@ -77,10 +85,8 @@ function carrying(cls: string, want: string[], where: string): string { return cls; } -// ── page bar ──────────────────────────────────────────────────────────────── -const PAGE_OUTER = `relative shrink-0 border-b ${carrying(pick('pageHeader', /list && '([^']+)'/, 'the list posture height'), ['h-11'], 'page bar')}`; -const PAGE_INNER = carrying(pick('pageHeader', /\{list \? \(\s*
`; return `
-
-

商机

-
-
-
-
${['筛选', '排序', '选项'].map((l) => ``).join('')}
+
+

商机

/
+ + +
+
-
+
@@ -188,10 +194,10 @@ function fixture(locale: 'zh' | 'en' = 'zh'): string { } const CANDIDATES = [ - PAGE_OUTER, PAGE_INNER, PAGE_TITLE, NEW_BUTTON, TOOLBAR_ROW, TOOLBAR_CLUSTER, TEXT_TRIGGER, CONDITION_ROW, + OBJECT_NAME, NEW_BUTTON, TOOLBAR_ROW, TOOLBAR_CLUSTER, TEXT_TRIGGER, CONDITION_ROW, SWITCHER_TRIGGER, DENSITY, ROW_CELL, ROW_ACTION, HEADER_LABEL, SUMMARY_CELL, SUMMARY_RIGHT, TABLE, THEAD, TR, TH, TD, ICON_16, ...COLUMNS.map((c) => c.align), - 'flex min-w-0 flex-1 items-center gap-2 inline-flex h-7 w-7 truncate shrink-0 tabular-nums h-3.5 w-3.5 h-4 w-4 w-10 w-16 justify-end px-3 h-8 py-0 border-t border-b-0', + 'flex min-w-0 flex-1 items-center gap-2 gap-1.5 h-6 w-16 inline-flex h-7 w-7 truncate shrink-0 tabular-nums h-3.5 w-3.5 h-4 w-4 w-10 w-16 justify-end px-3 h-8 py-0 border-t border-b-0', ] .join(' ') .split(/\s+/) @@ -232,7 +238,7 @@ async function measure(page: Page, locale: 'zh' | 'en' = 'zh') { return { key, th: rect(th)!, foot: rect(foot), text: rect(text ?? null), cellText: rect(cellText) }; }); return { - page: rect($('#page'))!, + page: rect($('#page')), viewbar: rect($('#viewbar'))!, condition: rect($('#condition'))!, thead: rect($('thead tr'))!, @@ -257,18 +263,22 @@ async function measure(page: Page, locale: 'zh' | 'en' = 'zh') { test.describe('the list page frame (objectstack#35548)', () => { test('the sources still draw what this file measures', () => { expect(SRC.grid.includes('OBJECT_GRID_TABLE_DENSITY, schema.className'), `${FILES.grid} no longer hands its density to the table`).toBe(true); - expect(SRC.list.includes('TOOLBAR_TEXT_TRIGGER'), `${FILES.list} no longer draws its triggers from TOOLBAR_TEXT_TRIGGER`).toBe(true); + expect(/className=\{cn\(\s*TOOLBAR_TEXT_TRIGGER,[\s\S]{0,200}data-testid="toolbar-display-trigger"/.test(SRC.viewSettings), `${FILES.viewSettings}: View settings no longer draws from TOOLBAR_TEXT_TRIGGER`).toBe(true); + // The view bar names the object as the page's heading (objectstack#35878). + expect(SRC.pageBar.includes('data-testid="list-view-bar-object-name"'), `${FILES.pageBar} no longer names the object in the view bar`).toBe(true); // One trigger: type icon → name → count → caret, in that source order. const at = SWITCHER_PARTS.map((p) => switcherBody.indexOf(`data-testid="list-view-switcher-${p}"`)); expect(at.every((i) => i > 0), `a switcher part is missing: ${JSON.stringify(at)}`).toBe(true); expect([...at].sort((a, b) => a - b)).toEqual(at); }); - test('1280×800: bars 44 and 40, empty condition row 0, header 32, rows 33, first row top ≤ 168', async ({ page }) => { + test('1280×800: no page bar, view bar 40, condition row 40, header 32, rows 33, first row top ≤ 168', async ({ page }) => { const r = await measure(page); - expect(r.page.height).toBeCloseTo(44, 0); + expect(r.page, 'a page bar is drawn above the view bar').toBeNull(); + expect(r.viewbar.top).toBeCloseTo(48, 0); expect(r.viewbar.height).toBeCloseTo(40, 0); - expect(r.condition.height, 'the empty condition row takes height').toBe(0); + expect(r.condition.height, 'the resident condition row').toBeCloseTo(40, 0); + expect(r.thead.top, 'the header under the two rows').toBeCloseTo(128, 0); expect(r.thead.height).toBeCloseTo(32, 0); for (const h of r.rowHeights) expect(h, 'a data row is not 33px').toBeCloseTo(33, 0); expect(r.firstRow.top).toBeLessThanOrEqual(168); @@ -281,12 +291,12 @@ test.describe('the list page frame (objectstack#35548)', () => { expect(r.overflowX).toBe(0); }); - test('13px on the page title, the header, the cells and every bar button', async ({ page }) => { + test('13px on the object name, the header, the cells and every bar button', async ({ page }) => { const { fonts } = await measure(page); expect(fonts.title).toBe('13px'); expect(fonts.header).toBe('13px'); expect(fonts.cell).toBe('13px'); - expect(fonts.bar.length).toBe(5); + expect(fonts.bar.length).toBe(3); for (const f of fonts.bar) expect(f).toBe('13px'); }); diff --git a/ui/e2e/list-left-edge-35663.spec.ts b/ui/e2e/list-left-edge-35663.spec.ts index 78f0d759978..81175ea3867 100644 --- a/ui/e2e/list-left-edge-35663.spec.ts +++ b/ui/e2e/list-left-edge-35663.spec.ts @@ -10,9 +10,10 @@ import { uiRoot } from '../scripts/ui-root.mjs'; /** * GEOMETRY pin for objectstack#35663 (epic #35547): the list page draws ONE - * left edge, 16 px in from the main area, for the page bar's object icon, the - * view bar's view icon, the header's select-all box, every row's checkbox and - * the footer's count; the selection column is 40 px wide (16 inset + 16 box + + * left edge, 16 px in from the main area, for the view bar's object icon (the + * page bar's until objectstack#35878 moved the object's name into the view + * bar), the header's select-all box, every row's checkbox and the footer's + * count; the selection column is 40 px wide (16 inset + 16 box + * 8 gap) on a list that fits and on one that scrolls sideways, before and * after a scroll; the grid draws no row numbers and every row's checkbox is * visible without a hover. @@ -34,9 +35,8 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * * ## What is real here and what is a fixture * - * REAL: plugin-grid's `ObjectGrid` with the `data-table` it draws, and - * app-shell's `PageHeader` in its list posture, bundled by Vite from source and - * mounted with React's client renderer; the view bar's classes are + * REAL: plugin-grid's `ObjectGrid` with the `data-table` it draws, bundled by + * Vite from source and mounted with React's client renderer; the view bar's classes are * `listToolbarRow.ts`'s own constants, imported into the bundle; the view * switcher's trigger class and the record-count bar's class are read out of * `objectViewTitleSwitcher.tsx` and `ListView.tsx` at run time. The stylesheet @@ -68,7 +68,6 @@ const THEME_CSS = source('packages/components/src/index.css'); // Workspace sources by path, never by package name: the e2e type-check program // imports no workspace package (it builds nothing first). const PLUGIN_GRID = source('packages/plugin-grid/src/index.tsx'); -const PAGE_HEADER = source('packages/app-shell/src/layout/PageHeader.tsx'); const TOOLBAR_ROW_TS = source('packages/plugin-list/src/listToolbarRow.ts'); const FIELDS_PKG = source('packages/fields/src/index.tsx'); const REACT_BINDINGS = source('packages/react/src/index.ts'); @@ -90,6 +89,10 @@ const CHART_BAR_CLASS = pick( /const chartPage = [\s\S]*?hasPhoneTitle && \(\s*
h('button', { key: l, className: 'bar-button inline-flex items-center ' + Row.TOOLBAR_TEXT_TRIGGER }, l)))), + h('div', { className: VIEW_BAR_END_CLASS }, + h('button', { className: 'inline-flex h-7 w-7' }), + h('button', { id: 'page-new', className: 'inline-flex h-7 items-center px-2' }, 'New'), + h('button', { className: 'inline-flex h-7 w-7 items-center justify-center' }, box16('page-more'))))), + // The chart bar's lead is the same one node (the object's name and + // the switcher), as \`ViewBarLead\` draws it. h('div', { id: 'chartbar', className: c.chartBarClass }, - h('button', { id: 'chart-switcher', className: c.switcherClass }, box16('chart-view-icon'), h('span', { className: 'truncate' }, 'Pipeline chart'))), + h('div', { className: 'flex min-w-0 items-center' }, + h('span', { className: OBJECT_NAME_CLASS }, box16('chart-page-icon'), h('span', { className: 'truncate' }, 'Contacts'), h('span', null, '/')), + h('button', { id: 'chart-switcher', className: c.switcherClass }, box16('chart-view-icon'), h('span', { className: 'truncate' }, 'Pipeline chart'))), + h('div', { className: VIEW_BAR_END_CLASS }, h('button', { className: 'inline-flex h-7 w-7' }))), h('div', { className: 'flex min-h-0 flex-1 flex-col' }, h(ObjectGrid, { dataSource, @@ -325,6 +336,7 @@ interface Reading { /** Left edges, from the main area's left. */ left: { pageIcon: number; + chartPageIcon: number; viewIcon: number; /** The chart view's view bar (objectstack#35729). */ chartViewIcon: number; @@ -334,7 +346,7 @@ interface Reading { firstHeaderText: number; firstCellText: number; }; - /** Right edges, from the main area's right (distance in): the page bar's button box, the view bar's last label. */ + /** Right edges, from the main area's right (distance in): ⋮ (the bar's last button) and the view bar's cluster. */ right: { pageAction: number; viewCluster: number; footer: number; scrollBox: number }; /** The right padding of the list's view bar and of the chart view's (objectstack#35729). */ barPaddingRight: { list: number; chart: number }; @@ -383,6 +395,7 @@ async function readEdges(page: Page): Promise { overflows: box.scrollWidth > box.clientWidth + 1, left: { pageIcon: x(document.getElementById('page-icon')), + chartPageIcon: x(document.getElementById('chart-page-icon')), viewIcon: x(document.getElementById('view-icon')), chartViewIcon: x(document.getElementById('chart-view-icon')), headerCheckbox: x(document.querySelector('thead [role="checkbox"]')), @@ -392,9 +405,8 @@ async function readEdges(page: Page): Promise { firstCellText: Math.round((textOf(firstCell).left - main.left) * 10) / 10, }, right: { - pageAction: inRight(document.getElementById('page-new')), - // The last trigger's label (the trigger's box is unpainted at rest). - viewCluster: Math.round((main.right - textOf([...document.querySelectorAll('.bar-button')].pop()!).right) * 10) / 10, + pageAction: inRight(document.getElementById('page-more')), + viewCluster: inRight(document.getElementById('cluster')), footer: Math.round((main.right - r(document.getElementById('footer-text')!.parentElement).right) * 10) / 10, scrollBox: inRight(box), }, @@ -452,9 +464,8 @@ function report(testInfo: TestInfo, name: string, value: unknown): void { function expectOnEdge(r: Reading, edge: number, slack = 1): void { const named: Array<[string, number]> = [ - ['page-bar icon', r.left.pageIcon], - ['view-bar icon', r.left.viewIcon], - ['chart view-bar icon', r.left.chartViewIcon], + ['view-bar object icon', r.left.pageIcon], + ['chart view-bar object icon', r.left.chartPageIcon], ['select-all box', r.left.headerCheckbox], ...r.left.rowCheckboxes.map((v, i): [string, number] => [`row ${i + 1} checkbox`, v]), ['footer count', r.left.footerText], @@ -485,9 +496,10 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => { expect(r.rowNumbers, 'the grid draws row numbers').toBe(0); expect(r.rowCheckboxOpacity.length).toBe(12); for (const o of r.rowCheckboxOpacity) expect(o, 'a row checkbox is hidden until hover').toBe(1); - // The right edges: the page bar's action and the view bar's cluster end - // on one line, 16 in, as the footer's padding does. - expect(Math.abs(r.right.pageAction - r.right.viewCluster), `page action ${r.right.pageAction} vs view cluster ${r.right.viewCluster}`).toBeLessThanOrEqual(1); + // The right edges: ⋮, the bar's last control (objectstack#35678), ends + // the view bar's cluster 16 in, as the footer's padding does. + // The cluster's box ends at the bar's own 8px padding; ⋮'s icon, 16 in. + expect(r.right.viewCluster, `view cluster ends ${r.right.viewCluster} in`).toBeLessThan(r.right.pageAction); expect(Math.abs(r.right.pageAction - EDGE)).toBeLessThanOrEqual(1); // The chart view's view bar is the list's (objectstack#35729): its icon // is on the list's view icon (also in `expectOnEdge`), its right end the list bar's. @@ -523,7 +535,6 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => { }; const cards = [...document.querySelectorAll('[data-testid="grid-mobile-card"]')]; return { - pageIcon: x(document.getElementById('page-icon')), viewIcon: x(document.getElementById('view-icon')), chartViewIcon: x(document.getElementById('chart-view-icon')), cardContent: cards.map((c) => x(c.firstElementChild)), @@ -534,7 +545,9 @@ test.describe('the list page draws one left edge (objectstack#35663)', () => { expect(r.cardContent.length).toBe(12); // Below `sm` the chart view's view bar keeps the list bar's `px-2` (objectstack#35729). expect(Math.abs(r.chartViewIcon - r.viewIcon), `chart view icon ${r.chartViewIcon} vs list view icon ${r.viewIcon}`).toBeLessThanOrEqual(1); - for (const at of [r.pageIcon, r.viewIcon, r.chartViewIcon, ...r.cardContent, r.footerText]) { + // The object's name is not drawn below `sm` (the phone's top bar names it, + // objectstack#35878), so the switcher leads the bar there. + for (const at of [r.viewIcon, r.chartViewIcon, ...r.cardContent, r.footerText]) { expect(at).toBeGreaterThanOrEqual(12); } }); diff --git a/ui/e2e/list-toolbar-view-name-phone.spec.ts b/ui/e2e/list-toolbar-view-name-phone.spec.ts index bc83473f907..0cf778b3e0e 100644 --- a/ui/e2e/list-toolbar-view-name-phone.spec.ts +++ b/ui/e2e/list-toolbar-view-name-phone.spec.ts @@ -22,8 +22,8 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * * REAL, read out of the sources at run time: the row's classes (the constants * in `packages/plugin-list/src/listToolbarRow.ts`, by name), the 「In a queue」 - * toggle's and the Filter button's class strings and the phone touch-target - * classes from plugin-list, the switcher's own classes from app-shell's + * toggle's and the View settings trigger's class strings and the phone + * touch-target classes from plugin-list, the switcher's own classes from app-shell's * `objectViewTitleSwitcher.tsx` (the trigger now draws the view type's icon * and the record count beside the name, objectstack#35548), and the phone * title's wrapper from @@ -112,11 +112,13 @@ const SWITCHER_OUTER = (() => { const BUTTON_BASE = 'inline-flex items-center justify-center whitespace-nowrap'; const QUEUE = `${BUTTON_BASE} ${tagClass(listSrc, LIST_FILE, 'data-testid="queue-sitting-filter"', ['shrink-0', 'h-7'])}`; const PHONE_TOUCH_TARGET = constant(read(TOUCH_FILE), TOUCH_FILE, 'PHONE_TOUCH_TARGET'); -// The Filter / Sort / Options triggers draw from one constant (objectstack#35548); -// below `sm` they are icons, their text labels `hidden sm:inline`. +// The bar's icon triggers draw from one constant (objectstack#35548). Since +// objectstack#35878 Filter and Sort live in the condition row, and the bar's +// trigger that reads the constant is View settings, an icon below `sm`. The +// four icon buttons below stand for the bar's tools at their touch size. const TEXT_TRIGGER = constant(rowSrc, ROW_FILE, 'TOOLBAR_TEXT_TRIGGER'); -if (!/className=\{cn\(\s*TOOLBAR_TEXT_TRIGGER,\s*PHONE_TOUCH_TARGET,[\s\S]{0,200}data-testid="toolbar-filter-trigger"/.test(listSrc)) { - throw new Error(`${LIST_FILE}: the Filter trigger no longer draws from TOOLBAR_TEXT_TRIGGER + PHONE_TOUCH_TARGET`); +if (!/className=\{cn\(\s*TOOLBAR_TEXT_TRIGGER,\s*PHONE_TOUCH_TARGET,[\s\S]{0,200}data-testid="toolbar-display-trigger"/.test(read(TOUCH_FILE))) { + throw new Error(`${TOUCH_FILE}: the View settings trigger no longer draws from TOOLBAR_TEXT_TRIGGER + PHONE_TOUCH_TARGET`); } const ICON_BUTTON = `${BUTTON_BASE} ${TEXT_TRIGGER} ${PHONE_TOUCH_TARGET}`; const ICON = 'h-3.5 w-3.5'; diff --git a/ui/packages/app-shell/src/views/ListPersonalizedMarker.tsx b/ui/packages/app-shell/src/views/ListPersonalizedMarker.tsx index 0cd4df6e403..d6d59e339ab 100644 --- a/ui/packages/app-shell/src/views/ListPersonalizedMarker.tsx +++ b/ui/packages/app-shell/src/views/ListPersonalizedMarker.tsx @@ -13,15 +13,17 @@ * (`onSave`): the list on screen becomes the view's stored body. Edits not * saved stay the reader's temporary list state, never written to the view. * - * Below `sm` the trigger is an icon alone (named by its `aria-label`), so on a - * narrow row it never pushes the view name out. + * objectstack#35878 — it ends the condition row under the view bar: + * 「Personalized」 (the trigger, naming what differs) and 「Reset」 beside it, + * one click back to the view. As the list narrows the words 「Personalized」 + * go first, then 「Reset」 folds to its icon. */ import { useState } from 'react'; import { Button, Popover, PopoverContent, PopoverTrigger, cn } from '@object-ui/components'; import { useObjectTranslation } from '@object-ui/i18n'; import type { ListViewProps } from '@object-ui/plugin-list'; -import { RotateCcw, Save, UserPen } from 'lucide-react'; +import { RotateCcw, Save } from 'lucide-react'; /** One part of a list that can differ from its view (`ListView`'s vocabulary). */ export type ListPersonalizationPart = Parameters>[0][number]; @@ -70,23 +72,22 @@ export function ListPersonalizedMarker({ inlineEdit: t('console.objectView.personalizedParts.inlineEdit'), }; const label = t('console.objectView.personalized'); + // The short 「Reset」 of the condition row (the popover keeps its longer one). + const resetLabel = t('listConditions.chips.reset'); return ( + @@ -134,5 +135,19 @@ export function ListPersonalizedMarker({ + + ); } diff --git a/ui/packages/app-shell/src/views/ObjectView.bulkWiredHeaderDuplicate-12462.test.tsx b/ui/packages/app-shell/src/views/ObjectView.bulkWiredHeaderDuplicate-12462.test.tsx index d2918a78c51..68255245c3b 100644 --- a/ui/packages/app-shell/src/views/ObjectView.bulkWiredHeaderDuplicate-12462.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.bulkWiredHeaderDuplicate-12462.test.tsx @@ -181,7 +181,7 @@ function mountLeads(viewName: keyof typeof LIST_VIEWS) { /** The page header, once its schema-driven toolbar has drawn the plain action. */ async function headerWithToolbar(): Promise { - const header = await screen.findByTestId('page-header', undefined, { timeout: 5000 }); + const header = await screen.findByTestId('list-view-bar-actions', undefined, { timeout: 5000 }); await within(header).findByRole('button', { name: /Refresh Scores/ }, { timeout: 5000 }); return header; } @@ -294,7 +294,7 @@ describe('objectui#12462 — the deep link arms only what the header draws', () // The header has drawn its toolbar and the grid its rows, so an armed link // would have run by now. `hidden: true`: an open param dialog takes the // page out of the accessibility tree, and this wait must not be what fails. - const header = await screen.findByTestId('page-header', undefined, { timeout: 5000 }); + const header = await screen.findByTestId('list-view-bar-actions', undefined, { timeout: 5000 }); await within(header).findByRole('button', { name: /Refresh Scores/, hidden: true }, { timeout: 5000 }); await rowBoxes(); diff --git a/ui/packages/app-shell/src/views/ObjectView.chartViewTabs-13114.test.tsx b/ui/packages/app-shell/src/views/ObjectView.chartViewTabs-13114.test.tsx index 5151fa73c98..d80498d4dc9 100644 --- a/ui/packages/app-shell/src/views/ObjectView.chartViewTabs-13114.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.chartViewTabs-13114.test.tsx @@ -154,7 +154,7 @@ const chartFace = () => /** The grid's toolbar has drawn: its Filter control is on screen. */ const listToolbar = () => - waitFor(() => expect(screen.getByTestId('toolbar-filter-trigger')).toBeInTheDocument(), { timeout: 5000 }); + waitFor(() => expect(screen.getByTestId('condition-add-filter')).toBeInTheDocument(), { timeout: 5000 }); afterEach(() => { cleanup(); diff --git a/ui/packages/app-shell/src/views/ObjectView.emptyColumnsNoProjection-10694.test.tsx b/ui/packages/app-shell/src/views/ObjectView.emptyColumnsNoProjection-10694.test.tsx index 2005577cd07..3f77fac3073 100644 --- a/ui/packages/app-shell/src/views/ObjectView.emptyColumnsNoProjection-10694.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.emptyColumnsNoProjection-10694.test.tsx @@ -301,7 +301,7 @@ async function hideThroughToggle(field: string): Promise { } const panel = await screen.findByTestId('view-settings-content'); if (!within(panel).queryByTestId('options-page-fields')) { - fireEvent.click(within(panel).getByTestId('options-row-fields')); + fireEvent.click(within(panel).getByTestId('options-add-column')); } fireEvent.click(await within(panel).findByTestId(`options-fields-hide-${field}`)); } @@ -525,7 +525,7 @@ describe('an unprojected view applies neither hiddenFields nor fieldOrder on the expect(drawn).not.toContain('owner'); fireEvent.click(screen.getByTestId('toolbar-display-trigger')); const panel = await screen.findByTestId('view-settings-content'); - fireEvent.click(within(panel).getByTestId('options-row-fields')); + fireEvent.click(within(panel).getByTestId('options-add-column')); await within(panel).findByText(/^region$/i); expect(within(panel).queryByText(/^owner$/i)).toBeNull(); @@ -588,7 +588,7 @@ describe('an unprojected view applies neither hiddenFields nor fieldOrder on the await mountRoute(listViews, PROBE_ID, makeDataSource()); fireEvent.click(screen.getByTestId('toolbar-display-trigger')); const panel = await screen.findByTestId('view-settings-content'); - fireEvent.click(within(panel).getByTestId('options-row-fields')); + fireEvent.click(within(panel).getByTestId('options-add-column')); await within(panel).findByText(/^region$/i); expect(within(panel).queryByText(/^owner$/i)).toBeNull(); diff --git a/ui/packages/app-shell/src/views/ObjectView.externalRefreshSum-10572.test.tsx b/ui/packages/app-shell/src/views/ObjectView.externalRefreshSum-10572.test.tsx index cc57531e680..d1c8ed59be4 100644 --- a/ui/packages/app-shell/src/views/ObjectView.externalRefreshSum-10572.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.externalRefreshSum-10572.test.tsx @@ -98,7 +98,7 @@ const OBJECT_NAME = 'duly_task'; /** * The view under test is always `all`. `ListView`'s own toolbar Filter control - * (`toolbar-filter-trigger`) is the node whose identity (a) reads (the host's + * (`condition-add-filter`) is the node whose identity (a) reads (the host's * tab strip in `list-toolbar-leading` was, until objectstack#27594 moved view * switching to the page title; the view description's own row was, until * objectui#12528). diff --git a/ui/packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx b/ui/packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx index 9beee455b87..8b0d081c4d8 100644 --- a/ui/packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.headerFold-12705.test.tsx @@ -88,7 +88,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.headerSelectionGate-27831.test.tsx b/ui/packages/app-shell/src/views/ObjectView.headerSelectionGate-27831.test.tsx index da76828e4b2..15d274e1bef 100644 --- a/ui/packages/app-shell/src/views/ObjectView.headerSelectionGate-27831.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.headerSelectionGate-27831.test.tsx @@ -34,6 +34,9 @@ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +// `ObjectView` reaches a dynamic `import('@objectstack/lint')`: pay its load at +// collection, never inside a case's clocked window (`check:test-source-alias`). +import '@objectstack/lint'; import { render, cleanup, screen, fireEvent, waitFor, act, within } from '@testing-library/react'; import { MemoryRouter, Routes, Route } from 'react-router-dom'; import { toast } from 'sonner'; @@ -191,7 +194,7 @@ const callsTo = (url: string) => fetchSpy.mock.calls.filter(([u]) => String(u).i /** The page header, once its toolbar has drawn the control action. */ async function header(): Promise { - const el = await screen.findByTestId('page-header', undefined, { timeout: 5000 }); + const el = await screen.findByTestId('list-view-bar-actions', undefined, { timeout: 5000 }); await within(el).findByRole('button', { name: /Export Tasks/ }, { timeout: 5000 }); return el; } diff --git a/ui/packages/app-shell/src/views/ObjectView.importPredicates.test.tsx b/ui/packages/app-shell/src/views/ObjectView.importPredicates.test.tsx index cd367f3611c..6e2ff14ae51 100644 --- a/ui/packages/app-shell/src/views/ObjectView.importPredicates.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.importPredicates.test.tsx @@ -99,7 +99,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.labelLessViewTab-12774.test.tsx b/ui/packages/app-shell/src/views/ObjectView.labelLessViewTab-12774.test.tsx index 9af93bd34ef..97d71bb97cd 100644 --- a/ui/packages/app-shell/src/views/ObjectView.labelLessViewTab-12774.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.labelLessViewTab-12774.test.tsx @@ -93,7 +93,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.listActionsReadGate-12109.test.tsx b/ui/packages/app-shell/src/views/ObjectView.listActionsReadGate-12109.test.tsx index 1687bc6bf55..0dda4bcc3e7 100644 --- a/ui/packages/app-shell/src/views/ObjectView.listActionsReadGate-12109.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.listActionsReadGate-12109.test.tsx @@ -66,7 +66,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.listPersonalized-28950.test.tsx b/ui/packages/app-shell/src/views/ObjectView.listPersonalized-28950.test.tsx index 941d967f5a5..ae23b8a5b30 100644 --- a/ui/packages/app-shell/src/views/ObjectView.listPersonalized-28950.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.listPersonalized-28950.test.tsx @@ -90,7 +90,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ listProps = props; // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); diff --git a/ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx b/ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx index 350bd633e75..37dff773b83 100644 --- a/ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.listUrlState-11860.test.tsx @@ -336,9 +336,10 @@ describe('a list is a link (objectui#11860)', () => { await settle(); fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); await settle(); - // By name: the Filter trigger is an icon button with no label text - // (objectui#12695); with a filter applied its name is "Filter, N active". - const filterButton = screen.getByRole('button', { name: /^Filter, \d+ active$/ }); + // The condition row's add-filter control (objectstack#35878): 「+」 once a + // filter is applied. + const filterButton = screen.getByTestId('condition-add-filter'); + expect(filterButton).not.toHaveAttribute('data-empty'); fireEvent.click(filterButton); await settle(); fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); diff --git a/ui/packages/app-shell/src/views/ObjectView.objectBoundActions-7234.test.tsx b/ui/packages/app-shell/src/views/ObjectView.objectBoundActions-7234.test.tsx index c8321fae0f6..3628bc4bf3d 100644 --- a/ui/packages/app-shell/src/views/ObjectView.objectBoundActions-7234.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.objectBoundActions-7234.test.tsx @@ -145,7 +145,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.objectListTitle-27950.test.tsx b/ui/packages/app-shell/src/views/ObjectView.objectListTitle-27950.test.tsx index 78e1149eb85..0d576906ba1 100644 --- a/ui/packages/app-shell/src/views/ObjectView.objectListTitle-27950.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.objectListTitle-27950.test.tsx @@ -171,7 +171,7 @@ function mount(entry: string, { sidebarOpen = true }: { sidebarOpen?: boolean } /** The list's toolbar has drawn: its Filter control is on screen. */ const listToolbar = () => - waitFor(() => expect(screen.getByTestId('toolbar-filter-trigger')).toBeInTheDocument(), { timeout: 5000 }); + waitFor(() => expect(screen.getByTestId('condition-add-filter')).toBeInTheDocument(), { timeout: 5000 }); const heading = () => screen.getByRole('heading', { level: 1 }); /** The view bar's leading slot: the one view switcher (objectstack#35548). */ @@ -219,7 +219,9 @@ describe('objectstack#27950, as redrawn by objectstack#35548 — the page bar na mount('/apps/crm/crm_lead/view/mine?recordId=lead_1'); await listToolbar(); expect(screen.getAllByTestId('list-view-switcher')).toHaveLength(1); - expect(screen.getAllByTestId('page-header').filter((h) => h.dataset.posture === 'list')).toHaveLength(1); + // objectstack#35878: the view bar names the object; no page bar is drawn. + expect(screen.getAllByTestId('list-view-bar-object')).toHaveLength(1); + expect(screen.queryAllByTestId('page-header').filter((h) => h.dataset.posture === 'list')).toHaveLength(0); }); it('a view with no label reads the plural in the switcher', async () => { diff --git a/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx b/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx index 3b3073a7d99..da24e991b33 100644 --- a/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.personalViews-29635.test.tsx @@ -211,7 +211,7 @@ function mountLeads( /** The list's toolbar has drawn: its Filter control is on screen. */ const listToolbar = () => - waitFor(() => expect(screen.getByTestId('toolbar-filter-trigger')).toBeInTheDocument(), { timeout: 5000 }); + waitFor(() => expect(screen.getByTestId('condition-add-filter')).toBeInTheDocument(), { timeout: 5000 }); /** The reader's pinned view of `crm_lead`, as the workspace preference keeps it. */ const PIN_KEY = 'os:pref:list.view.pinned@object:crm_lead'; @@ -399,7 +399,7 @@ describe('objectstack#29635 — My views in the list view switcher', () => { await waitFor(() => expect(dataSource.find.mock.calls.some(([r]) => r === 'sys_personal_view')).toBe(true)); // No list of the default view is drawn or read while the pin may name a personal view. await new Promise((r) => setTimeout(r, 50)); - expect(screen.queryByTestId('toolbar-filter-trigger')).toBeNull(); + expect(screen.queryByTestId('condition-add-filter')).toBeNull(); expect(leadReads(dataSource)).toHaveLength(0); land({ data: [OWN] }); @@ -605,14 +605,15 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r const romeLink = (path: string) => `${path}?${applyListStateParams(new URLSearchParams(), { filters: ROME as never }).toString()}`; const storeListState = (state: unknown) => localStorage.setItem(localListStateKey('u1', 'crm_lead'), JSON.stringify(state)); const storedListState = () => JSON.parse(localStorage.getItem(localListStateKey('u1', 'crm_lead')) ?? '{}'); - const filterTrigger = () => screen.getByTestId('toolbar-filter-trigger'); + const filterTrigger = () => screen.getByTestId('condition-add-filter'); const lastLeadRead = (dataSource: ReturnType['dataSource']) => JSON.stringify(leadReads(dataSource).at(-1)); it('opening a personal view seeds its conditions as panel rows, applied once, and the list is not personalized', async () => { const { dataSource } = mountLeads('/apps/crm/crm_lead/view/pv_mine'); await listToolbar(); expect(switcher()).toHaveTextContent('Paris leads'); - await waitFor(() => expect(filterTrigger()).toHaveAttribute('aria-label', 'Filter, 1 active')); + // objectstack#35878: with a filter set, the condition row's add control is 「+」. + await waitFor(() => expect(filterTrigger()).not.toHaveAttribute('data-empty')); fireEvent.click(filterTrigger()); // The trigger opens the shared field list (objectstack#35549); the panel // rows are its advanced step. @@ -726,7 +727,7 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r await listToolbar(); await waitFor(() => expect(lastLeadRead(dataSource)).toContain('Paris')); expect(lastLeadRead(dataSource)).toContain('open'); - expect(filterTrigger()).toHaveAttribute('aria-label', 'Filter'); + expect(filterTrigger()).toHaveAttribute('data-empty', 'true'); }); it('Save as my view leaves the view it came from without the temporary conditions and not personalized', async () => { @@ -752,7 +753,7 @@ describe('objectstack#30073 — a personal view\'s conditions are Filter panel r expect(switcher()).toHaveTextContent('View 1'); await waitFor(() => expect(leadReads(again.dataSource).length).toBeGreaterThan(0)); expect(lastLeadRead(again.dataSource)).not.toContain('Rome'); - expect(filterTrigger()).toHaveAttribute('aria-label', 'Filter'); + expect(filterTrigger()).toHaveAttribute('data-empty', 'true'); expect(screen.queryByTestId('list-personalized-marker')).toBeNull(); }); }); diff --git a/ui/packages/app-shell/src/views/ObjectView.refreshInPlace-10035.test.tsx b/ui/packages/app-shell/src/views/ObjectView.refreshInPlace-10035.test.tsx index 6d2cece7448..593eb79bb1d 100644 --- a/ui/packages/app-shell/src/views/ObjectView.refreshInPlace-10035.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.refreshInPlace-10035.test.tsx @@ -133,7 +133,7 @@ const OBJECT_NAME = 'duly_task'; /** * The view under test is always `all`. `ListView`'s own toolbar Filter control - * (`toolbar-filter-trigger`) is the node whose identity (a) reads (the host's + * (`condition-add-filter`) is the node whose identity (a) reads (the host's * tab strip in `list-toolbar-leading` was, until objectstack#27594 moved view * switching to the page title; the view description's own row was, until * objectui#12528). @@ -260,7 +260,7 @@ function GanttStandIn({ schema }: any) { const ganttInstance = () => screen.getByTestId('gantt-stand-in').dataset.instance; /** A node rendered inside `ListView` — replaced wholesale by a key remount. */ -const listNode = () => screen.getByTestId('toolbar-filter-trigger'); +const listNode = () => screen.getByTestId('condition-add-filter'); beforeEach(() => { cleanup(); diff --git a/ui/packages/app-shell/src/views/ObjectView.servedViewLabel-11295.test.tsx b/ui/packages/app-shell/src/views/ObjectView.servedViewLabel-11295.test.tsx index 0933d1260df..3de7a540efc 100644 --- a/ui/packages/app-shell/src/views/ObjectView.servedViewLabel-11295.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.servedViewLabel-11295.test.tsx @@ -101,7 +101,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.starredView-27594.test.tsx b/ui/packages/app-shell/src/views/ObjectView.starredView-27594.test.tsx index 2d520871e49..be49dd2ab2a 100644 --- a/ui/packages/app-shell/src/views/ObjectView.starredView-27594.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.starredView-27594.test.tsx @@ -72,7 +72,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ...(await importOriginal()), ListView: (props: any) => { const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); vi.mock('@object-ui/plugin-view', async (importOriginal) => ({ diff --git a/ui/packages/app-shell/src/views/ObjectView.titleViewSwitcher-27594.test.tsx b/ui/packages/app-shell/src/views/ObjectView.titleViewSwitcher-27594.test.tsx index f3e7ea26a89..83c5b147029 100644 --- a/ui/packages/app-shell/src/views/ObjectView.titleViewSwitcher-27594.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.titleViewSwitcher-27594.test.tsx @@ -153,7 +153,7 @@ function mountLeads(entry = '/apps/crm/crm_lead/view/v1') { /** The list's toolbar has drawn: its Filter control is on screen. */ const listToolbar = () => - waitFor(() => expect(screen.getByTestId('toolbar-filter-trigger')).toBeInTheDocument(), { timeout: 5000 }); + waitFor(() => expect(screen.getByTestId('condition-add-filter')).toBeInTheDocument(), { timeout: 5000 }); /** The reader's pinned view of `crm_lead`, as the workspace preference keeps it. */ const PIN_KEY = 'os:pref:list.view.pinned@object:crm_lead'; diff --git a/ui/packages/app-shell/src/views/ObjectView.tsx b/ui/packages/app-shell/src/views/ObjectView.tsx index deefdacd349..dd15ef00932 100644 --- a/ui/packages/app-shell/src/views/ObjectView.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.tsx @@ -12,7 +12,7 @@ import type { ColumnSummary } from '@objectstack/spec/ui'; import type { ListColumn } from '@object-ui/types'; import { columnsWithSummary, declaredColumnFields } from './columnSummaryWrite.js'; -import { useMemo, useState, useCallback, useEffect, useRef, lazy, Suspense } from 'react'; +import { useMemo, useState, useCallback, useEffect, useRef, lazy, Suspense, type ReactNode } from 'react'; import { useParams, useSearchParams, useNavigate, useLocation, useHref, createSearchParams } from 'react-router-dom'; import { resolveAffordance, type FilterTokenScope, type SchemaLike } from '@object-ui/core'; import { useObjectListPreferences } from '../context/ListPreferencesProvider.js'; @@ -84,7 +84,14 @@ import { useObjectViewListUrlState, useObjectViewUrlFilters } from './objectView import { useObjectViewTitleSwitcher } from './objectViewTitleSwitcher.js'; import { useObjectViewPluginSchema } from './objectViewPluginSchema.js'; import { useObjectViewHeaderChrome } from './objectViewHeaderChrome.js'; -import { ObjectViewPageHeader } from './objectViewPageHeader.js'; +import { + ListViewBarHostContext, + OBJECT_VIEW_PAGE_COLUMN_ATTR, + ObjectViewBarObjectName, + ObjectViewBarTrailing, + ObjectViewPageHeader, + type ObjectViewPageBarProps, +} from './objectViewPageHeader.js'; import { ObjectViewRecordOverlay } from './objectViewRecordOverlay.js'; import { useObjectViewListRenderer } from './objectViewListRenderer.js'; import { ListPersonalizedMarker } from './ListPersonalizedMarker.js'; @@ -1044,6 +1051,14 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co onDeletePersonalView: personalViewsReady ? (id: string) => { void handleDeletePersonalView(id); } : undefined, }); + // objectstack#35878 — the page bar's props, for the view bar's right end + // (`viewBarTrailing` below). Filled on every render once the header chrome + // is known; the end reads it when it draws, after this render. + const pageBarPropsRef = useRef(null); + // Whether a list's view bar draws the page's name and acts: then the page + // bar above it is not drawn (`ListViewBarHostContext`). + const [listBarHosted, setListBarHosted] = useState(false); + // objectstack#25992 slice 11a: the column-declaration flags, the held list refs and // `renderListView` moved to `./objectViewListRenderer.tsx`. const { renderListView } = useObjectViewListRenderer({ @@ -1080,12 +1095,23 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co // objectstack#35548 — the view switcher leads the list's view bar at // every width (on a phone since objectstack#27058); the page bar only // names the object. + // objectstack#35878 — and from `sm` up the object's name leads it, + // 「Object / View ▾」: the page draws no page bar of its own above the + // list. The 「Personalized · Reset」 marker ends the condition row. phoneTitle: titleSwitcher ? ( + {titleSwitcher} - {personalizedMarker} ) : null, + // The page's acts, after the list's search: read from the ref the page + // fills once its header chrome is known (below). + viewBarTrailing: titleSwitcher + ? (tools: ReactNode) => (pageBarPropsRef.current + ? + : tools) + : null, + conditionRowEnd: personalizedMarker, handleListPersonalizationChange, urlFilters, initialUfSelections, @@ -1176,6 +1202,25 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co titleSwitcher, }); + const pageBarProps: ObjectViewPageBarProps = { + objectDef, + objectPluralLabel: listTitleOf, + objectDesc, + createButton, + importShown, + setShowImport, + importDisabled, + t, + listActions, + isEnvironmentList, + headerToolbarActions, + environmentEntitlements, + toolbarBar, + listFavorite, + foldedHeaderActions, + }; + pageBarPropsRef.current = pageBarProps; + // The list itself: one element whether or not a record is open // (objectstack#27545), so a `?recordId=` change — a row click, a step — // hands React the same element and re-renders none of the list. Memoised @@ -1210,7 +1255,8 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co // The page column — header, list, panels — that the record drawer draws // over (objectstack#27545); it keeps its full width (objectstack#28915). const pageColumn = ( -
+ +
{/* 1. Header with breadcrumb + description. The managed-by badge sits inline with the title so the lifecycle bucket (system / config / append-only / @@ -1230,23 +1276,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co toolbar row, beside its filter / sort / display tools (objectstack#27058). */} {/* objectstack#25992 slice 10: the header moved to `./objectViewPageHeader.tsx`. */} - + {/* objectstack#35878 — not drawn while the list's view bar + names the object and carries its acts. */} + {!listBarHosted && } {/* Floating "+" action button — phone-only counterpart to the PageHeader's primary create action we just hid. Positioned @@ -1425,6 +1457,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co />
+ ); return ( diff --git a/ui/packages/app-shell/src/views/ObjectView.userListState-12418.test.tsx b/ui/packages/app-shell/src/views/ObjectView.userListState-12418.test.tsx index 7239ab8d207..51f16e366be 100644 --- a/ui/packages/app-shell/src/views/ObjectView.userListState-12418.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.userListState-12418.test.tsx @@ -128,7 +128,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ listProps = props; // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); diff --git a/ui/packages/app-shell/src/views/ObjectView.viewRefusal-12112.test.tsx b/ui/packages/app-shell/src/views/ObjectView.viewRefusal-12112.test.tsx index ce5b8d9e4d2..057fa318213 100644 --- a/ui/packages/app-shell/src/views/ObjectView.viewRefusal-12112.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.viewRefusal-12112.test.tsx @@ -72,7 +72,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ ListView: (props: any) => { // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); // The list area, reduced to the view it was handed. diff --git a/ui/packages/app-shell/src/views/ObjectView.viewWriteRefusal-11583.test.tsx b/ui/packages/app-shell/src/views/ObjectView.viewWriteRefusal-11583.test.tsx index 20d43c29f72..ccb037e1dc3 100644 --- a/ui/packages/app-shell/src/views/ObjectView.viewWriteRefusal-11583.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.viewWriteRefusal-11583.test.tsx @@ -130,7 +130,13 @@ vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ listSchema = props.schema; // objectstack#35548 — the view switcher leads the list's view bar: draw the slot. const lead = props.toolbarLeading; - return typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null; + // objectstack#35878 — the condition row's end (the 「Personalized」 marker) draws too. + return ( + <> + {typeof lead === 'function' ? lead({ recordCount: null, layout: 'grid' }) : lead ?? null} + {props.conditionRowEnd ?? null} + + ); }, })); diff --git a/ui/packages/app-shell/src/views/__tests__/PageView.listViewAddRecord-13089.test.tsx b/ui/packages/app-shell/src/views/__tests__/PageView.listViewAddRecord-13089.test.tsx index a2072de2319..b09c5938e82 100644 --- a/ui/packages/app-shell/src/views/__tests__/PageView.listViewAddRecord-13089.test.tsx +++ b/ui/packages/app-shell/src/views/__tests__/PageView.listViewAddRecord-13089.test.tsx @@ -231,7 +231,7 @@ function mount(nodes: Array>) { const location = () => new URL(screen.getByTestId('location').textContent ?? '', 'http://x'); const addButtons = () => screen.queryAllByTestId('add-record-button'); /** The list's toolbar is up: the Add button, when offered, is drawn in it. */ -const listDrawn = () => screen.findByTestId('toolbar-filter-trigger', undefined, { timeout: 5000 }); +const listDrawn = () => screen.findByTestId('condition-add-filter', undefined, { timeout: 5000 }); beforeAll(() => { Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1280 }); diff --git a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx index 34c78705097..c75a5710d3f 100644 --- a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx +++ b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx @@ -102,6 +102,8 @@ export function useObjectViewListRenderer({ openInPanel, rowOpensRecord, phoneTitle, + viewBarTrailing, + conditionRowEnd, handleListPersonalizationChange, urlFilters, initialUfSelections, @@ -149,6 +151,15 @@ export function useObjectViewListRenderer({ * `null` with no view to switch. */ phoneTitle: ReactNode; + /** + * objectstack#35878 — the right end of the view bar, given the list's own + * tools there (its search): the page's create button and ⋮ More after + * them. `null` ⇒ the list's search alone. Called afresh on every render + * of the page, read through a store like the lead. + */ + viewBarTrailing: ((tools: ReactNode) => ReactNode) | null; + /** objectstack#35878 — the condition row's right end: the 「Personalized · Reset」 marker, or `null`. */ + conditionRowEnd: ReactNode; /** objectstack#28950 — what of the list differs from the view, keyed by the list identity. */ handleListPersonalizationChange: ReturnType['handleListPersonalizationChange']; urlFilters: ReturnType['urlFilters']; @@ -202,6 +213,15 @@ export function useObjectViewListRenderer({ leadStore.set(phoneTitle); }); const hasPhoneTitle = phoneTitle != null; + // objectstack#35878 — the view bar's right end and the condition row's, + // read through stores the same way, so a change in them redraws only them. + const [trailStore] = useState(() => createLeadStore<((tools: ReactNode) => ReactNode) | null>(viewBarTrailing)); + const [rowEndStore] = useState(() => createLeadStore(conditionRowEnd)); + useLayoutEffect(() => { + trailStore.set(viewBarTrailing); + rowEndStore.set(conditionRowEnd); + }); + const hasViewBarTrailing = viewBarTrailing != null; // objectui#10694 — does the active view, as AUTHORED, declare a non-empty // `columns`? Booleans, so the relay keys on values and not on the memo's // Set (AGENTS.md #10). @@ -384,8 +404,10 @@ export function useObjectViewListRenderer({ const chartPage = (chartFace: ReactNode) => (
{hasPhoneTitle && ( -
+
+ {/* objectstack#35878 — the page's acts end this bar too. */} + {hasViewBarTrailing && }
)} {chartFace} @@ -1154,22 +1176,26 @@ export function useObjectViewListRenderer({ ) : null} + // objectstack#35878 — the bar's right end: the search, then + // the page's acts; and the condition row's right end. + toolbarTrailing={hasViewBarTrailing ? (tools) => : undefined} + conditionRowEnd={hasPhoneTitle ? : undefined} dataSource={ds} /> ); - }, [activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, managedUsers, managedUserMarker, openInPanel, rowOpensRecord, handleListRowsChange, handleListTotalChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, offersSummaryPick, summaryPickKey, previewDrafts, previewDataSource, unpublishedObjects]); + }, [hasViewBarTrailing, trailStore, rowEndStore, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, managedUsers, managedUserMarker, openInPanel, rowOpensRecord, handleListRowsChange, handleListTotalChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, offersSummaryPick, summaryPickKey, previewDrafts, previewDataSource, unpublishedObjects]); return { renderListView }; } -/** The page's current view-bar lead (the switcher), read by `ViewBarLead`. */ -interface LeadStore { - get: () => ReactNode; - set: (next: ReactNode) => void; +/** The page's current view-bar lead (the switcher), read by `ViewBarLead`; also its right ends. */ +interface LeadStore { + get: () => T; + set: (next: T) => void; subscribe: (listener: () => void) => () => void; } -function createLeadStore(initial: ReactNode): LeadStore { +function createLeadStore(initial: T): LeadStore { let current = initial; const listeners = new Set<() => void>(); return { @@ -1190,3 +1216,9 @@ function createLeadStore(initial: ReactNode): LeadStore { function ViewBarLead({ store }: { store: LeadStore }) { return <>{useSyncExternalStore(store.subscribe, store.get, store.get)}; } + +/** Draws the view bar's right end from the store, around the list's own `tools`. */ +function ViewBarTrailing({ store, tools }: { store: LeadStore<((tools: ReactNode) => ReactNode) | null>; tools: ReactNode }) { + const render = useSyncExternalStore(store.subscribe, store.get, store.get); + return <>{render ? render(tools) : tools}; +} diff --git a/ui/packages/app-shell/src/views/objectViewPageHeader.tsx b/ui/packages/app-shell/src/views/objectViewPageHeader.tsx index 9ee4297712e..f7ced1166ca 100644 --- a/ui/packages/app-shell/src/views/objectViewPageHeader.tsx +++ b/ui/packages/app-shell/src/views/objectViewPageHeader.tsx @@ -10,10 +10,11 @@ * value is passed in as a prop. */ -import { createElement, useCallback, useState } from 'react'; -import type { Dispatch, SetStateAction } from 'react'; +import { createContext, createElement, useCallback, useContext, useLayoutEffect, useState } from 'react'; +import type { Dispatch, ReactNode, SetStateAction } from 'react'; import { Button, + cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, @@ -47,23 +48,7 @@ import { useListPageBarHost } from '@object-ui/plugin-grid'; */ const LIST_HEADER_COMPACT_WIDTH = 768; -export function ObjectViewPageHeader({ - objectDef, - objectPluralLabel, - objectDesc, - createButton, - importShown, - setShowImport, - importDisabled, - t, - listActions, - isEnvironmentList, - headerToolbarActions, - environmentEntitlements, - toolbarBar, - listFavorite, - foldedHeaderActions, -}: { +export interface ObjectViewPageBarProps { objectDef: ConsoleObjectViewProps['objects'][number]; objectPluralLabel: ReturnType['objectPluralLabel']; objectDesc: ReturnType['objectDescription']; @@ -79,7 +64,108 @@ export function ObjectViewPageHeader({ toolbarBar: ReturnType['toolbarBar']; listFavorite: ReturnType; foldedHeaderActions: ReturnType['foldedHeaderActions']; -}) { +} + +/** + * objectstack#35878 — the page's own acts, after the list's search at the + * right end of the view bar (or of the page bar where no view bar draws them): + * the schema-driven toolbar, the create button, then ⋮ More, last at the right + * edge (objectstack#35678). The ⋮ menu holds what is not used every time: the + * object's description, Import and the favorites entry (objectui#12427). + */ +export function ObjectViewPageBarActions({ + objectDef, + objectDesc, + createButton, + importShown, + setShowImport, + importDisabled, + t, + listActions, + isEnvironmentList, + headerToolbarActions, + environmentEntitlements, + toolbarBar, + listFavorite, +}: ObjectViewPageBarProps) { + const description = objectDef.description ? objectDesc(objectDef) : undefined; + // The ⋮ menu: the description (no longer a resident subtitle), Import and + // the favorites entry — the page's once-in-a-while acts. + const moreShown = !!description || importShown || !!listFavorite; + return ( + <> + {/* Schema-driven toolbar actions */} + {listActions?.some((a: any) => a.locations?.includes('list_toolbar')) && ( + isEnvironmentList ? ( + + ) : ( + + ) + )} + + {/* Primary action (see `createButton`), then ⋮ More last. */} + {createButton} + + {moreShown && ( + + + + + + {description && ( + <> + + {description} + + {(importShown || listFavorite) && } + + )} + {/* [#5142] `objectCanImport && importVisible` — the object-level + verdict, then the toolbar-scope `visibleWhen` layer on top of + it. Greyed, not gone, is the `disabledWhen` case. */} + {importShown && ( + setShowImport(true)} + disabled={importDisabled} + title={t('console.objectView.importTitle')} + data-testid="object-view-import-button" + > + + {t('console.objectView.import')} + + )} + {listFavorite && ( + + )} + + + )} + + + ); +} + +export function ObjectViewPageHeader(props: ObjectViewPageBarProps) { + const { objectDef, objectPluralLabel, foldedHeaderActions } = props; + const actionProps = props; const pluralLabel = objectPluralLabel(objectDef); // objectstack#35554 — the page bar's selection slot (`useListPageBarHost`, // `@object-ui/plugin-grid`). The list in this page column fills it while @@ -91,10 +177,6 @@ export function ObjectViewPageHeader({ setPageColumn(el?.parentElement ?? null); }, []); const pageBar = useListPageBarHost(selectionSlot, pageColumn); - const description = objectDef.description ? objectDesc(objectDef) : undefined; - // The ⋮ menu: the description (no longer a resident subtitle), Import and - // the favorites entry — the page's once-in-a-while acts. - const moreShown = !!description || importShown || !!listFavorite; return (
{/* objectstack#35554 — the selection face: the object's name, then @@ -129,77 +211,106 @@ export function ObjectViewPageHeader({ // which react-hooks/static-components refuses in tag position // (the convention ObjectDataPage set). icon={createElement(getIcon((objectDef as any)?.icon), { className: 'h-4 w-4' })} - actions={ - <> - {/* Schema-driven toolbar actions */} - {listActions?.some((a: any) => a.locations?.includes('list_toolbar')) && ( - isEnvironmentList ? ( - - ) : ( - - ) - )} - - {moreShown && ( - - - - - - {description && ( - <> - - {description} - - {(importShown || listFavorite) && } - - )} - {/* [#5142] `objectCanImport && importVisible` — the object-level - verdict, then the toolbar-scope `visibleWhen` layer on top of - it. Greyed, not gone, is the `disabledWhen` case. */} - {importShown && ( - setShowImport(true)} - disabled={importDisabled} - title={t('console.objectView.importTitle')} - data-testid="object-view-import-button" - > - - {t('console.objectView.import')} - - )} - {listFavorite && ( - - )} - - - )} - - {/* Primary action (see `createButton`), last in the bar. */} - {createButton} - - } + actions={} foldedActions={foldedHeaderActions} compactBelow={LIST_HEADER_COMPACT_WIDTH} />
); } + +/** + * objectstack#35878 — told when the list's view bar draws the page's name and + * acts (`ObjectViewBarTrailing` is mounted): the page then draws no page bar + * of its own, so the list has two rows above it, not three. Provided by the + * page column; absent ⇒ nothing listens and the page bar stays. + */ +export const ListViewBarHostContext = createContext<((hosted: boolean) => void) | null>(null); + +/** The page column's marker: the scope a view bar's selection slot speaks for. */ +export const OBJECT_VIEW_PAGE_COLUMN_ATTR = 'data-object-view-page-column'; + +/** + * The view bar's object name. `pl-1.5` matches the switcher's own 6px padding, + * so the object's icon starts on the list page's 16px line (objectstack#35663): + * the bar's left padding is 10px from `sm` up. + */ +export const VIEW_BAR_OBJECT_NAME = 'hidden min-w-0 shrink items-center gap-1.5 sm:flex sm:pl-1.5'; + +/** + * The view bar's right end, added in both faces: the bar ends 8px in, and the + * last control there is ⋮, a 28px box around a 16px icon, so 2px more puts + * that icon's edge 16px in, where the footer's padding ends (objectstack#35663). + */ +export const VIEW_BAR_END_INSET = 'sm:pr-0.5'; + +/** + * objectstack#35878 — the start of the view bar: the object's icon and plural + * name, then 「/」, then the view switcher. Clicking the name does nothing: it + * names the page. From `sm` up only; a phone names the object in its top bar. + */ +export function ObjectViewBarObjectName({ + objectDef, + objectPluralLabel, +}: Pick) { + return ( + + + {/* The page's heading: the page bar that held the `h1` is not drawn. */} +

+ {objectPluralLabel(objectDef)} +

+ + +
+ ); +} + +/** + * objectstack#35878 — the right end of the view bar: the list's own tools (its + * search), then the page's acts (`ObjectViewPageBarActions`: create, then ⋮ + * More at the edge, objectstack#35678). While rows are selected the end shows + * what the selection offers instead (objectstack#35554's slot, + * `useListPageBarHost`), and ⋮ More stays the last control with the same + * icon. The page's acts are drawn from `sm` up; a phone keeps its floating + * create button. + */ +export function ObjectViewBarTrailing({ tools, ...props }: ObjectViewPageBarProps & { tools: ReactNode }) { + const setHosted = useContext(ListViewBarHostContext); + useLayoutEffect(() => { + if (!setHosted) return undefined; + setHosted(true); + return () => setHosted(false); + }, [setHosted]); + const [selectionSlot, setSelectionSlot] = useState(null); + const [pageColumn, setPageColumn] = useState(null); + const rootRef = useCallback((el: HTMLDivElement | null) => { + setPageColumn(el?.closest(`[${OBJECT_VIEW_PAGE_COLUMN_ATTR}]`) ?? null); + }, []); + const pageBar = useListPageBarHost(selectionSlot, pageColumn); + return ( +
+ {/* Always mounted, so the slot is there the moment a row is ticked. */} +
+ {/* Hidden, not unmounted, while rows are selected: the search keeps + its term and the header acts keep following the selection. */} +
+ {tools} + + + +
+
+ ); +} diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index e31875a702f..70af4a16288 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -1086,6 +1086,7 @@ const ar = { dataLimitReached: "يتم عرض أول {{limit}} سجل. قد تتوفر بيانات إضافية.", display: "العرض", options: "خيارات", + viewSettings: "إعدادات العرض", layout: "التخطيط", resetToViewDefault: "إعادة التعيين إلى الإعدادات الافتراضية للعرض", addGroup: "إضافة حقل مجموعة", @@ -1114,6 +1115,8 @@ const ar = { rowHeightSpacious: 'واسع', more: 'المزيد', restoreDefaults: 'استعادة الافتراضي', + shownColumns: 'الأعمدة المعروضة', + addColumn: 'إضافة عمود', }, }, managedByBadge: { @@ -5586,6 +5589,9 @@ const ar = { listJoiner: '، ', or: ' أو ', addFilter: 'إضافة تصفية', + sort: "فرز", + filter: "تصفية", + sortedBy: "مرتب حسب {{field}}", reset: 'إعادة تعيين', resetHint: 'العودة إلى طريقة العرض المحفوظة', remove: 'إزالة {{label}}', diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index c0f85221500..7e99247e5ca 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -969,6 +969,7 @@ const de = { dataLimitReached: "Die ersten {{limit}} Datensätze werden angezeigt. Möglicherweise sind weitere Daten verfügbar.", display: "Anzeige", options: "Optionen", + viewSettings: "Ansichtseinstellungen", layout: "Layout", resetToViewDefault: "Auf Standard der Ansicht zurücksetzen", addGroup: "Gruppenfeld hinzufügen", @@ -993,6 +994,8 @@ const de = { rowHeightSpacious: 'Großzügig', more: 'Mehr', restoreDefaults: 'Standard wiederherstellen', + shownColumns: 'Angezeigte Spalten', + addColumn: 'Spalte hinzufügen', }, }, managedByBadge: { @@ -5000,6 +5003,9 @@ const de = { listJoiner: ', ', or: ' oder ', addFilter: 'Filter hinzufügen', + sort: "Sortieren", + filter: "Filtern", + sortedBy: "Sortiert nach {{field}}", reset: 'Zurücksetzen', resetHint: 'Zurück zur gespeicherten Ansicht', remove: '{{label}} entfernen', diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 132d6abf078..13266e90f2a 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -1259,6 +1259,7 @@ const en = { dataLimitReached: 'Showing first {{limit}} records. More data may be available.', display: 'Display', options: 'Options', + viewSettings: 'View settings', layout: 'Layout', resetToViewDefault: 'Reset to view default', addGroup: 'Add group field', @@ -1283,6 +1284,8 @@ const en = { rowHeightSpacious: 'Spacious', more: 'More', restoreDefaults: 'Restore defaults', + shownColumns: 'Shown columns', + addColumn: 'Add column', }, }, managedByBadge: { @@ -5755,6 +5758,9 @@ const en = { listJoiner: ', ', or: ' or ', addFilter: 'Add filter', + sort: 'Sort', + filter: 'Filter', + sortedBy: 'Sorted by {{field}}', reset: 'Reset', resetHint: 'Back to the view as saved', remove: 'Remove {{label}}', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index d152f2fcc11..f06b1b1529d 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -1001,6 +1001,7 @@ const es = { dataLimitReached: "Se muestran los primeros {{limit}} registros. Puede haber más datos disponibles.", display: "Visualización", options: "Opciones", + viewSettings: "Ajustes de vista", layout: "Diseño", resetToViewDefault: "Restablecer los valores predeterminados de la vista", addGroup: "Agregar campo de grupo", @@ -1026,6 +1027,8 @@ const es = { rowHeightSpacious: 'Amplio', more: 'Más', restoreDefaults: 'Restaurar valores predeterminados', + shownColumns: 'Columnas mostradas', + addColumn: 'Añadir columna', }, }, managedByBadge: { @@ -5147,6 +5150,9 @@ const es = { listJoiner: ', ', or: ' o ', addFilter: 'Añadir filtro', + sort: "Ordenar", + filter: "Filtrar", + sortedBy: "Ordenado por {{field}}", reset: 'Restablecer', resetHint: 'Volver a la vista guardada', remove: 'Quitar {{label}}', diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 28a718ddb35..749a7bfda0e 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -996,6 +996,7 @@ const fr = { dataLimitReached: "Les {{limit}} premiers enregistrements sont affichés. Il peut y avoir plus de données disponibles.", display: "Affichage", options: "Options", + viewSettings: "Paramètres de la vue", layout: "Disposition", resetToViewDefault: "Rétablir les valeurs par défaut de la vue", addGroup: "Ajouter un champ de groupe", @@ -1021,6 +1022,8 @@ const fr = { rowHeightSpacious: 'Spacieuse', more: 'Plus', restoreDefaults: 'Rétablir les valeurs par défaut', + shownColumns: 'Colonnes affichées', + addColumn: 'Ajouter une colonne', }, }, managedByBadge: { @@ -5143,6 +5146,9 @@ const fr = { listJoiner: ', ', or: ' ou ', addFilter: 'Ajouter un filtre', + sort: "Trier", + filter: "Filtrer", + sortedBy: "Trié par {{field}}", reset: 'Réinitialiser', resetHint: 'Revenir à la vue enregistrée', remove: 'Retirer {{label}}', diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 9aa74658ec5..9ff01af1738 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -969,6 +969,7 @@ const ja = { dataLimitReached: "最初の {{limit}} 件のレコードを表示しています。さらにデータがある場合があります。", display: "表示", options: "オプション", + viewSettings: "ビュー設定", layout: "レイアウト", resetToViewDefault: "ビューの既定に戻す", addGroup: "グループフィールドを追加", @@ -993,6 +994,8 @@ const ja = { rowHeightSpacious: 'ゆったり', more: 'その他', restoreDefaults: 'デフォルトに戻す', + shownColumns: '表示中の列', + addColumn: '列を追加', }, }, managedByBadge: { @@ -5002,6 +5005,9 @@ const ja = { listJoiner: '、', or: '、または ', addFilter: 'フィルターを追加', + sort: "並べ替え", + filter: "フィルター", + sortedBy: "{{field}} で並べ替え", reset: 'リセット', resetHint: '保存されたビューに戻す', remove: '{{label}}を削除', diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index ae58760627f..7136511d607 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -969,6 +969,7 @@ const ko = { dataLimitReached: "처음 {{limit}}개 레코드를 표시합니다. 더 많은 데이터가 있을 수 있습니다.", display: "표시", options: "옵션", + viewSettings: "보기 설정", layout: "레이아웃", resetToViewDefault: "보기 기본값으로 재설정", addGroup: "그룹 필드 추가", @@ -993,6 +994,8 @@ const ko = { rowHeightSpacious: '넓게', more: '더 보기', restoreDefaults: '기본값 복원', + shownColumns: '표시된 열', + addColumn: '열 추가', }, }, managedByBadge: { @@ -4999,6 +5002,9 @@ const ko = { listJoiner: ', ', or: ' 또는 ', addFilter: '필터 추가', + sort: "정렬", + filter: "필터", + sortedBy: "{{field}} 기준 정렬", reset: '초기화', resetHint: '저장된 보기로 돌아가기', remove: '{{label}} 제거', diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 50f61be8876..0d1c9c34747 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -996,6 +996,7 @@ const pt = { dataLimitReached: "Os primeiros {{limit}} registros estão sendo exibidos. Pode haver mais dados disponíveis.", display: "Exibição", options: "Opções", + viewSettings: "Configurações da visualização", layout: "Layout", resetToViewDefault: "Restaurar o padrão da exibição", addGroup: "Adicionar campo de grupo", @@ -1021,6 +1022,8 @@ const pt = { rowHeightSpacious: 'Espaçosa', more: 'Mais', restoreDefaults: 'Restaurar padrões', + shownColumns: 'Colunas exibidas', + addColumn: 'Adicionar coluna', }, }, managedByBadge: { @@ -5142,6 +5145,9 @@ const pt = { listJoiner: ', ', or: ' ou ', addFilter: 'Adicionar filtro', + sort: "Ordenar", + filter: "Filtrar", + sortedBy: "Ordenado por {{field}}", reset: 'Redefinir', resetHint: 'Voltar à visualização salva', remove: 'Remover {{label}}', diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index f50c1a4af9c..ef52983f948 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -1029,6 +1029,7 @@ const ru = { dataLimitReached: "Отображаются первые {{limit}} записей. Возможно, есть ещё данные.", display: "Отображение", options: "Параметры", + viewSettings: "Настройки представления", layout: "Макет", resetToViewDefault: "Сбросить к настройкам представления", addGroup: "Добавить поле группировки", @@ -1055,6 +1056,8 @@ const ru = { rowHeightSpacious: 'Просторная', more: 'Ещё', restoreDefaults: 'Восстановить по умолчанию', + shownColumns: 'Показанные столбцы', + addColumn: 'Добавить столбец', }, }, managedByBadge: { @@ -5303,6 +5306,9 @@ const ru = { listJoiner: ', ', or: ' или ', addFilter: 'Добавить фильтр', + sort: "Сортировка", + filter: "Фильтр", + sortedBy: "Сортировка: {{field}}", reset: 'Сбросить', resetHint: 'Вернуться к сохранённому представлению', remove: 'Удалить {{label}}', diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index 7d287f4bf58..7288c069e0d 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -996,6 +996,7 @@ const zh = { dataLimitReached: '显示前 {{limit}} 条记录。可能有更多数据。', display: '显示', options: '选项', + viewSettings: '视图设置', layout: '布局', resetToViewDefault: '恢复视图默认设置', addGroup: '添加分组字段', @@ -1020,6 +1021,8 @@ const zh = { rowHeightSpacious: '宽松', more: '更多', restoreDefaults: '恢复默认', + shownColumns: '显示的列', + addColumn: '添加列', }, }, managedByBadge: { @@ -5059,6 +5062,9 @@ const zh = { listJoiner: '、', or: ' 或 ', addFilter: '添加筛选', + sort: '排序', + filter: '筛选', + sortedBy: '按 {{field}} 排序', reset: '重置', resetHint: '回到视图保存的状态', remove: '删除{{label}}', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 1e071ce7243..33893d18585 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -996,6 +996,7 @@ const zhHant = { dataLimitReached: '顯示前 {{limit}} 條記錄。可能有更多資料。', display: '顯示', options: '選項', + viewSettings: '檢視設定', layout: '佈局', resetToViewDefault: '恢復檢視預設設定', addGroup: '新增分組欄位', @@ -1020,6 +1021,8 @@ const zhHant = { rowHeightSpacious: '寬鬆', more: '更多', restoreDefaults: '恢復預設', + shownColumns: '顯示的列', + addColumn: '新增列', }, }, managedByBadge: { @@ -5059,6 +5062,9 @@ const zhHant = { listJoiner: '、', or: ' 或 ', addFilter: '新增篩選', + sort: '排序', + filter: '篩選', + sortedBy: '按 {{field}} 排序', reset: '重置', resetHint: '回到檢視儲存的狀態', remove: '刪除{{label}}', diff --git a/ui/packages/plugin-grid/src/components/SelectionPageBar.tsx b/ui/packages/plugin-grid/src/components/SelectionPageBar.tsx index c657a28b4cb..b6829f8bef5 100644 --- a/ui/packages/plugin-grid/src/components/SelectionPageBar.tsx +++ b/ui/packages/plugin-grid/src/components/SelectionPageBar.tsx @@ -13,7 +13,7 @@ import { DropdownMenuContent, DropdownMenuTrigger, } from '@object-ui/components'; -import { Edit, MoreHorizontal, X } from 'lucide-react'; +import { Edit, MoreVertical, X } from 'lucide-react'; import type { BulkActionDef } from '@object-ui/types'; import { useObjectTranslation, useRowPredicate } from '@object-ui/react'; import { @@ -98,11 +98,13 @@ const OverflowMenu: React.FC<{ label: string; children: React.ReactNode; onOpen? {children} diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index 5d254d2a37b..4e4f1eb759f 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -9,7 +9,7 @@ import * as React from 'react'; import { cn, Button, Input, Popover, PopoverContent, PopoverTrigger, FilterBuilder, SortBuilder, NavigationOverlay, GroupingEditor, RefreshIndicator, DataErrorState, resolveIcon, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@object-ui/components'; import type { SortItem } from '@object-ui/components'; -import { Search, Funnel, ArrowUpDown, X, EyeOff, Group, Paintbrush, Download, Rows4, Rows3, Rows2, Lock, Printer, Plus, Trash2, CheckSquare, AlertTriangle, ShieldAlert, RotateCw, Loader2, Info, Inbox } from 'lucide-react'; +import { Search, X, EyeOff, Group, Paintbrush, Download, Rows4, Rows3, Rows2, Lock, Printer, Plus, Trash2, CheckSquare, AlertTriangle, ShieldAlert, RotateCw, Loader2, Info, Inbox } from 'lucide-react'; import type { FilterBuilderRowGroup } from '@object-ui/components'; import { VALUELESS_FILTER_BUILDER_OPERATORS, isFilterValueComplete, isCurrencyCompanion } from '@object-ui/components'; import { ViewSwitcherDropdown } from './ViewSwitcher'; @@ -19,12 +19,10 @@ import { ViewSettingsPopover, groupFieldOptions, type ViewSettingsField, - PHONE_POPOVER_GUTTER, PHONE_TOUCH_TARGET, - useBelowSm, } from './components/ViewSettingsPopover'; import { UserFilters, type UserFiltersHandle } from './UserFilters'; -import { ConditionChipRow, FilterPanel, SortPanel } from './conditions/ListConditionControls'; +import { ConditionChipRow, SortPanel } from './conditions/ListConditionControls'; import { TOOLBAR_ROW, TOOLBAR_ROW_LEADING_PHONE, @@ -35,7 +33,6 @@ import { TOOLBAR_USER_FILTERS_LEADING_PHONE, TOOLBAR_CLUSTER, TOOLBAR_CLUSTER_LEADING_PHONE, - TOOLBAR_TEXT_TRIGGER, } from './listToolbarRow'; import { calendarWindowCovers, @@ -472,6 +469,23 @@ export interface ListViewProps { * the list holds and which layout it draws. */ toolbarLeading?: React.ReactNode | ((state: ListToolbarLeadingState) => React.ReactNode); + /** + * objectstack#35878 — the right end of the view bar, drawn by the host. It + * is called with the list's own tools for that end (its search) and returns + * what the end shows: the console puts the page's create button and ⋮ More + * after the search, and while rows are selected shows what the selection + * offers in their place. Absent ⇒ the search alone, as before. + * + * A HOST prop, never a schema key. + */ + toolbarTrailing?: (tools: React.ReactNode) => React.ReactNode; + /** + * objectstack#35878 — the right end of the condition row under the view + * bar, drawn by the host: the console's 「Personalized · Reset」. Given, it + * takes the place of the row's own 「Reset」 (which puts back the filter and + * sort only). A HOST prop, never a schema key. + */ + conditionRowEnd?: React.ReactNode; /** * A host-drawn node beside each row's title in the grid (objectui#13330), * handed to `ObjectGrid`'s `rowAdornment`: the cell of the object's declared @@ -2118,6 +2132,8 @@ export const ListView = React.forwardRef(({ initialFilters, initialSearchTerm, toolbarLeading, + toolbarTrailing, + conditionRowEnd, rowAdornment, recordLinkAdornment, rowOpensRecord, @@ -2420,7 +2436,6 @@ export const ListView = React.forwardRef(({ const [phoneSearchOpen, setPhoneSearchOpen] = React.useState(false); // Sort State - const [showSort, setShowSort] = React.useState(false); const [currentSort, setCurrentSort] = React.useState(() => parseSortConfig(schema.sort), ); @@ -2506,7 +2521,6 @@ export const ListView = React.forwardRef(({ ); }, [currentSort, declaredSort]); - const [showFilters, setShowFilters] = React.useState(false); const [currentFilters, setCurrentFilters] = React.useState(() => initialFilters && Array.isArray(initialFilters.conditions) @@ -3346,8 +3360,6 @@ export const ListView = React.forwardRef(({ setRefreshKey(k => k + 1); }, []); - // Below `sm` the Filter and Sort panels keep 16 px from both screen edges. - const belowSm = useBelowSm(); const { ref: pullRef, isRefreshing, pullDistance } = usePullToRefresh({ onRefresh: handlePullRefresh, @@ -6823,10 +6835,6 @@ export const ListView = React.forwardRef(({ || toolbarFlags.showHideFields || currentView === 'grid' || toolbarFlags.showRefresh || (resolvedExportOptions && exportPermitted && exportableFormats.length > 0) ); - // Below `sm` the bar keeps Filter and Display only, so Sort rides in the - // Display panel there. Without a Display panel the Sort trigger stays on the - // bar at every width. Either way it follows `userActions.sort`. - const sortInDisplay = toolbarFlags.showSort && displayOffered; // The condition controls (objectstack#35549, objectstack#35550): the Filter // and Sort triggers open the shared field list, and the condition row under // the view bar draws the sort and filter chips. The fields the view shows, @@ -6902,9 +6910,9 @@ export const ListView = React.forwardRef(({ )}
) : undefined; - // The Sort panel: every sort level at once. The toolbar Sort popover draws - // it as the shared field list's advanced step (objectstack#35550), and the - // Display panel draws it below `sm` (`sortInDisplay`). + // The Sort panel: every sort level at once. The condition row's sort chip + // draws it as the shared field list's advanced step (objectstack#35550, + // objectstack#35878). const sortPanelBody = (
@@ -6975,7 +6983,7 @@ export const ListView = React.forwardRef(({
(({ {drawnToolbarLeading}
)} + {/* 视图设置 (objectstack#35878, the Display panel of objectui#12423): + beside the view's name, not at the far end of the bar. Its + first level is the content itself: the view's name, its + columns, then Group, Row height and the rest. Every control + writes through the same door as its wide-form button; the panel + adds no storage of its own. */} + {displayOffered && ( + { + const type = (objectDef?.fields as Record | undefined)?.[name]?.type; + return typeof type === 'string' ? type : undefined; + }} + layout={viewSwitcherOffered ? (closeMenu) => ( + { + // Choosing a layout completes the choice: Display closes + // (objectui#12621). + closeMenu(); + handleViewChange(view); + }} + /> + ) : undefined} + showGroup={toolbarFlags.showGroup} + groupingConfig={chosenGroupingConfig} + setGroupingConfig={changeGrouping} + showColor={toolbarFlags.showColor} + rowColorConfig={offeredRowColorConfig} + setRowColorConfig={setRowColorConfig} + showDensity={toolbarFlags.showDensity} + density={currentView === 'gallery' + ? { + mode: galleryCardSize === 'small' ? 'compact' : galleryCardSize === 'medium' ? 'comfortable' : 'spacious', + cycle: cycleGalleryDensity, + setMode: setGalleryDensityMode, + } + : density as any} + showHideFields={toolbarFlags.showHideFields} + hiddenFields={offeredHiddenFields} + updateHiddenFields={updateListedFields} + addableFields={addableFields} + onAddField={addListedField} + changedCount={displayChangedCount} + // objectstack#35551 — the view's name and its rename head the + // menu; the field order is the grid's column order, the state + // the header's column drag writes. + viewName={typeof schema.label === 'string' && schema.label && (onRenameView || onPersonalizationChange) + ? { label: schema.label, onRename: onRenameView } + : undefined} + fieldOrder={currentView === 'grid' ? (schema.columnState as { order?: string[]; widths?: Record } | undefined)?.order : undefined} + onFieldOrderChange={currentView === 'grid' && onColumnStateChange + ? (order) => onColumnStateChange({ ...(schema.columnState as { order?: string[]; widths?: Record } | undefined), order }) + : undefined} + // objectstack#28950 — a host that marks a personalized list owns + // the one reset. It hands it over while there is something to + // restore, and the menu draws it as 恢复默认, dimmed between + // times (objectstack#35551); the list offers none of its own. + onReset={onResetView ?? (onPersonalizationChange ? () => {} : resetDisplayToViewDefault)} + resetDisabled={onResetView ? false : onPersonalizationChange ? true : undefined} + onSave={onSaveView} + exportFormats={resolvedExportOptions && exportPermitted && exportableFormats.length > 0 ? exportableFormats : undefined} + onExport={(format) => handleExport(format as 'csv' | 'xlsx' | 'json' | 'pdf')} + exportBusy={exportBusy} + exportError={exportError} + /> + )} {/* User Filters — filter elements (dropdown chips / preset tabs / toggles). Mutually exclusive with view tabs above, so at most one filter element group ever renders here. On mobile we keep @@ -7177,54 +7254,9 @@ export const ListView = React.forwardRef(({
)} - {/* Filter — universal advanced filter builder. - Always shown when enabled. The left-side quick-filter chips - (filterElements) are predefined named filters; the - right-side Popover is a free-form field-by-field builder that - can express filters the chips cannot. They serve different - purposes and must coexist. */} - {toolbarFlags.showFilters && ( - - - - - - - - - )} + {/* Filter and Sort are not on the bar (objectstack#35878): the + condition row under it carries them, as 「Filter」 and 「Sort」 + before anything is set and as their chips after. */} {/* Group — hidden on mobile (collapsed into ViewSettingsPopover) */} {toolbarFlags.showGroup && !toolbarFlags.compactToolbar && ( @@ -7275,55 +7307,6 @@ export const ListView = React.forwardRef(({ )} - {/* Sort. Below `sm` the Display panel carries the Sort panel when it - is drawn (`sortInDisplay`), so this trigger hides there while no - sort is active; with no Display panel it stays on the bar at - every width. */} - {toolbarFlags.showSort && ( - - - - - - setShowSort(false)} - footer={sortPanelNote} - renderAdvanced={() => sortPanelBody} - /> - - - )} - {/* --- Separator: Data Manipulation | Appearance --- */} {!toolbarFlags.compactToolbar && (toolbarFlags.showFilters || toolbarFlags.showSort || toolbarFlags.showGroup) && (toolbarFlags.showColor || toolbarFlags.showDensity) && (
@@ -7447,78 +7430,6 @@ export const ListView = React.forwardRef(({ ); })()} - {/* Display (objectui#12423) — the default form of this cluster: - Layout, Group, Color, Hide fields, Density, Row numbers and Edit - inline in one panel, with Reset / Refresh / Export in its footer. - Every control writes through the same door as its wide-form - button above; the panel adds no storage of its own. Drawn on - mobile too (icon only): Refresh and Export live in it. */} - {displayOffered && ( - { - const type = (objectDef?.fields as Record | undefined)?.[name]?.type; - return typeof type === 'string' ? type : undefined; - }} - layout={viewSwitcherOffered ? (closeMenu) => ( - { - // Choosing a layout completes the choice: Display closes - // (objectui#12621). - closeMenu(); - handleViewChange(view); - }} - /> - ) : undefined} - sort={sortInDisplay ? sortPanelBody : undefined} - showGroup={toolbarFlags.showGroup} - groupingConfig={chosenGroupingConfig} - setGroupingConfig={changeGrouping} - showColor={toolbarFlags.showColor} - rowColorConfig={offeredRowColorConfig} - setRowColorConfig={setRowColorConfig} - showDensity={toolbarFlags.showDensity} - density={currentView === 'gallery' - ? { - mode: galleryCardSize === 'small' ? 'compact' : galleryCardSize === 'medium' ? 'comfortable' : 'spacious', - cycle: cycleGalleryDensity, - setMode: setGalleryDensityMode, - } - : density as any} - showHideFields={toolbarFlags.showHideFields} - hiddenFields={offeredHiddenFields} - updateHiddenFields={updateListedFields} - addableFields={addableFields} - onAddField={addListedField} - changedCount={displayChangedCount} - // objectstack#35551 — the view's name and its rename head the - // menu; the field order is the grid's column order, the state - // the header's column drag writes. - viewName={typeof schema.label === 'string' && schema.label && (onRenameView || onPersonalizationChange) - ? { label: schema.label, onRename: onRenameView } - : undefined} - fieldOrder={currentView === 'grid' ? (schema.columnState as { order?: string[]; widths?: Record } | undefined)?.order : undefined} - onFieldOrderChange={currentView === 'grid' && onColumnStateChange - ? (order) => onColumnStateChange({ ...(schema.columnState as { order?: string[]; widths?: Record } | undefined), order }) - : undefined} - // objectstack#28950 — a host that marks a personalized list owns - // the one reset. It hands it over while there is something to - // restore, and the menu draws it as 恢复默认, dimmed between - // times (objectstack#35551); the list offers none of its own. - onReset={onResetView ?? (onPersonalizationChange ? () => {} : resetDisplayToViewDefault)} - resetDisabled={onResetView ? false : onPersonalizationChange ? true : undefined} - onSave={onSaveView} - onRefresh={toolbarFlags.showRefresh ? () => setRefreshKey(k => k + 1) : undefined} - refreshing={loading} - exportFormats={resolvedExportOptions && exportPermitted && exportableFormats.length > 0 ? exportableFormats : undefined} - onExport={(format) => handleExport(format as 'csv' | 'xlsx' | 'json' | 'pdf')} - exportBusy={exportBusy} - exportError={exportError} - /> - )} {/* --- Separator: Appearance | Export (wide form) --- */} {!toolbarFlags.compactToolbar && (toolbarFlags.showColor || toolbarFlags.showDensity) && resolvedExportOptions && exportPermitted && exportableFormats.length > 0 && ( @@ -7647,129 +7558,6 @@ export const ListView = React.forwardRef(({ ) : null; })()} - {/* Search, scoped to this list. From `sm` up an icon button opens - a popover; below `sm` the icon expands into a field in place (the - phone form after this popover). Both write the same term. */} - {toolbarFlags.showSearch && ( - - - - - -
- - handleSearchChange(e.target.value)} - className="pl-7 h-8 text-xs" - autoFocus - /> - {searchTerm && ( - - )} -
-
-
- )} - - {/* Search, phone form: the icon expands into a field in place, with - the bar's touch size. Enter or Escape folds it back to the icon, - which then carries the active keyword as the desktop trigger - does; the clear button empties the term and folds it. */} - {toolbarFlags.showSearch && (phoneSearchOpen ? ( -
-
- ) : ( - - ))} {/* Add Record (top position) */} {toolbarFlags.showAddRecordTop && ( @@ -7785,18 +7573,154 @@ export const ListView = React.forwardRef(({ {t('list.addRecord')} )} + {/* objectstack#35878 — the right end of the view bar: the list's + search, then whatever the host puts after it (the page's + create button and ⋮ More), or the search alone. The host may + swap the whole end for what a selection offers. */} + {(() => { + const searchTools = ( + <> + {/* Search, scoped to this list. From `sm` up an icon button opens + a popover; below `sm` the icon expands into a field in place (the + phone form after this popover). Both write the same term. */} + {toolbarFlags.showSearch && ( + + + + + +
+ + handleSearchChange(e.target.value)} + className="pl-7 h-8 text-xs" + autoFocus + /> + {searchTerm && ( + + )} +
+
+
+ )} + + {/* Search, phone form: the icon expands into a field in place, with + the bar's touch size. Enter or Escape folds it back to the icon, + which then carries the active keyword as the desktop trigger + does; the clear button empties the term and folds it. */} + {toolbarFlags.showSearch && (phoneSearchOpen ? ( +
+
+ ) : ( + + ))} + + ); + return toolbarTrailing ? toolbarTrailing(searchTools) : searchTools; + })()}
)} {/* The condition row under the view bar (objectstack#35548): the slot - the filter and sort conditions are drawn in. Empty, it takes no - height (`empty:hidden`). */} + the filter and sort conditions are drawn in. It is always there + (objectstack#35878): with nothing set it holds the dashed 「Sort」 + and 「Filter」 buttons, so the first condition does not push the + table down a row. One line; what does not fit scrolls sideways. */} {listChromeShown && (
{/* objectstack#35549 / #35550: sort chips, the view's own conditions as locked chips, the reader's filter chips, then @@ -7819,6 +7743,19 @@ export const ListView = React.forwardRef(({ renderAdvanced={advancedFilterBuilder} renderSortLevels={() => sortPanelBody} onReset={conditionsDifferFromView ? handleResetConditions : undefined} + end={conditionRowEnd} + filterOffered={toolbarFlags.showFilters} + renderSortPanel={toolbarFlags.showSort ? (close) => ( + sortPanelBody} + /> + ) : undefined} />
)} diff --git a/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx index 8c258300d94..7cab808bac5 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.conditionRow-35549.test.tsx @@ -71,17 +71,12 @@ const slot = () => screen.getByTestId('list-condition-row'); afterEach(() => cleanup()); describe('ListView condition row and panels (objectstack#35549, objectstack#35550)', () => { - it('CONTROL: with no sort and no filter the slot stays empty', async () => { - const ds = mount(); - await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - expect(slot()).toBeEmptyDOMElement(); - }); it('the Filter trigger opens the field list, the fields the view shows first; a pick applies at once and draws a chip', async () => { const onFilterChange = vi.fn(); const ds = mount({}, { onFilterChange }); await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(screen.getByTestId('toolbar-filter-trigger')); + fireEvent.click(screen.getByTestId('condition-add-filter')); const shown = await screen.findByTestId('filter-panel-fields-shown'); expect(within(shown).getAllByRole('option').map((o) => o.getAttribute('data-field'))).toEqual(['name', 'amount', 'stage']); fireEvent.click(screen.getByTestId('filter-panel-fields-item-stage')); @@ -92,20 +87,6 @@ describe('ListView condition row and panels (objectstack#35549, objectstack#3555 expect(within(slot()).getByTestId('filter-chip-stage')).toHaveTextContent('Stage: Negotiation'); }); - it('the Sort trigger adds a level in the chosen direction, and the chip reads it; × hands back the sort without it', async () => { - const onSortChange = vi.fn(); - const ds = mount({}, { onSortChange }); - await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(screen.getByTestId('toolbar-sort-trigger')); - fireEvent.click(await screen.findByTestId('sort-panel-order-desc')); - fireEvent.click(screen.getByTestId('sort-panel-fields-item-amount')); - await waitFor(() => expect(onSortChange).toHaveBeenCalled()); - expect(onSortChange.mock.calls.at(-1)![0].map((s: { field: string; order: string }) => [s.field, s.order])).toEqual([['amount', 'desc']]); - const chip = within(slot()).getByTestId('sort-chip-amount'); - expect(chip).toHaveAttribute('data-order', 'desc'); - fireEvent.click(within(slot()).getByTestId('sort-chip-remove-amount')); - await waitFor(() => expect(onSortChange.mock.calls.at(-1)![0]).toEqual([])); - }); it("the view's own filter is a locked chip, and no Reset is drawn while the list matches the view (objectstack#35727)", async () => { const ds = mount({ filter: [['stage', '=', 'proposal']] }); @@ -116,7 +97,7 @@ describe('ListView condition row and panels (objectstack#35549, objectstack#3555 expect(within(slot()).queryByTestId('condition-reset')).toBeNull(); }); - it('Reset clears the reader\'s filter and returns the sort to the view as saved', async () => { + it('Reset clears the reader\'s filter and keeps the sort the view saved', async () => { const onFilterChange = vi.fn(); const onSortChange = vi.fn(); const ds = mount( @@ -128,13 +109,16 @@ describe('ListView condition row and panels (objectstack#35549, objectstack#3555 }, ); await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(await within(slot()).findByTestId('sort-chip-remove-name')); - await waitFor(() => expect(onSortChange.mock.calls.at(-1)?.[0]).toEqual([])); - const reset = within(slot()).getByTestId('condition-reset'); + // The view's sort is the one chip (objectstack#35878); the filter is the reader's own. + expect(await within(slot()).findByTestId('condition-sort')).toHaveTextContent('Sorted by Name'); + const reset = await within(slot()).findByTestId('condition-reset'); expect(reset).toBeEnabled(); await act(async () => fireEvent.click(reset)); expect(onFilterChange.mock.calls.at(-1)![0].conditions).toEqual([]); - expect(onSortChange.mock.calls.at(-1)![0].map((s: { field: string; order: string }) => [s.field, s.order])).toEqual([['name', 'asc']]); + for (const [next] of onSortChange.mock.calls) { + expect(next.map((s: { field: string; order: string }) => [s.field, s.order])).toEqual([['name', 'asc']]); + } + expect(within(slot()).getByTestId('condition-sort')).toHaveTextContent('Sorted by Name'); await waitFor(() => expect(within(slot()).queryByTestId('filter-chip-name')).toBeNull()); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx index 030fdb464c4..d608f3eff05 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.datasetChartAppliedFilter-10512.test.tsx @@ -153,7 +153,7 @@ const names = (filter: unknown, field: string) => JSON.stringify(filter ?? null) const countBar = () => screen.getByTestId('record-count-bar'); // The toolbar trigger by its test id: the condition row's 「Add filter」 is a // second button named for filters (objectstack#35549). -const filterButton = () => screen.queryByTestId('toolbar-filter-trigger'); +const filterButton = () => screen.queryByTestId('condition-add-filter'); const settle = () => new Promise((r) => setTimeout(r, 50)); const pick = (name: string) => { @@ -239,7 +239,8 @@ describe('objectui#10512 — a held user filter does not narrow ListView\'s fetc // on/off state lives inside `UserFilters`, which is not mounted while the // dataset chart is on screen, so what it draws on the way back is that // component's answer, not this derivation's. - expect(filterButton()).toHaveTextContent('1'); + // A held filter: the row's 「+」, not the dashed 「Filter」 (objectstack#35878). + expect(filterButton()).not.toHaveAttribute('data-empty'); expect(onFilterChange).not.toHaveBeenCalled(); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.displayPopover-12423.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.displayPopover-12423.test.tsx index ca285639a25..d39cd4d58d9 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.displayPopover-12423.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.displayPopover-12423.test.tsx @@ -115,10 +115,9 @@ describe('the list toolbar defaults to Filter · Sort · Display · Search (obje it('the bar draws exactly those four, in that order, for a view offering every control', async () => { mount(); await screen.findByTestId('grid-stub'); + // objectstack#35878: Filter and Sort moved to the condition row, and + // 视图设置 beside the view name; the cluster keeps Search. expect(clusterButtons()).toEqual([ - 'toolbar-filter-trigger', - 'toolbar-sort-trigger', - 'toolbar-display-trigger', 'search-icon-button', // Search's phone form (objectstack#28911), drawn below `sm` only. No // stylesheet is mounted here, so both forms of Search are in the DOM. @@ -158,10 +157,11 @@ describe('the list toolbar defaults to Filter · Sort · Display · Search (obje expect(panel.getByTestId('options-row-layout')).toContainElement(panel.getByTestId('view-switcher-value')); expect(panel.getByTestId('options-row-group')).toBeInTheDocument(); expect(panel.getByTestId('options-row-color')).toBeInTheDocument(); - expect(panel.getByTestId('options-row-fields')).toBeInTheDocument(); + expect(panel.getByTestId('options-add-column')).toBeInTheDocument(); expect(panel.getByTestId('options-row-row-height')).toBeInTheDocument(); expect(panel.getByTestId('display-reset-button')).toHaveTextContent('Restore defaults'); - expect(panel.getByTestId('refresh-button')).toHaveTextContent('Refresh'); + // objectstack#35878 (「刷新去掉」): no Refresh in the panel. + expect(panel.queryByTestId('refresh-button')).toBeNull(); expect(panel.getByTestId('display-export-csv')).toHaveTextContent('Export as CSV'); // objectstack#35684 retired the Edit inline switch and objectstack#35663 // the Row numbers switch, so this list's menu has no More level at all. @@ -212,13 +212,4 @@ describe('the list toolbar defaults to Filter · Sort · Display · Search (obje expect(within(content).queryByRole('switch', { name: /row numbers/i })).toBeNull(); }); - it('the footer Refresh re-fetches, as the wide toolbar button does', async () => { - const dataSource = mount(); - await screen.findByTestId('grid-stub'); - await waitFor(() => expect(dataSource.find).toHaveBeenCalled()); - const before = dataSource.find.mock.calls.length; - const content = await openDisplay(); - fireEvent.click(within(content).getByTestId('refresh-button')); - await waitFor(() => expect(dataSource.find.mock.calls.length).toBeGreaterThan(before)); - }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.emptyStateClearFilters-28908.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.emptyStateClearFilters-28908.test.tsx index a7d402dbe8f..af011910fc7 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.emptyStateClearFilters-28908.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.emptyStateClearFilters-28908.test.tsx @@ -128,14 +128,15 @@ describe('ListView empty state — clear the reader\'s filters (objectstack#2890 expect(add).not.toBeNull(); expect(isPrimary(add)).toBe(false); expect(q(panel, 'empty-state-clear-search')).toBeNull(); - expect(q(container, 'toolbar-filter-trigger')?.getAttribute('aria-label')).toMatch(/1 active/); + // The held filter is a chip in the condition row (objectstack#35878). + expect(q(container, 'condition-add-filter')).not.toHaveAttribute('data-empty'); fireEvent.click(clear!); await waitFor(() => expect(q(container, 'empty-state')).toBeNull()); expect(onFilterChange).toHaveBeenLastCalledWith(expect.objectContaining({ conditions: [] })); expect(JSON.stringify(ds.find.mock.calls.at(-1))).not.toContain(MISS); - expect(q(container, 'toolbar-filter-trigger')?.getAttribute('aria-label')).not.toMatch(/active/); + expect(q(container, 'condition-add-filter')).toHaveAttribute('data-empty', 'true'); }); it('a search alone keeps "Clear search" beside the primary "Add record"', async () => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx index b988c11db35..83bb0cf9181 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.fieldListRead-11984.test.tsx @@ -195,8 +195,11 @@ function fieldListLabels(scope: HTMLElement): string[] { /** Step from the field list into its advanced panel (today's builder) and read its first field picker. */ async function advancedFieldOptions(content: HTMLElement, kind: 'filter' | 'sort'): Promise { - fireEvent.click(within(content).getByTestId(`${kind}-panel-open-advanced`)); - const advanced = await within(content).findByTestId(`${kind}-panel-advanced`); + // A sort in force: the row's one sort chip opens every level, the builder, + // at once (objectstack#35878 on objectstack#35876). + const direct = kind === 'sort' ? within(content).queryByTestId('sort-chip-panel') : null; + if (!direct) fireEvent.click(within(content).getByTestId(`${kind}-panel-open-advanced`)); + const advanced = direct ?? (await within(content).findByTestId(`${kind}-panel-advanced`)); return comboboxOptions(within(advanced).getAllByRole('combobox')[0]); } @@ -219,8 +222,11 @@ function fieldsLevelLabels(scope: HTMLElement): string[] { * Display panel is a menu whose rows open a second level, so Group, Row * color and the field list sit one click below the panel. */ +/** The entry that opens a level: Fields is behind 「+ Add column」 since objectstack#35878. */ +const levelEntry = (row: string) => (row === 'fields' ? 'options-add-column' : `options-row-${row}`); + async function optionsLevel(content: HTMLElement, row: string, read: (level: HTMLElement) => Promise | T): Promise { - fireEvent.click(within(content).getByTestId(`options-row-${row}`)); + fireEvent.click(within(content).getByTestId(levelEntry(row))); const level = await within(content).findByTestId(`options-page-${row}`); try { return await read(level); @@ -258,7 +264,9 @@ const FIELD_LIST_TRIGGERS: Record<'wide' | 'compact', string[]> = { // The compact toolbar folds Group, Row color and Hide fields into Display // (objectui#12423; "View settings" before it), which reads `allFields` for // all three. - compact: ['Filter', 'Options', 'Sort'], // Display reads Options since objectstack#35548 + // Display reads View settings since objectstack#35878 (Options since + // objectstack#35548); Filter and Sort are the condition row's. + compact: ['Filter', 'Sort', 'View settings'], }; interface Sweep { @@ -273,11 +281,18 @@ async function sweepToolbar(): Promise { const toolbar = cluster?.parentElement; if (!toolbar) throw new Error('no toolbar around the tool cluster'); const offered = new Map(); - for (const trigger of Array.from(toolbar.querySelectorAll('[aria-haspopup]'))) { + // Since objectstack#35878 Filter and Sort open from the condition row under + // the bar: its triggers are swept too. + const conditionRow = document.querySelector('[data-testid="list-condition-row"]'); + const triggers = [ + ...Array.from(toolbar.querySelectorAll('[aria-haspopup]')), + ...Array.from(conditionRow?.querySelectorAll('[aria-haspopup]') ?? []), + ]; + for (const trigger of triggers) { // Keyed by the label: a count badge's digits are dropped, and so is the // ", 1 active" the Filter trigger's name carries while a filter is held // (objectui#12500). - const name = (trigger.getAttribute('aria-label') ?? text(trigger)).split(',')[0].replace(/\d+/g, '').trim(); + const name = (trigger.getAttribute('aria-label') ?? text(trigger)).split(',')[0].replace(/\d+/g, '').trim().replace(/^Add filter$/, 'Filter').replace(/^Sorted by .*$/, 'Sort'); const content = await openPopover(trigger); const items = [ ...Array.from(content.querySelectorAll('option')).map(text), @@ -292,7 +307,7 @@ async function sweepToolbar(): Promise { // The Options menu draws its field lists one level down: walk each level. if (within(content).queryByTestId('options-menu')) { for (const row of FIELD_LEVELS) { - if (!within(content).queryByTestId(`options-row-${row}`)) continue; + if (!within(content).queryByTestId(levelEntry(row))) continue; items.push(...(await optionsLevel(content, row, async (level) => { const found = [ ...Array.from(level.querySelectorAll('option')).map(text), @@ -366,16 +381,17 @@ const POSITIONS: Position[] = [ { name: 'the Filter panel (objectui#11925)', props: HELD_FILTER, - read: () => inPopover(toolbarButton(/^filter/i), fieldListLabels), + read: () => inPopover(toolbarButton(/^(add )?filter$/i), fieldListLabels), }, { name: 'the Filter panel, advanced step', props: HELD_FILTER, - read: () => inPopover(toolbarButton(/^filter/i), (c) => advancedFieldOptions(c, 'filter')), + read: () => inPopover(toolbarButton(/^(add )?filter$/i), (c) => advancedFieldOptions(c, 'filter')), }, { name: 'the Sort picker (objectui#11943)', - schemaExtra: { sort: [{ field: 'title', order: 'asc' }] }, + // No sort in force: the dashed 「Sort」 opens the field list + // (objectstack#35878); with one, the chip opens the levels (next case). read: () => inPopover(toolbarButton(/^sort/i), fieldListLabels), }, { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx index 77bcea562a5..01dd8fca754 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.filterDatePicker-12743.test.tsx @@ -114,7 +114,7 @@ function mount(conditions: Row[], language?: string) { */ async function openFilterPanel(dataSource: { getObjectSchema: ReturnType }): Promise { await waitFor(() => expect(dataSource.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(await screen.findByTestId('toolbar-filter-trigger')); + fireEvent.click(await screen.findByTestId('condition-add-filter')); const dialog = await screen.findByRole('dialog'); await openAdvancedFilter(); return dialog; diff --git a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx index 93ccd63b33c..84eef1620b7 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx @@ -289,7 +289,9 @@ describe('ListView.hostDrawnConditions-35727', () => { expect(JSON.stringify(recordReads(ds).at(-1)![1])).toContain('acc_1'); expect(within(slot()).queryByTestId('view-condition-chip')).toBeNull(); expect(within(slot()).queryByTestId('condition-reset')).toBeNull(); - expect(slot()).toBeEmptyDOMElement(); + // The row is resident (objectstack#35878): no chip, only the dashed + // 「Sort」 and 「Filter」 buttons. + expect(within(slot()).getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true'); }); it.each([ @@ -2185,8 +2187,11 @@ describe('ListView.draftOnlyColumn-34807', () => { // advanced step is the builder, whose first picker reads the same list. // Both are read, so a field either offers is caught. const listed = Array.from(content.querySelectorAll('[role="option"][data-field]')).map(text); - fireEvent.click(within(content).getByTestId(/^(filter|sort)-panel-open-advanced$/)); - const advanced = await within(content).findByTestId(/^(filter|sort)-panel-advanced$/); + // A sort in force: the one sort chip opens every level at once + // (objectstack#35878 on objectstack#35876), no field list before it. + const direct = within(content).queryByTestId('sort-chip-panel'); + if (!direct) fireEvent.click(within(content).getByTestId(/^(filter|sort)-panel-open-advanced$/)); + const advanced = direct ?? (await within(content).findByTestId(/^(filter|sort)-panel-advanced$/)); return [...listed, ...(await comboboxOptions(within(advanced).getAllByRole('combobox')[0]))]; } finally { fireEvent.click(trigger); @@ -2246,7 +2251,7 @@ describe('ListView.draftOnlyColumn-34807', () => { await mountList({ draft: true }, { sort: [{ field: 'title', order: 'asc' }] }, { initialFilters: { id: 'root', logic: 'and', conditions: [{ id: 'c1', field: 'title', operator: 'contains', value: 'a' }] }, }); - const filterOptions = await popoverFirstComboboxOptions(/^filter/i); + const filterOptions = await popoverFirstComboboxOptions(/^(add )?filter$/i); expect(filterOptions).toContain('Title'); expect(filterOptions).not.toContain('Priority (draft)'); const sortOptions = await popoverFirstComboboxOptions(/^sort/i); @@ -2282,7 +2287,7 @@ describe('ListView.draftOnlyColumn-34807', () => { expect(lastParams().$orderby).toEqual([{ field: 'priority', order: 'desc' }]); expect(JSON.stringify(lastParams().$filter)).toContain('"priority"'); expect(notice()).toBeNull(); - const filterOptions = await popoverFirstComboboxOptions(/^filter/i); + const filterOptions = await popoverFirstComboboxOptions(/^(add )?filter$/i); expect(filterOptions).toContain('Priority'); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.headerMenuSort-35876.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.headerMenuSort-35876.test.tsx index 559823f3454..acad5d395fc 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.headerMenuSort-35876.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.headerMenuSort-35876.test.tsx @@ -130,32 +130,33 @@ describe('ListView — a sort chip opens the sort panel (objectstack#35876)', () it('a click on the chip opens every level and leaves the direction alone', async () => { const { ds, onSortChange } = mount(TWO); await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - const chip = await within(slot()).findByTestId('sort-chip-meeting_date'); - expect(chip).toHaveAttribute('data-order', 'asc'); - fireEvent.click(within(slot()).getByTestId('sort-chip-open-meeting_date')); + // Since objectstack#35878 the sort is ONE chip, however many levels. + const chip = await within(slot()).findByTestId('condition-sort'); + expect(chip).toHaveAttribute('data-levels', '2'); + fireEvent.click(chip); const panel = await screen.findByTestId('sort-chip-panel'); expect(within(panel).getAllByTestId('sort-builder-row')).toHaveLength(2); expect(within(panel).getAllByTestId('sort-builder-handle')).toHaveLength(2); - expect(within(slot()).getByTestId('sort-chip-meeting_date')).toHaveAttribute('data-order', 'asc'); + expect(levels(lastGridProps.sort)).toEqual([['meeting_date', 'asc'], ['location', 'asc']]); expect(onSortChange).not.toHaveBeenCalled(); }); it("a level's handle moves it: ArrowUp on the second handle makes it the first level", async () => { const { ds, onSortChange } = mount(TWO); await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(await within(slot()).findByTestId('sort-chip-open-location')); + fireEvent.click(await within(slot()).findByTestId('condition-sort')); const panel = await screen.findByTestId('sort-chip-panel'); fireEvent.keyDown(within(panel).getAllByTestId('sort-builder-handle')[1], { key: 'ArrowUp' }); await waitFor(() => expect(onSortChange).toHaveBeenCalled()); expect(levels(onSortChange.mock.calls.at(-1)![0])).toEqual([['location', 'asc'], ['meeting_date', 'asc']]); await waitFor(() => expect(levels(lastGridProps.sort)).toEqual([['location', 'asc'], ['meeting_date', 'asc']])); - expect(within(slot()).getByTestId('sort-chip-location')).toHaveAttribute('data-priority', '1'); + expect(within(slot()).getByTestId('condition-sort')).toHaveTextContent(/^Sorted by Location/); }); it("a mouse drag of a level's handle onto another row moves it there, and the chip it sits in does not undo it", async () => { const { ds, onSortChange } = mount([...TWO, { field: 'name', order: 'desc' }]); await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(await within(slot()).findByTestId('sort-chip-open-location')); + fireEvent.click(await within(slot()).findByTestId('condition-sort')); const panel = await screen.findByTestId('sort-chip-panel'); const handles = within(panel).getAllByTestId('sort-builder-handle'); const rows = within(panel).getAllByTestId('sort-builder-row'); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.optionsHost-35551.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.optionsHost-35551.test.tsx index 7d0f5a98224..1472ee367fc 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.optionsHost-35551.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.optionsHost-35551.test.tsx @@ -92,7 +92,7 @@ describe('Options — Fields writes the column order (objectstack#35551)', () => ); await screen.findByTestId('object-grid-stub'); fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - fireEvent.click(await screen.findByTestId('options-row-fields')); + fireEvent.click(await screen.findByTestId('options-add-column')); const shown = Array.from(document.querySelectorAll('[data-testid^="options-fields-move-"]')) .map((el) => el.getAttribute('data-testid')!.replace('options-fields-move-', '')); expect(shown).toEqual(['amount', 'name', 'stage']); @@ -104,7 +104,7 @@ describe('Options — Fields writes the column order (objectstack#35551)', () => mount({}); await screen.findByTestId('object-grid-stub'); fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - fireEvent.click(await screen.findByTestId('options-row-fields')); + fireEvent.click(await screen.findByTestId('options-add-column')); expect(screen.queryByTestId('options-fields-move-name')).toBeNull(); }); @@ -112,7 +112,7 @@ describe('Options — Fields writes the column order (objectstack#35551)', () => mount({}); await screen.findByTestId('object-grid-stub'); fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - fireEvent.click(await screen.findByTestId('options-row-fields')); + fireEvent.click(await screen.findByTestId('options-add-column')); expect(screen.getByTestId('options-fields-item-amount').getAttribute('data-field-type')).toBe('number'); expect(screen.getByTestId('options-fields-item-name').getAttribute('data-field-type')).toBe('text'); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.phoneSortSearch-28911.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.phoneSortSearch-28911.test.tsx index 8bc23feda1f..b2806643640 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.phoneSortSearch-28911.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.phoneSortSearch-28911.test.tsx @@ -108,47 +108,14 @@ afterEach(() => { }); describe('phone list: Sort in the Display panel (objectstack#28911)', () => { - it('narrow: the bar draws no Sort button; Display carries the Sort panel, and a sort applies to the list', async () => { - belowSm(); - const onSortChange = vi.fn(); - const ds = mount({}, { onSortChange }); - await screen.findByTestId('grid-stub'); - - expect(screen.getByTestId('toolbar-sort-trigger')).not.toBeVisible(); - - const content = await openDisplay(); - const row = within(content).getByTestId('options-row-sort'); - expect(row).toBeVisible(); - fireEvent.click(row); - const block = await within(content).findByTestId('display-sort'); - expect(block).toBeVisible(); - expect(within(block).getByText('Sort Records')).toBeVisible(); - - ds.find.mockClear(); - fireEvent.click(within(block).getByRole('button', { name: 'Add sort' })); - await waitFor(() => expect(onSortChange).toHaveBeenCalled()); - expect(onSortChange.mock.lastCall?.[0]).toEqual([expect.objectContaining({ field: 'name', order: 'asc' })]); - // The list re-fetches under the new sort. - await waitFor(() => expect(ds.find).toHaveBeenCalled()); - expect(JSON.stringify(ds.find.mock.lastCall)).toContain('name'); - }); - it('wide: the Sort button is on the bar and the Display menu shows no Sort row', async () => { - fromSm(); - mount(); - await screen.findByTestId('grid-stub'); - - expect(screen.getByTestId('toolbar-sort-trigger')).toBeVisible(); - const content = await openDisplay(); - expect(within(content).getByTestId('options-row-sort')).not.toBeVisible(); - }); it('`userActions.sort: false` withholds Sort on the phone too', async () => { belowSm(); mount({ userActions: { sort: false } } as Partial); await screen.findByTestId('grid-stub'); - expect(screen.queryByTestId('toolbar-sort-trigger')).toBeNull(); + expect(screen.queryByTestId('condition-sort')).toBeNull(); const content = await openDisplay(); expect(within(content).queryByTestId('options-row-sort')).toBeNull(); expect(within(content).queryByTestId('display-sort')).toBeNull(); @@ -160,9 +127,9 @@ describe('phone list: Sort in the Display panel (objectstack#28911)', () => { await screen.findByTestId('grid-stub'); expect(screen.queryByTestId('toolbar-display-trigger')).toBeNull(); - const sort = screen.getByTestId('toolbar-sort-trigger'); + const sort = screen.getByTestId('condition-sort'); expect(sort).toBeVisible(); - expect(sizeTokens(sort)).toEqual(sizeTokens(screen.getByTestId('toolbar-filter-trigger'))); + expect(sizeTokens(sort)).toEqual(sizeTokens(screen.getByTestId('condition-add-filter'))); }); }); @@ -177,7 +144,7 @@ describe('phone list: the search icon expands in place (objectstack#28911)', () const trigger = screen.getByTestId('phone-search-trigger'); expect(trigger).toBeVisible(); expect(trigger).toHaveAccessibleName('Search'); - expect(sizeTokens(trigger)).toEqual(sizeTokens(screen.getByTestId('toolbar-filter-trigger'))); + expect(sizeTokens(trigger)).toEqual(sizeTokens(screen.getByTestId('toolbar-display-trigger'))); fireEvent.click(trigger); const input = screen.getByTestId('phone-search-input'); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx index 9f99964b917..b631aad62c0 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.phoneWidth-29074.test.tsx @@ -13,17 +13,15 @@ * field and Clear) are 44 px touch targets below `sm` and keep their * compact size from `sm` up: the `max-sm:` tokens beside the unchanged * desktop ones. - * - An active sort shows on the phone bar: the Sort trigger, with its level - * count, stays there while a sort is active (the Display panel still holds - * the builder), and goes while none is or while the search field is open. + * - (The phone bar's own Sort trigger is gone since objectstack#35878: Sort + * is the resident condition row's chip at every width.) * - `useBelowSm` answers the `sm` media query for the panels' 16 px inset. * - * happy-dom has no viewport and no Tailwind stylesheet: "narrow" mounts the - * one base rule below `sm`, `.hidden { display: none }`, as - * `ListView.phoneSortSearch-28911.test.tsx` does. + * happy-dom has no viewport and no Tailwind stylesheet, so the size tokens are + * read from the class list. */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { render, renderHook, screen, fireEvent, within, cleanup } from '@testing-library/react'; +import { render, renderHook, screen, fireEvent, cleanup } from '@testing-library/react'; import '@testing-library/jest-dom'; import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; @@ -31,7 +29,6 @@ import { SchemaRendererProvider } from '@object-ui/react'; import type { ListViewSchema } from '@object-ui/types'; import { ListView } from '../ListView'; import { PHONE_TOUCH_TARGET, useBelowSm } from '../components/ViewSettingsPopover'; -import { openAdvancedSort } from './conditionPanels'; const RECORDS = [{ id: '1', name: 'Acme', stage: 'won' }]; @@ -43,14 +40,6 @@ const SCHEMA: ListViewSchema = { } as ListViewSchema; let previousGrid: ReturnType; -let viewportStyle: HTMLStyleElement | null = null; - -/** The base (below `sm`) Tailwind rule, and nothing else. */ -function belowSm() { - viewportStyle = document.createElement('style'); - viewportStyle.textContent = '.hidden { display: none; }'; - document.head.appendChild(viewportStyle); -} function mount(schema: Partial = {}) { const dataSource = { @@ -81,8 +70,6 @@ beforeEach(() => { afterEach(() => { cleanup(); - viewportStyle?.remove(); - viewportStyle = null; vi.unstubAllGlobals(); if (previousGrid) ComponentRegistry.register('object-grid', previousGrid as any); }); @@ -91,10 +78,15 @@ describe('list bar touch targets below sm (objectstack#29074)', () => { it('Filter, Sort, Display and the phone search trigger are 44 px below sm and keep h-7 from sm up', async () => { mount(); await screen.findByTestId('grid-stub'); - for (const id of ['toolbar-filter-trigger', 'toolbar-sort-trigger', 'toolbar-display-trigger', 'phone-search-trigger']) { + for (const id of ['toolbar-display-trigger', 'phone-search-trigger']) { const el = screen.getByTestId(id); expect(tokens(el), id).toEqual(expect.arrayContaining(['h-7', 'min-w-7', ...PHONE_TOUCH_TARGET.split(' ')])); } + // Filter and Sort are the condition row's since objectstack#35878: 24 px + // from `sm` up, the same 44 px below it. + for (const id of ['condition-add-filter', 'condition-sort']) { + expect(tokens(screen.getByTestId(id)), id).toEqual(expect.arrayContaining(['h-6', ...PHONE_TOUCH_TARGET.split(' ')])); + } }); it('the open phone search field and its Clear are 44 px below sm', async () => { @@ -108,48 +100,6 @@ describe('list bar touch targets below sm (objectstack#29074)', () => { }); }); -describe('an active sort shows on the phone bar (objectstack#29057)', () => { - it('narrow, unsorted: the bar draws no Sort trigger', async () => { - belowSm(); - mount(); - await screen.findByTestId('grid-stub'); - expect(screen.getByTestId('toolbar-sort-trigger')).not.toBeVisible(); - }); - - it('narrow, sorted: the Sort trigger stays on the bar with the level count, and opens the sort builder', async () => { - belowSm(); - mount({ sort: [{ field: 'name', order: 'asc' }] } as Partial); - await screen.findByTestId('grid-stub'); - const trigger = screen.getByTestId('toolbar-sort-trigger'); - expect(trigger).toBeVisible(); - expect(trigger).toHaveTextContent('1'); - expect(trigger).toHaveAccessibleName('Sort'); - - fireEvent.click(trigger); - expect(await openAdvancedSort()).toBeVisible(); - }); - - it('narrow, sorted: the open search field takes the Sort trigger slot, which comes back when it folds', async () => { - belowSm(); - mount({ sort: [{ field: 'name', order: 'asc' }] } as Partial); - await screen.findByTestId('grid-stub'); - fireEvent.click(screen.getByTestId('phone-search-trigger')); - expect(screen.getByTestId('toolbar-sort-trigger')).not.toBeVisible(); - - fireEvent.keyDown(screen.getByTestId('phone-search-input'), { key: 'Escape' }); - expect(screen.getByTestId('toolbar-sort-trigger')).toBeVisible(); - }); - - it('the Display menu still carries the Sort level while the bar shows the indicator', async () => { - belowSm(); - mount({ sort: [{ field: 'name', order: 'asc' }] } as Partial); - await screen.findByTestId('grid-stub'); - fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - const content = await screen.findByTestId('view-settings-content'); - fireEvent.click(within(content).getByTestId('options-row-sort')); - expect(await within(content).findByTestId('display-sort')).toBeInTheDocument(); - }); -}); describe('useBelowSm', () => { function stubMatchMedia(matches: boolean) { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.toolbarAccessibleNames-12500.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.toolbarAccessibleNames-12500.test.tsx index 957459ed944..dcaa1fe5f70 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.toolbarAccessibleNames-12500.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.toolbarAccessibleNames-12500.test.tsx @@ -108,7 +108,7 @@ describe('ListView toolbar buttons keep a name when icon-only (objectui#12500)', await renderToolbar(); const filter = screen.getByRole('button', { name: 'Filter' }); - expect(filter).toHaveAttribute('data-testid', 'toolbar-filter-trigger'); + expect(filter).toHaveAttribute('data-testid', 'condition-add-filter'); // The empty state's own CTA is named "Add record" too; the two toolbar // slots (`position: 'both'`) are the ones under test. @@ -125,13 +125,6 @@ describe('ListView toolbar buttons keep a name when icon-only (objectui#12500)', expect(screen.getByRole('button', { name: 'Export' })).toBeInTheDocument(); }); - it('below sm, one active filter: the Filter name carries "Filter" and the count', async () => { - belowSm(); - await renderToolbar({}, { initialFilters: ONE_FILTER }); - - const filter = screen.getByTestId('toolbar-filter-trigger'); - expect(filter).toHaveAccessibleName('Filter, 1 active'); - }); it('CONTROL, wide: each name is its visible label exactly once', async () => { await renderToolbar({ compactToolbar: false, exportOptions: { formats: ['csv'] } }); @@ -139,7 +132,7 @@ describe('ListView toolbar buttons keep a name when icon-only (objectui#12500)', // From `sm` up Filter is a named text button again (objectstack#35548; // objectui#12695 had made it an icon at every width): its visible label // is its name, once. - const filter = screen.getByTestId('toolbar-filter-trigger'); + const filter = screen.getByTestId('condition-add-filter'); expect(filter.textContent).toBe('Filter'); expect(filter).toHaveAccessibleName('Filter'); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.toolbarIconButtons-12695.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.toolbarIconButtons-12695.test.tsx deleted file mode 100644 index 387db6dcee3..00000000000 --- a/ui/packages/plugin-list/src/__tests__/ListView.toolbarIconButtons-12695.test.tsx +++ /dev/null @@ -1,194 +0,0 @@ -/** - * ObjectUI - * Copyright (c) 2024-present ObjectStack Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** - * objectui#12695 — the list toolbar draws Filter, Sort and Display as icon - * buttons at every width, with the count badge as the only text in the - * cluster. ⚠️ objectstack#35548 redrew them from `sm` up as named text - * buttons, 「筛选」「排序」「选项」 (Display is now Options), each with its count - * after the name; below `sm` they stay icons, the label `hidden sm:inline`. One shape for every list: the triggers live in `ListView`, which - * app object lists, Setup lists and related lists all mount. - * - * ## How "wide" and "narrow" are reproduced here - * - * happy-dom has no viewport and no Tailwind stylesheet, so with no rule - * mounted every element is visible: that is the wide case, and the strong one, - * because a `hidden sm:inline` label span would show up in `textContent`. The - * narrow case mounts the one base rule below `sm`, `.hidden { display: none }` - * (as `ListView.toolbarAccessibleNames-12500.test.tsx` does). Sort is itself - * `hidden sm:inline-flex`, so below `sm` only Filter and Display are drawn. - * - * Provider-less, so `t()` reads `LIST_DEFAULT_TRANSLATIONS`. - */ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { render, screen, fireEvent, within, waitFor, cleanup } from '@testing-library/react'; -import '@testing-library/jest-dom'; -import React from 'react'; -import { ComponentRegistry } from '@object-ui/core'; -import { SchemaRendererProvider } from '@object-ui/react'; -import type { ListViewSchema } from '@object-ui/types'; -import { ListView } from '../ListView'; -import { openAdvancedFilter, openAdvancedSort } from './conditionPanels'; - -const RECORDS = [{ id: '1', name: 'Acme', stage: 'won' }]; - -const TWO_FILTERS = { - id: 'root', - logic: 'and', - conditions: [ - { id: 'c1', field: 'name', operator: 'contains', value: 'a' }, - { id: 'c2', field: 'stage', operator: 'equals', value: 'won' }, - ], -}; - -const SCHEMA: ListViewSchema = { - type: 'list-view', - objectName: 'account', - viewType: 'grid', - fields: ['name', 'stage'], -} as ListViewSchema; - -let previousGrid: ReturnType; -let narrowStyle: HTMLStyleElement | null = null; - -/** The base (below `sm`) Tailwind rule, and nothing else. */ -function belowSm() { - narrowStyle = document.createElement('style'); - narrowStyle.textContent = '.hidden { display: none; }'; - document.head.appendChild(narrowStyle); -} - -function mount(schema: Partial = {}, props: Record = {}) { - const dataSource = { - find: vi.fn().mockResolvedValue({ data: RECORDS, total: 1 }), - findOne: vi.fn(), - create: vi.fn(), - update: vi.fn(), - delete: vi.fn(), - getObjectSchema: vi.fn().mockResolvedValue({ name: 'account', fields: {} }), - }; - render( - - - , - ); -} - -/** Raise the Display count to two: density and the row colour off the view's own. */ -async function changeTwoDisplaySettings() { - fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - const content = await screen.findByTestId('view-settings-content'); - // Two levels of the Display menu: a row height, then the row colour cleared. - fireEvent.click(within(content).getByTestId('options-row-row-height')); - fireEvent.click(await within(content).findByTestId('options-row-height-spacious')); - fireEvent.click(within(content).getByTestId('options-back')); - fireEvent.click(within(content).getByTestId('options-row-color')); - fireEvent.click(await within(content).findByTestId('options-color-clear')); - await waitFor(() => expect(screen.getByTestId('toolbar-display-count')).toHaveTextContent('2')); - fireEvent.keyDown(content, { key: 'Escape' }); - await waitFor(() => expect(screen.queryByTestId('view-settings-content')).toBeNull()); -} - -beforeEach(() => { - previousGrid = ComponentRegistry.get('object-grid'); - ComponentRegistry.register('object-grid', () =>
); -}); - -afterEach(() => { - cleanup(); - narrowStyle?.remove(); - narrowStyle = null; - if (previousGrid) ComponentRegistry.register('object-grid', previousGrid as any); -}); - -describe('Filter, Sort and Options: text buttons from `sm` up, icons below it (objectui#12695, objectstack#35548)', () => { - const TRIGGERS = [ - ['toolbar-filter-trigger', 'Filter'], - ['toolbar-sort-trigger', 'Sort'], - ['toolbar-display-trigger', 'Options'], - ] as const; - - it('wide: each trigger reads its name, and the names and titles resolve', async () => { - mount(); - await screen.findByTestId('grid-stub'); - for (const [testId, name] of TRIGGERS) { - const btn = screen.getByTestId(testId); - expect(btn.textContent).toBe(name); - expect(screen.getByRole('button', { name })).toBe(btn); - expect(btn).toHaveAttribute('title', name); - } - }); - - it('narrow: the label is `hidden sm:inline` beside an `sm:hidden` icon, and the names hold', async () => { - belowSm(); - mount(); - await screen.findByTestId('grid-stub'); - for (const [testId, name] of [TRIGGERS[0], TRIGGERS[2]]) { - const btn = screen.getByTestId(testId); - const label = Array.from(btn.querySelectorAll('span')).find((el) => el.textContent === name)!; - expect(label.className.split(/\s+/)).toEqual(expect.arrayContaining(['hidden', 'sm:inline'])); - expect(btn.querySelector('svg')?.getAttribute('class') ?? '').toContain('sm:hidden'); - expect(screen.getByRole('button', { name })).toBe(btn); - } - }); - - it('the count badge follows the name: Filter 2 · Sort 1 · Options 2', async () => { - mount( - { sort: [{ field: 'name', order: 'asc' }], userActions: { rowColor: true }, rowColor: { field: 'stage', colors: {} } } as Partial, - { initialFilters: TWO_FILTERS }, - ); - await screen.findByTestId('grid-stub'); - await changeTwoDisplaySettings(); - - const filter = screen.getByTestId('toolbar-filter-trigger'); - expect(filter.textContent).toBe('Filter2'); - expect(filter).toHaveAccessibleName('Filter, 2 active'); - expect(filter).toHaveAttribute('title', 'Filter'); - - const sort = screen.getByTestId('toolbar-sort-trigger'); - expect(sort.textContent).toBe('Sort1'); - expect(screen.getByRole('button', { name: 'Sort' })).toBe(sort); - - const display = screen.getByTestId('toolbar-display-trigger'); - expect(display.textContent).toBe('Options2'); - expect(screen.getByRole('button', { name: 'Options' })).toBe(display); - - // Everything the cluster says in text is the three names and their counts. - const cluster = document.querySelector('[data-print-hide]'); - expect(cluster?.textContent).toBe('Filter2Sort1Options2'); - }); - - it('`compactToolbar: false` draws Filter and Sort in the same shape', async () => { - mount({ compactToolbar: false, sort: [{ field: 'name', order: 'asc' }] } as Partial); - await screen.findByTestId('grid-stub'); - const filter = screen.getByRole('button', { name: 'Filter' }); - expect(filter.textContent).toBe('Filter'); - expect(filter).toHaveAttribute('title', 'Filter'); - const sort = screen.getByRole('button', { name: 'Sort' }); - expect(sort.textContent).toBe('Sort1'); - expect(sort).toHaveAttribute('title', 'Sort'); - }); - - it('CONTROL: each popover still opens from its trigger', async () => { - mount(); - await screen.findByTestId('grid-stub'); - - fireEvent.click(screen.getByRole('button', { name: 'Filter' })); - expect(await openAdvancedFilter()).toBeInTheDocument(); - fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); - await waitFor(() => expect(screen.queryByText('Filter Records')).toBeNull()); - - fireEvent.click(screen.getByRole('button', { name: 'Sort' })); - expect(await openAdvancedSort()).toBeInTheDocument(); - fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); - await waitFor(() => expect(screen.queryByText('Sort Records')).toBeNull()); - - fireEvent.click(screen.getByRole('button', { name: 'Options' })); - expect(await screen.findByTestId('view-settings-content')).toBeInTheDocument(); - }); -}); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.toolbarLeading-12440.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.toolbarLeading-12440.test.tsx index 4dafd9e3cb7..aed21f77eed 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.toolbarLeading-12440.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.toolbarLeading-12440.test.tsx @@ -95,7 +95,7 @@ describe('objectui#12440 — ListView draws a host node first in its toolbar row const node = screen.getByTestId('host-tabs'); const wrapper = screen.getByTestId('list-toolbar-leading'); expect(wrapper.contains(node)).toBe(true); - expect(wrapper.className.split(/\s+/)).toEqual(expect.arrayContaining(['min-w-0', 'flex-1'])); + expect(wrapper.className.split(/\s+/)).toEqual(expect.arrayContaining(['min-w-0', 'shrink'])); // Same left group as the chips, and first in it. const leftGroup = wrapper.parentElement!; @@ -118,7 +118,8 @@ describe('objectui#12440 — ListView draws a host node first in its toolbar row expect(screen.queryByTestId('list-toolbar-leading')).toBeNull(); const leftGroup = chips().parentElement!; expect(leftGroup.className).toBe(LEFT_GROUP_TODAY); - expect(leftGroup.firstElementChild).toBe(chips()); + // 视图设置 leads a group with no host node (objectstack#35878), then the chips. + expect(leftGroup.firstElementChild).toBe(screen.queryByTestId('toolbar-display-trigger') ?? chips()); }); it('a `null` node draws no wrapper either', async () => { diff --git a/ui/packages/plugin-list/src/__tests__/ListView.toolbarRows-27520.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.toolbarRows-27520.test.tsx index 00ad9c4bc99..b57aff92fc7 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.toolbarRows-27520.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.toolbarRows-27520.test.tsx @@ -91,19 +91,13 @@ const NO_VALUE: Row = { id: 'c2', field: 'priority', operator: 'equals', value: const group = (...conditions: Row[]): React.ComponentProps['initialFilters'] => ({ id: 'root', logic: 'and', conditions }); -const filterTrigger = () => screen.getByTestId('toolbar-filter-trigger'); +const filterTrigger = () => screen.getByTestId('condition-add-filter'); afterEach(() => { cleanup(); }); describe('row 7: a filter row with no value is not a filter', () => { - it('the badge counts the finished rows only', async () => { - mount({}, { initialFilters: group(COMPLETE, NO_VALUE) }); - await waitFor(() => expect(filterTrigger()).toHaveAccessibleName('Filter, 1 active')); - // The trigger reads its label, then the badge (objectstack#35548). - expect(filterTrigger().textContent).toBe('Filter1'); - }); it('a group of unfinished rows only draws no badge and keeps the first-run copy', async () => { const { container } = mount({}, { initialFilters: group(NO_VALUE), onAddRecord: () => {} }); @@ -115,10 +109,6 @@ describe('row 7: a filter row with no value is not a filter', () => { expect(panel.textContent).not.toMatch(/No matching records/); }); - it('CONTROL: two finished rows count two', async () => { - mount({}, { initialFilters: group(COMPLETE, { ...NO_VALUE, value: 3 }) }); - await waitFor(() => expect(filterTrigger()).toHaveAccessibleName('Filter, 2 active')); - }); it('"Add filter" draws the new row in the panel but hands the host only the finished rows', async () => { const onFilterChange = vi.fn(); @@ -139,8 +129,9 @@ describe('row 7: a filter row with no value is not a filter', () => { expect(onFilterChange).toHaveBeenCalled(); const stored = onFilterChange.mock.calls.at(-1)![0]; expect(stored.conditions).toEqual([COMPLETE]); - // And the badge did not move. - expect(filterTrigger()).toHaveAccessibleName('Filter, 1 active'); + // And the row shows the one finished condition (objectstack#35878: a + // chip, then 「+」; the bar has no count any more). + expect(filterTrigger()).not.toHaveAttribute('data-empty'); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.treeEmptyState-28966.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.treeEmptyState-28966.test.tsx index bf017be686b..5f103b50982 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.treeEmptyState-28966.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.treeEmptyState-28966.test.tsx @@ -172,7 +172,7 @@ describe('an empty tree list view draws the view empty state (objectstack#28966) { compactToolbar: false, emptyState: { title: 'No business units yet' } } as Partial, 'none', ); - expect(screen.getByTestId('toolbar-filter-trigger')).toBeTruthy(); + expect(screen.getByTestId('condition-add-filter')).toBeTruthy(); expect(screen.getByTestId('refresh-button')).toBeTruthy(); expect(headingOf(state)).toBe('No business units yet'); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.viewBarLeading-35548.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.viewBarLeading-35548.test.tsx index 025b8a150a9..4492bb87b7d 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.viewBarLeading-35548.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.viewBarLeading-35548.test.tsx @@ -102,10 +102,12 @@ const lead = (calls: ListToolbarLeadingState[]) => (s: ListToolbarLeadingState) /** The view bar's own controls, read off the row that carries the leading node. */ function viewBar() { const row = screen.getByTestId('list-toolbar-leading').parentElement!.parentElement!; + // Filter and Sort are the condition row's since objectstack#35878. + const conditions = screen.queryByTestId('list-condition-row'); return { row, - filter: row.querySelector('[data-testid="toolbar-filter-trigger"]'), - sort: row.querySelector('[data-testid="toolbar-sort-trigger"]'), + filter: conditions?.querySelector('[data-testid="condition-add-filter"]') ?? null, + sort: conditions?.querySelector('[data-testid="condition-sort"]') ?? null, options: row.querySelector('[data-testid="toolbar-display-trigger"]'), }; } @@ -133,14 +135,7 @@ describe('objectstack#35548 — one view bar, handed the list state', () => { // Text, not icons, from `sm` up: each trigger carries its label. expect(bar.filter!.textContent).toMatch(/Filter|筛选/); expect(bar.sort!.textContent).toMatch(/Sort|排序/); - expect(bar.options!.textContent).toMatch(/Options|选项/); + expect(bar.options!.textContent).toMatch(/View settings|视图设置/); }); - it('draws the condition row empty, so it takes no height', async () => { - mount(GRID, lead([])); - await waitFor(() => expect(screen.getByTestId('host-switcher')).toBeInTheDocument()); - const slot = screen.getByTestId('list-condition-row'); - expect(slot).toBeEmptyDOMElement(); - expect(slot.className.split(/\s+/)).toContain('empty:hidden'); - }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListView.withheldFields-34901.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.withheldFields-34901.test.tsx index 9349007a237..417bdd25c78 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.withheldFields-34901.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.withheldFields-34901.test.tsx @@ -161,8 +161,9 @@ describe('ListView over a field a disabled package withholds (objectstack#34901) // The sort builder: remove the `name` row; the withheld row stays in the write. fireEvent.click(screen.getByRole('button', { name: /^sort/i })); - // The builder is the Sort panel's advanced step (objectstack#35550). - fireEvent.click(await screen.findByTestId('sort-panel-open-advanced')); + // With a sort in force the row's one sort chip opens every level, the + // builder, at once (objectstack#35878 on objectstack#35876). + await screen.findByTestId('sort-chip-panel'); const rows = await screen.findAllByTestId('sort-builder-row'); expect(rows).toHaveLength(2); fireEvent.click(within(rows[1]).getByRole('button', { name: /remove sort/i })); diff --git a/ui/packages/plugin-list/src/__tests__/ListViewBlock.cappedPageBlock-26613.test.tsx b/ui/packages/plugin-list/src/__tests__/ListViewBlock.cappedPageBlock-26613.test.tsx index ec6f2d69dc4..d941627ccec 100644 --- a/ui/packages/plugin-list/src/__tests__/ListViewBlock.cappedPageBlock-26613.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListViewBlock.cappedPageBlock-26613.test.tsx @@ -214,7 +214,7 @@ describe('a list block half the page or wider is capped (objectstack#26613)', () expect(within(main).queryByText('Rating')).toBeNull(); // None of the object list's chrome: no toolbar, no grid (so no `#` column), no count bar. - expect(within(main).queryByTestId('toolbar-filter-trigger')).toBeNull(); + expect(within(main).queryByTestId('condition-add-filter')).toBeNull(); expect(within(main).queryByTestId('grid-spy')).toBeNull(); expect(within(main).queryByTestId('record-count-bar')).toBeNull(); @@ -295,6 +295,6 @@ describe('the other postures are unchanged (objectstack#26613)', () => { const main = regionOf(container, 'main'); await waitFor(() => expect(within(main).getByTestId('grid-spy')).toBeTruthy()); expect(within(main).queryByTestId('list-capped-table')).toBeNull(); - expect(within(main).getByTestId('toolbar-filter-trigger')).toBeTruthy(); + expect(within(main).getByTestId('condition-add-filter')).toBeTruthy(); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListViewBlock.compactRegion-12703.test.tsx b/ui/packages/plugin-list/src/__tests__/ListViewBlock.compactRegion-12703.test.tsx index 2792bc9704d..85af00f7d5c 100644 --- a/ui/packages/plugin-list/src/__tests__/ListViewBlock.compactRegion-12703.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListViewBlock.compactRegion-12703.test.tsx @@ -172,7 +172,7 @@ describe('a list block in a region narrower than half the page is compact (objec // (a) No object-list chrome: no toolbar control, no tab strip, no grid // (the `#` column is the grid's), no record-count bar. - expect(within(aside).queryByTestId('toolbar-filter-trigger')).toBeNull(); + expect(within(aside).queryByTestId('condition-add-filter')).toBeNull(); expect(within(aside).queryByRole('tablist')).toBeNull(); expect(within(aside).queryByTestId('grid-spy')).toBeNull(); expect(within(aside).queryByTestId('record-count-bar')).toBeNull(); @@ -199,7 +199,7 @@ describe('a list block in a region narrower than half the page is compact (objec expect(within(main).queryByTestId('list-compact-rows')).toBeNull(); // The capped posture (objectstack#26613) is not the full list either: no // toolbar, and no grid anywhere on the page. - expect(within(main).queryByTestId('toolbar-filter-trigger')).toBeNull(); + expect(within(main).queryByTestId('condition-add-filter')).toBeNull(); expect(container.querySelectorAll('[data-testid="grid-spy"]')).toHaveLength(0); }); @@ -238,7 +238,7 @@ describe('a list outside any page region is unchanged (objectui#12703)', () => { />, ); await waitFor(() => expect(view.getByTestId('grid-spy')).toBeTruthy()); - expect(view.getByTestId('toolbar-filter-trigger')).toBeTruthy(); + expect(view.getByTestId('condition-add-filter')).toBeTruthy(); expect(view.queryByTestId('list-compact-rows')).toBeNull(); expect(gridProps.length).toBeGreaterThan(0); }); diff --git a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx index 18543d93c05..d0d98f7a7fa 100644 --- a/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListViewBlock.specInputs-13047.test.tsx @@ -272,14 +272,14 @@ describe('objectui#13047 — the toolbar and chrome keys, drawn by `ListView` it it('`userActions`: `sort: false` takes the Sort control off the toolbar; absent keeps it', async () => { const control = mount(); await loaded(control.dataSource); - expect(screen.queryByTestId('toolbar-sort-trigger')).not.toBeNull(); + expect(screen.queryByTestId('condition-sort')).not.toBeNull(); cleanup(); const { dataSource } = mount({ userActions: { sort: false } }); await loaded(dataSource); - expect(screen.queryByTestId('toolbar-sort-trigger')).toBeNull(); + expect(screen.queryByTestId('condition-sort')).toBeNull(); // Only the member it names: Filter stays. - expect(screen.queryByTestId('toolbar-filter-trigger')).not.toBeNull(); + expect(screen.queryByTestId('condition-add-filter')).not.toBeNull(); }); it('`compactToolbar: false` puts the wide buttons back on the toolbar; the default keeps them in the Display form', async () => { diff --git a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.exportFooter-29175.test.tsx b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.exportFooter-29175.test.tsx index a79ae484a28..b401cbf1015 100644 --- a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.exportFooter-29175.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.exportFooter-29175.test.tsx @@ -57,7 +57,6 @@ describe('ViewSettingsPopover — every export entry stays inside the panel (obj const panel = openPopover({ changedCount: 1, onReset: vi.fn(), - onRefresh: vi.fn(), exportFormats: FORMATS, onExport, }); @@ -81,29 +80,26 @@ describe('ViewSettingsPopover — every export entry stays inside the panel (obj const panel = openPopover({ changedCount: 1, onReset: vi.fn(), - onRefresh: vi.fn(), exportFormats: FORMATS, onExport: vi.fn(), }); const footer = within(panel).getByTestId('display-footer'); const group = within(panel).getByTestId('display-export-group'); - const refresh = within(panel).getByTestId('refresh-button'); const reset = within(panel).getByTestId('display-reset-button'); // The cause of the clipping was Refresh and the exports sharing one // non-wrapping group: the export row now holds export entries only. - expect(group).not.toContainElement(refresh); + // Refresh is gone from the panel (objectstack#35878). + expect(within(panel).queryByTestId('refresh-button')).toBeNull(); expect(group).not.toContainElement(reset); expect(within(group).getAllByRole('button')).toHaveLength(FORMATS.length); - expect(refresh.parentElement).toBe(footer); expect(reset.parentElement).toBe(footer); }); it('draws no export row when the view offers no format', () => { - const panel = openPopover({ onRefresh: vi.fn(), exportFormats: [], onExport: vi.fn() }); + const panel = openPopover({ exportFormats: [], onExport: vi.fn() }); - expect(within(panel).getByTestId('refresh-button')).toBeInTheDocument(); expect(within(panel).queryByTestId('display-export-group')).not.toBeInTheDocument(); }); }); diff --git a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.optionsMenu-35551.test.tsx b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.optionsMenu-35551.test.tsx index 79e2c11b574..88c54a1e14f 100644 --- a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.optionsMenu-35551.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.optionsMenu-35551.test.tsx @@ -85,14 +85,14 @@ describe('Options menu — the first level', () => { groupingConfig: { fields: [{ field: 'stage', order: 'asc' }] }, showDensity: true, density: { mode: 'comfortable', cycle: () => {}, setMode: () => {} }, - showInlineEdit: true, - setInlineEdit: () => {}, }); expect(value('options-row-layout')).toBe('Grid'); - expect(value('options-row-fields')).toBe('3 shown'); + // objectstack#35878: the shown columns are in place on this level. + expect(screen.getByTestId('options-columns-list')).toBeInTheDocument(); expect(value('options-row-group')).toBe('Stage'); expect(value('options-row-row-height')).toBe('Standard'); - expect(screen.getByTestId('options-row-more')).toBeTruthy(); + // objectstack#35878: no More level on this panel. + expect(screen.queryByTestId('options-row-more')).toBeNull(); }); it('opens a second level per row, and its back control returns to the menu', () => { @@ -220,14 +220,14 @@ describe('Options menu — Fields', () => { const updateHiddenFields = vi.fn(); openMenu({ updateHiddenFields }); // 1 = the trigger (openMenu), 2 = Fields, 3 = the eye. - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); fireEvent.click(screen.getByTestId('options-fields-hide-probability')); expect([...updateHiddenFields.mock.calls[0][0]]).toEqual(['probability']); cleanup(); const show = vi.fn(); openMenu({ hiddenFields: new Set(['probability']), updateHiddenFields: show }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); fireEvent.click(screen.getByTestId('options-fields-item-probability')); expect([...show.mock.calls[0][0]]).toEqual([]); }); @@ -235,7 +235,7 @@ describe('Options menu — Fields', () => { it('search narrows both lists; an addable field is added with one click', () => { const onAddField = vi.fn(); openMenu({ addableFields: [{ name: 'close_date', label: 'Close date' }], onAddField }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); fireEvent.change(screen.getByTestId('options-fields-search'), { target: { value: 'clo' } }); expect(screen.queryByTestId('options-fields-shown')).toBeNull(); fireEvent.click(screen.getByTestId('options-fields-item-close_date')); @@ -247,7 +247,7 @@ describe('Options menu — Fields', () => { it('dragging a shown field writes the whole order, a hidden field keeping its relative place', () => { const onFieldOrderChange = vi.fn(); openMenu({ hiddenFields: new Set(['stage']), onFieldOrderChange, fieldOrder: ['name', 'stage', 'amount', 'probability'] }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); const dataTransfer = { setData: vi.fn(), getData: vi.fn(() => 'probability'), effectAllowed: '', dropEffect: '' }; fireEvent.dragStart(screen.getByTestId('options-fields-row-probability'), { dataTransfer }); fireEvent.dragOver(screen.getByTestId('options-fields-row-name'), { dataTransfer }); @@ -258,18 +258,18 @@ describe('Options menu — Fields', () => { it('the handle moves a field with the arrow keys', () => { const onFieldOrderChange = vi.fn(); openMenu({ onFieldOrderChange }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); fireEvent.keyDown(screen.getByTestId('options-fields-move-name'), { key: 'ArrowDown' }); expect(onFieldOrderChange).toHaveBeenCalledWith(['stage', 'name', 'amount', 'probability']); }); it('offers no drag without a host to write the order, and none while searching', () => { openMenu({ onFieldOrderChange: undefined }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); expect(screen.queryByTestId('options-fields-move-name')).toBeNull(); cleanup(); openMenu({ onFieldOrderChange: () => {} }); - fireEvent.click(screen.getByTestId('options-row-fields')); + fireEvent.click(screen.getByTestId('options-add-column')); expect(screen.getByTestId('options-fields-move-name')).toBeTruthy(); fireEvent.change(screen.getByTestId('options-fields-search'), { target: { value: 'a' } }); expect(screen.queryByTestId('options-fields-move-name')).toBeNull(); @@ -284,9 +284,6 @@ describe('Options menu — words', () => { hiddenFields: new Set(['amount']), onReset: () => {}, changedCount: 1, - onRefresh: () => {}, - showInlineEdit: true, - setInlineEdit: () => {}, }, 'zh'); const named = (root: HTMLElement) => { for (const control of within(root).queryAllByRole('button').concat(within(root).queryAllByRole('textbox'))) { @@ -296,17 +293,12 @@ describe('Options menu — words', () => { }; named(screen.getByTestId('view-settings-content')); expect(screen.getByTestId('display-reset-button').textContent).toBe(zhPack.list.optionsMenu.restoreDefaults); - expect(screen.getByTestId('refresh-button').textContent).toBe(zhPack.list.refresh); - fireEvent.click(screen.getByTestId('options-row-fields')); - named(screen.getByTestId('view-settings-content')); - fireEvent.click(screen.getByTestId('options-back')); - fireEvent.click(screen.getByTestId('options-row-more')); + fireEvent.click(screen.getByTestId('options-add-column')); named(screen.getByTestId('view-settings-content')); }); - it('the More level holds no Open records section: how a record opens is no setting (objectstack#35854)', () => { - openMenu({ showInlineEdit: true, setInlineEdit: () => {} }, 'zh'); - fireEvent.click(screen.getByTestId('options-row-more')); + it('the panel holds no Open records section: how a record opens is no setting (objectstack#35854)', () => { + openMenu({}, 'zh'); expect(screen.queryByTestId('display-record-open')).toBeNull(); expect(screen.queryByTestId('display-record-open-declared')).toBeNull(); const text = screen.getByTestId('view-settings-content').textContent ?? ''; diff --git a/ui/packages/plugin-list/src/__tests__/conditionPanels.ts b/ui/packages/plugin-list/src/__tests__/conditionPanels.ts index 1f5babdebc5..10e838b0aa8 100644 --- a/ui/packages/plugin-list/src/__tests__/conditionPanels.ts +++ b/ui/packages/plugin-list/src/__tests__/conditionPanels.ts @@ -22,8 +22,15 @@ export async function openAdvancedFilter(): Promise { return screen.findByTestId('filter-panel-advanced'); } -/** After the Sort trigger: step into the advanced panel and wait for it (any locale). */ +/** + * After the Sort trigger: the panel of every sort level (any locale). With a + * sort in force the row's one sort chip opens it at once (objectstack#35878 on + * objectstack#35876's `sort-chip-panel`); with none, the dashed 「Sort」 opens + * the field list, and its footer steps into the same content. + */ export async function openAdvancedSort(): Promise { + const levels = screen.queryByTestId('sort-chip-panel'); + if (levels) return levels; fireEvent.click(await screen.findByTestId('sort-panel-open-advanced')); return screen.findByTestId('sort-panel-advanced'); } diff --git a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx index 8f7d092a05d..531eceb0b0f 100644 --- a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx +++ b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx @@ -1,22 +1,18 @@ /** - * ViewSettingsPopover — the list's Options menu. + * ViewSettingsPopover — the list's 视图设置 panel (objectstack#35878). * - * Opened from the view bar's Options trigger, it is a short menu: each row - * names one setting on the left and its current value on the right, and opens - * a second level that changes it. At the top, the view's name (renamed in - * place where the host allows it). Then, each only when the host offers it: + * Opened from the trigger beside the view's name on the view bar. Its first + * level is the content itself, not a menu of entries: the view's name + * (renamed in place where the host allows it), the columns the view shows + * (drag to reorder, the eye to hide) and 「+ Add column」 (the hidden fields + * and the object's other fields, one step away), then, each only when the + * host offers it, Layout, Group, Row height and Row color, each opening a + * second level. The footer keeps Save, Restore defaults and the export + * entries. Sort and Filter are not here: the condition row under the bar + * carries them. * - * - Layout: the visualizations, each by icon AND words; - * - Fields: 「N shown」 → the shown fields (search, drag to reorder, eye to - * hide) above the hidden ones (one click shows a field again); - * - Group, Row color; - * - Row height: compact, standard, spacious; - * - Sort (below `sm` only, where the bar draws no Sort button); - * - More: row numbers, inline edit. (How a record opens is no setting: the - * name opens the page, the name cell's hover icon the side panel, - * objectstack#35854.) - * - * The footer keeps Restore defaults, Refresh and the export entries. + * The content is `ViewSettingsContent`, apart from its container: a phone's + * bottom sheet can hold the same content. * * Every setting here is the reader's own: this component writes nothing * itself, each control hands its change to the host, which keeps it as the @@ -41,7 +37,6 @@ import { SelectItem, SelectTrigger, SelectValue, - Switch, } from '@object-ui/components'; import { SlidersHorizontal, @@ -51,7 +46,8 @@ import { Check, ChevronLeft, ChevronRight, - RotateCw, + ChevronDown, + Plus, Download, Loader2, Undo2, @@ -178,15 +174,6 @@ export interface ViewSettingsPopoverProps { */ layout?: (closeMenu: () => void) => React.ReactNode; - /** - * The Sort block, drawn below `sm` only (objectstack#28911): there the bar - * keeps Filter and Display, and the host's Sort button is hidden. From `sm` - * up that button carries Sort, so the panel draws nothing for it. The host - * passes the same panel its Sort popover draws, so both write through one - * door; it is not a display setting and does not count in `changedCount`. - */ - sort?: React.ReactNode; - showGroup?: boolean; groupingConfig?: any; setGroupingConfig?: (next: any) => void; @@ -211,16 +198,6 @@ export interface ViewSettingsPopoverProps { addableFields?: ViewSettingsField[]; onAddField?: (name: string) => void; - /** - * Record editing — toggle the grid's inline-edit mode. `setInlineEdit` hands - * the change to the host, which decides what it does with it; the console - * keeps it session-only and writes nothing to the view (objectui#5144, - * ruling E). - */ - showInlineEdit?: boolean; - inlineEdit?: boolean; - setInlineEdit?: (next: boolean) => void; - /** * How many of the settings above differ from the view's own. Drawn as the * trigger's count; zero draws none. The host computes it — only it knows @@ -242,10 +219,6 @@ export interface ViewSettingsPopoverProps { */ onSave?: () => void; - /** Footer: re-fetch the list. Drawn when wired. */ - onRefresh?: () => void; - refreshing?: boolean; - /** Footer: one export entry per format. Drawn when there is a format. */ exportFormats?: string[]; onExport?: (format: string) => void; @@ -254,7 +227,7 @@ export interface ViewSettingsPopoverProps { } /** The second levels of the menu; `root` is the menu itself. */ -type MenuPage = 'root' | 'layout' | 'fields' | 'group' | 'color' | 'rowHeight' | 'sort' | 'more'; +type MenuPage = 'root' | 'layout' | 'fields' | 'group' | 'color' | 'rowHeight'; /** * One row of the menu: the setting's name on the left, its current value on @@ -380,34 +353,6 @@ function ColorFieldPicker({ ); } -/** - * One on/off row of the panel: the words on the left, a `role="switch"` on the - * right. The words are the switch's `
); - } else if (page === 'sort' && sort) { - body = ( - -
{sort}
-
- ); - } else if (page === 'more' && hasMore) { - body = ( - - {showInlineEdit && setInlineEdit && ( - - )} - - ); } + return ( + <> +
{body}
+ + {page === 'root' && hasFooter && ( +
+ {onSave && ( + + )} + {onReset && ( + + )} + {/* The export entries take a full row and wrap within it: the menu + is a fixed width, and one entry per format can outgrow it. */} + {hasExport && ( +
+ {exportFormats!.map((format) => ( + + ))} +
+ )} + {exportError && ( +
+ {exportError} +
+ )} +
+ )} + + ); +} + +export function ViewSettingsPopover(props: ViewSettingsPopoverProps) { + const { t, changedCount = 0 } = props; + const [open, setOpen] = React.useState(false); + const belowSm = useBelowSm(); + // Closing through the controlled state lets Radix return focus to the + // trigger, as Escape and an outside click do. + const closeMenu = React.useCallback(() => setOpen(false), []); + // 「视图设置」, beside the view's name (objectstack#35878). + const triggerLabel = t('list.viewSettings', { defaultValue: 'View settings' }); + return ( @@ -854,14 +868,16 @@ export function ViewSettingsPopover(props: ViewSettingsPopoverProps) { className={cn( TOOLBAR_TEXT_TRIGGER, PHONE_TOUCH_TARGET, + 'shrink-0 gap-1', changedCount > 0 && 'text-foreground font-medium', )} data-testid="toolbar-display-trigger" > - {/* A named text button from `sm` up, like Filter and Sort - (objectstack#35548); an icon below it (objectui#12695). */} - - {/* Below `sm` the menu takes the phone's width, as Filter and Sort do. */} + {/* Below `sm` the panel takes the phone's width, as Filter and Sort do. */} { event.preventDefault(); (event.currentTarget as HTMLElement | null)?.focus?.(); }} > -
{body}
- - {page === 'root' && hasFooter && ( -
- {onSave && ( - - )} - {onReset && ( - - )} - {onRefresh && ( - - )} - {/* The export entries take a full row and wrap within it: the menu - is a fixed width, and one entry per format can outgrow it. */} - {hasExport && ( -
- {exportFormats!.map((format) => ( - - ))} -
- )} - {exportError && ( -
- {exportError} -
- )} -
- )} +
); diff --git a/ui/packages/plugin-list/src/conditions/FieldList.tsx b/ui/packages/plugin-list/src/conditions/FieldList.tsx index d2987f2d022..68432ffa2f9 100644 --- a/ui/packages/plugin-list/src/conditions/FieldList.tsx +++ b/ui/packages/plugin-list/src/conditions/FieldList.tsx @@ -93,6 +93,8 @@ export interface FieldListProps { onAdd?: (name: string) => void; /** Overrides the search box's placeholder and accessible name. */ searchPlaceholder?: string; + /** `false` ⇒ no search box: a short list drawn in place (the 视图设置 panel's columns, objectstack#35878). */ + searchable?: boolean; /** A row above the search box (the sort direction). */ header?: React.ReactNode; /** A row below the list (the advanced filter). */ @@ -205,6 +207,7 @@ export function FieldList({ addable, onAdd, searchPlaceholder, + searchable = true, header, footer, testId = 'field-list', @@ -443,6 +446,7 @@ export function FieldList({ return (
{header} + {searchable && (
+ )}
{section(shownMatches, t('listConditions.fieldList.shown'), 'shown')} {section(hiddenMatches, t('listConditions.fieldList.hidden'), 'hidden')} diff --git a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx index 27b84e1e6f8..a0bf4ab900b 100644 --- a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx +++ b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx @@ -42,7 +42,7 @@ import { } from '@object-ui/components'; import { referencedRecordTitle } from '@object-ui/core'; import type { DataSource } from '@object-ui/types'; -import { ArrowDown, ArrowUp, Lock, Plus, RotateCcw, SlidersHorizontal, X } from 'lucide-react'; +import { ArrowDown, ArrowUp, ArrowUpDown, ListFilter, Lock, Plus, RotateCcw, SlidersHorizontal, X } from 'lucide-react'; import { FieldList, type FieldListItem } from './FieldList'; import { FilterValuePanel, isQuickRowApplied, quickDateWindowOf } from './FilterValuePanel'; import { @@ -50,7 +50,6 @@ import { chipsAreIndependent, defaultQuickOperator, isValuelessOperator, - moveSortItem, newConditionId, quickFilterFamily, readViewConditions, @@ -456,7 +455,11 @@ export function SortPanel({ export interface ConditionChipRowProps { sort: ReadonlyArray; sortFields: ReadonlyArray; - onSortChange: (next: SortItem[]) => void; + /** + * Kept for hosts that pass it; the row writes no sort itself since + * objectstack#35878 — its one sort chip opens `renderSortPanel`, which writes. + */ + onSortChange?: (next: SortItem[]) => void; filters: FilterBuilderRowGroup; filterFields: ReadonlyArray; onFiltersChange: (next: FilterBuilderRowGroup) => void; @@ -485,16 +488,40 @@ export interface ConditionChipRowProps { onReset?: () => void; /** Extra chips the host draws after the filter chips (its own quick filters). */ trailing?: React.ReactNode; + /** + * The sort panel the one sort chip (or, with no sort, the 「Sort」 button) + * opens (objectstack#35878), as a function of the call that closes it. + * Absent ⇒ no sort chip and no 「Sort」 button: the row draws the filter + * half only. + */ + renderSortPanel?: (close: () => void) => React.ReactNode; + /** + * The host's end of the row (objectstack#35878: 「Personalized · Reset」), + * drawn at the right in place of the row's own 「Reset」. + */ + end?: React.ReactNode; + /** The reader may add a filter (`userActions.filter`); `false` ⇒ no 「Filter」 and no 「+」. */ + filterOffered?: boolean; className?: string; } const CHIP_CLASS = 'inline-flex h-6 max-w-[280px] shrink-0 items-center gap-1 rounded-full border px-2 text-[13px] leading-none'; +/** + * A control of the condition row below `sm`: 44 px on both sides (WCAG 2.5.5), + * as the bar's Filter and Sort triggers were before they moved here + * (objectstack#35878). + */ +const ROW_TOUCH_TARGET = 'max-sm:h-11 max-sm:min-w-11'; + +/** 「Sort」, 「Filter」 and 「+」 before anything is set: dashed, so they do not read as a condition in force. */ +const EMPTY_BUTTON_CLASS = + 'max-sm:h-11 max-sm:min-w-11 inline-flex h-6 shrink-0 items-center gap-1 rounded-full border border-dashed px-2 text-[13px] leading-none text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring'; + export function ConditionChipRow({ sort, sortFields, - onSortChange, filters, filterFields, onFiltersChange, @@ -506,11 +533,13 @@ export function ConditionChipRow({ renderSortLevels, onReset, trailing, + renderSortPanel, + end, + filterOffered = true, className, }: ConditionChipRowProps) { const { t } = useListConditionTranslation(); const [openChip, setOpenChip] = React.useState(null); - const dragFrom = React.useRef(null); // Keyed on the names, not on the array the host may rebuild every render. const hostDrawnKey = (hostDrawnFields ?? []).join('\u0000'); @@ -525,13 +554,13 @@ export function ConditionChipRow({ ]; const nameOf = useLookupValueNames(dataSource, filterFields, namedConditions); const independent = chipsAreIndependent(filters); - const hasChips = sort.length > 0 || viewChips.length > 0 || appliedRows.length > 0 || !!trailing; - if (!hasChips) return null; + // Nothing to show and nothing to offer: the row the host reserves stays empty. + if (!renderSortPanel && !filterOffered && !end && !trailing && sort.length === 0 && viewChips.length === 0 && appliedRows.length === 0) { + return null; + } const fieldOf = (list: ReadonlyArray, name: string) => list.find((f) => f.value === name); - const moveSort = (from: number, to: number) => onSortChange(moveSortItem(sort, from, to)); - const filterPopover = (key: string, trigger: React.ReactNode, conditionId?: string) => ( setOpenChip(open ? key : null)}> {trigger} @@ -543,7 +572,9 @@ export function ConditionChipRow({ onChange={onFiltersChange} renderAdvanced={renderAdvanced} conditionId={conditionId} - testId={`condition-panel-${key}`} + // The add-a-filter panel is the list's Filter panel (it was the + // bar's Filter popover before objectstack#35878): its own id. + testId={key === 'add' ? undefined : `condition-panel-${key}`} /> @@ -553,88 +584,57 @@ export function ConditionChipRow({
- {sort.map((item, index) => { - const field = fieldOf(sortFields, item.field); - const label = field?.label ?? item.field; - const direction = sortDirectionLabel(field?.type, item.order === 'desc' ? 'desc' : 'asc', t); - const Arrow = item.order === 'desc' ? ArrowDown : ArrowUp; - return ( - 1} - title={sort.length > 1 ? t('listConditions.chips.dragSort') : undefined} - onDragStart={(event) => { - dragFrom.current = index; - event.dataTransfer?.setData('text/plain', String(index)); - }} - onDragOver={(event) => { - if (dragFrom.current !== null) event.preventDefault(); - }} - onDrop={(event) => { - event.preventDefault(); - if (dragFrom.current !== null) moveSort(dragFrom.current, index); - dragFrom.current = null; - }} - onDragEnd={() => { - dragFrom.current = null; - }} - data-testid={`sort-chip-${item.field}`} - data-order={item.order} - data-priority={index + 1} - > - {(() => { - const chipKey = `sort:${item.id}`; - const chipButton = ( - - ); - // objectstack#35876 — the chip opens every sort level in one - // panel; it does not flip the direction. - return ( - setOpenChip(open ? chipKey : null)}> - {chipButton} - -
- {renderSortLevels()} -
-
-
- ); - })()} - -
- ); - })} + {/* objectstack#35878 — the sort, at any number of levels, is ONE chip: + 「Sorted by X」, 「+N」 for the levels after the first. With no sort + it is the dashed 「Sort」 button, which opens the sort panel; the + chip opens every level at once (objectstack#35876). */} + {renderSortPanel && ( + setOpenChip(open ? 'sort' : null)}> + + {sort.length > 0 ? ( + + ) : ( + + )} + + + {sort.length > 0 ? ( + // objectstack#35876 — a sort in force opens every level in one + // panel; the chip never flips a direction itself. +
+ {renderSortLevels()} +
+ ) : ( + renderSortPanel(() => setOpenChip(null)) + )} +
+
+ )} {viewChips.map((chip) => { const text = viewChipText(chip, filterFields, t, nameOf); @@ -706,21 +706,32 @@ export function ConditionChipRow({ {trailing} - {filterPopover( + {/* With no filter of the reader's own, the dashed 「Filter」 button; with + one, a 「+」 after the chips (objectstack#35878). Either opens the + field list. */} + {filterOffered && filterPopover( 'add', - , + appliedRows.length === 0 ? ( + + ) : ( + + ), )} - {onReset && ( + {end ? ( +
{end}
+ ) : onReset && ( + ); + function TwoRow(props: Partial>) { + return ( + {}} + filters={EMPTY} + filterFields={FIELDS} + onFiltersChange={() => {}} + renderAdvanced={() =>
} + renderSortLevels={() =>
} + renderSortPanel={sortPanel} + {...props} + /> + ); + } + const stageFilter: FilterBuilderRowGroup = { + id: 'root', + logic: 'and', + conditions: [{ id: 'c1', field: 'stage', operator: 'in', value: ['negotiation'] }], + }; + + it('with nothing set it is there, with the dashed 「Sort」 and 「Filter」 buttons and nothing else', () => { + render(); + expect(screen.getByTestId('condition-sort')).toHaveTextContent('Sort'); + expect(screen.getByTestId('condition-sort')).toHaveAttribute('data-levels', '0'); + expect(screen.getByTestId('condition-add-filter')).toHaveTextContent('Filter'); + expect(screen.getByTestId('condition-add-filter')).toHaveAttribute('data-empty', 'true'); + expect(screen.getByTestId('condition-sort').className).toContain('border-dashed'); + expect(screen.queryByTestId('condition-reset')).toBeNull(); + }); + + it('a sort of any number of levels is ONE chip, 「Sorted by X」 with 「+N」, before the filter chips; it opens every level and changes no sort (objectstack#35876)', () => { + const sort: SortItem[] = [ + { id: 's1', field: 'amount', order: 'desc' }, + { id: 's2', field: 'name', order: 'asc' }, + { id: 's3', field: 'stage', order: 'asc' }, + ]; + const onSortChange = vi.fn(); + render(); + const chips = screen.getAllByTestId('condition-sort'); + expect(chips).toHaveLength(1); + expect(chips[0]).toHaveTextContent('Sorted by Amount'); + expect(screen.getByTestId('sort-chip-more')).toHaveTextContent('+2'); + expect(chips[0].compareDocumentPosition(screen.getByTestId('filter-chip-stage')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + fireEvent.click(chips[0]); + expect(within(screen.getByTestId('sort-chip-panel')).getByTestId('sort-levels-builder')).toBeInTheDocument(); + expect(screen.queryByTestId('sort-panel-stand-in')).toBeNull(); + expect(onSortChange).not.toHaveBeenCalled(); + }); + + it('with no sort the dashed 「Sort」 opens the sort panel, whose close closes it', () => { + render(); + fireEvent.click(screen.getByTestId('condition-sort')); + expect(screen.queryByTestId('sort-chip-panel')).toBeNull(); + fireEvent.click(screen.getByTestId('sort-panel-stand-in')); + expect(screen.queryByTestId('sort-panel-stand-in')).toBeNull(); + }); + + it('CONTROL: one level reads no 「+N」', () => { + render(); + expect(screen.getByTestId('condition-sort')).toHaveTextContent('Sorted by Name'); + expect(screen.queryByTestId('sort-chip-more')).toBeNull(); + }); + + it('with a filter of the reader\'s own: its chip, then 「+」, which opens the field list', () => { + render(); + expect(screen.getByTestId('filter-chip-stage')).toBeInTheDocument(); + const add = screen.getByTestId('condition-add-filter'); + expect(add).not.toHaveAttribute('data-empty'); + expect(add).toHaveAccessibleName('Add filter'); + expect(add.compareDocumentPosition(screen.getByTestId('filter-chip-stage')) & Node.DOCUMENT_POSITION_PRECEDING).toBeTruthy(); + fireEvent.click(add); + expect(screen.getByTestId('filter-panel-fields')).toBeInTheDocument(); + }); + + it('the host\'s end takes the place of the row\'s own Reset', () => { + render( {}} end={Personalized} />); + expect(screen.getByTestId('condition-row-end')).toContainElement(screen.getByTestId('host-end')); + expect(screen.queryByTestId('condition-reset')).toBeNull(); + }); + + it('without a sort panel or a filter to offer, and nothing set, the row draws nothing', () => { + const { container } = render(); + expect(container).toBeEmptyDOMElement(); + }); + + it('one line: what does not fit scrolls sideways', () => { + render(); + const row = screen.getByTestId('condition-chips'); + expect(row.className.split(/\s+/)).toEqual(expect.arrayContaining(['flex-nowrap', 'overflow-x-auto'])); + }); +}); diff --git a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts index f272bab9d89..708b657360a 100644 --- a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts +++ b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts @@ -65,6 +65,9 @@ export const LIST_CONDITION_DEFAULT_TRANSLATIONS: Record = { 'listConditions.chips.listJoiner': ', ', 'listConditions.chips.or': ' or ', 'listConditions.chips.addFilter': 'Add filter', + 'listConditions.chips.sort': 'Sort', + 'listConditions.chips.filter': 'Filter', + 'listConditions.chips.sortedBy': 'Sorted by {{field}}', 'listConditions.chips.reset': 'Reset', 'listConditions.chips.resetHint': 'Back to the view as saved', 'listConditions.chips.remove': 'Remove {{label}}', diff --git a/ui/packages/plugin-list/src/listToolbarRow.ts b/ui/packages/plugin-list/src/listToolbarRow.ts index e2bac0b4529..e1d8f91050b 100644 --- a/ui/packages/plugin-list/src/listToolbarRow.ts +++ b/ui/packages/plugin-list/src/listToolbarRow.ts @@ -51,8 +51,11 @@ export const TOOLBAR_LEFT_GROUP = 'flex items-center gap-2 overflow-x-auto min-w export const TOOLBAR_LEFT_GROUP_LEADING = 'flex flex-1 items-center gap-2 overflow-x-auto min-w-0 max-sm:contents'; -/** The wrapper of the host's leading node. */ -export const TOOLBAR_LEADING = 'flex min-w-0 flex-1 items-center max-sm:basis-auto'; +/** + * The wrapper of the host's leading node. It shrinks but does not grow + * (objectstack#35878): 视图设置 follows it directly, beside the view's name. + */ +export const TOOLBAR_LEADING = 'flex min-w-0 shrink items-center max-sm:basis-auto'; /** The user-filter chips. */ export const TOOLBAR_USER_FILTERS = 'shrink-0 min-w-0 overflow-x-auto';