From a9ba435929dfd12a24478b28e765ee8ac2315182 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 17:09:28 +0000 Subject: [PATCH 1/6] =?UTF-8?q?feat(list):=20two-row=20list=20toolbar:=20o?= =?UTF-8?q?bject=20name=20and=20page=20acts=20in=20the=20view=20bar,=20?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E8=AE=BE=E7=BD=AE=20beside=20the=20view=20na?= =?UTF-8?q?me,=20a=20resident=20condition=20row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgXbiCh84nxg4WvGahS --- .../src/views/ListPersonalizedMarker.tsx | 35 +- .../app-shell/src/views/ObjectView.tsx | 75 ++- .../src/views/objectViewListRenderer.tsx | 46 +- .../src/views/objectViewPageHeader.tsx | 279 ++++++--- ui/packages/i18n/src/locales/ar.ts | 4 + ui/packages/i18n/src/locales/de.ts | 4 + ui/packages/i18n/src/locales/en.ts | 4 + ui/packages/i18n/src/locales/es.ts | 4 + ui/packages/i18n/src/locales/fr.ts | 4 + ui/packages/i18n/src/locales/ja.ts | 4 + ui/packages/i18n/src/locales/ko.ts | 4 + ui/packages/i18n/src/locales/pt-BR.ts | 4 + ui/packages/i18n/src/locales/ru.ts | 4 + ui/packages/i18n/src/locales/zh-Hans.ts | 4 + ui/packages/i18n/src/locales/zh-Hant.ts | 4 + .../src/components/SelectionPageBar.tsx | 8 +- ui/packages/plugin-list/src/ListView.tsx | 568 ++++++++---------- .../src/components/ViewSettingsPopover.tsx | 456 +++++--------- .../plugin-list/src/conditions/FieldList.tsx | 5 + .../src/conditions/ListConditionControls.tsx | 173 +++--- .../src/conditions/conditionTranslations.ts | 3 + ui/packages/plugin-list/src/listToolbarRow.ts | 7 +- 22 files changed, 870 insertions(+), 829 deletions(-) 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.tsx b/ui/packages/app-shell/src/views/ObjectView.tsx index 4c24e16db0a..6686c28aaf7 100644 --- a/ui/packages/app-shell/src/views/ObjectView.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.tsx @@ -9,7 +9,7 @@ * - ListView delegation for non-grid view types (kanban, calendar, chart, etc.) */ -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'; @@ -83,7 +83,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'; @@ -1035,6 +1042,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({ @@ -1071,12 +1086,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, @@ -1145,6 +1171,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 @@ -1179,7 +1224,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 / @@ -1199,23 +1245,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 @@ -1394,6 +1426,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co />
+ ); return ( diff --git a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx index 47ab0125be3..279ac9520a7 100644 --- a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx +++ b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx @@ -101,6 +101,8 @@ export function useObjectViewListRenderer({ openAsPage, rowOpensRecord, phoneTitle, + viewBarTrailing, + conditionRowEnd, handleListPersonalizationChange, urlFilters, initialUfSelections, @@ -148,6 +150,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']; @@ -191,6 +202,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). @@ -373,8 +393,10 @@ export function useObjectViewListRenderer({ const chartPage = (chartFace: ReactNode) => (
{hasPhoneTitle && ( -
+
+ {/* objectstack#35878 — the page's acts end this bar too. */} + {hasViewBarTrailing && }
)} {chartFace} @@ -1140,22 +1162,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, recordOpen, openAsPage, rowOpensRecord, handleListRowsChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, 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, recordOpen, openAsPage, rowOpensRecord, handleListRowsChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, 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 { @@ -1176,3 +1202,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..ad24d7ca034 100644 --- a/ui/packages/app-shell/src/views/objectViewPageHeader.tsx +++ b/ui/packages/app-shell/src/views/objectViewPageHeader.tsx @@ -10,8 +10,8 @@ * 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, DropdownMenu, @@ -47,23 +47,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 +63,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 +176,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 +210,91 @@ 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'; + +/** + * 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 ( + + + + {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. */} +
+ {!pageBar.selecting && ( + <> + {tools} + + + + + )} +
+ ); +} diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 14b652d847d..24cec1e9f99 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -1069,6 +1069,7 @@ const ar = { dataLimitReached: "يتم عرض أول {{limit}} سجل. قد تتوفر بيانات إضافية.", display: "العرض", options: "خيارات", + viewSettings: "إعدادات العرض", layout: "التخطيط", resetToViewDefault: "إعادة التعيين إلى الإعدادات الافتراضية للعرض", recordOpen: "فتح السجلات", @@ -5556,6 +5557,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 58e70f7edbe..21c4c8e8fa1 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -952,6 +952,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", recordOpen: "Datensätze öffnen", @@ -4970,6 +4971,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 dff9e7910d5..d1de2888807 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -1241,6 +1241,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', recordOpen: 'Open records', @@ -5726,6 +5727,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 e0c7e224bfd..01424689984 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -984,6 +984,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", recordOpen: "Abrir registros", @@ -5117,6 +5118,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 82acd914de1..7dd961da1a0 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -979,6 +979,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", recordOpen: "Ouvrir les enregistrements", @@ -5113,6 +5114,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 6991ebb6490..17d8bd7d9c9 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -952,6 +952,7 @@ const ja = { dataLimitReached: "最初の {{limit}} 件のレコードを表示しています。さらにデータがある場合があります。", display: "表示", options: "オプション", + viewSettings: "ビュー設定", layout: "レイアウト", resetToViewDefault: "ビューの既定に戻す", recordOpen: "レコードを開く", @@ -4972,6 +4973,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 13f7a980535..e247c8fa5a8 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -952,6 +952,7 @@ const ko = { dataLimitReached: "처음 {{limit}}개 레코드를 표시합니다. 더 많은 데이터가 있을 수 있습니다.", display: "표시", options: "옵션", + viewSettings: "보기 설정", layout: "레이아웃", resetToViewDefault: "보기 기본값으로 재설정", recordOpen: "레코드 열기", @@ -4969,6 +4970,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 171f9615455..9a866fbe261 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -979,6 +979,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", recordOpen: "Abrir registros", @@ -5112,6 +5113,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 0629e208996..f61bb1b04e5 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -1012,6 +1012,7 @@ const ru = { dataLimitReached: "Отображаются первые {{limit}} записей. Возможно, есть ещё данные.", display: "Отображение", options: "Параметры", + viewSettings: "Настройки представления", layout: "Макет", resetToViewDefault: "Сбросить к настройкам представления", recordOpen: "Открытие записей", @@ -5273,6 +5274,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 3812641e6a2..cb56ad206bd 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -979,6 +979,7 @@ const zh = { dataLimitReached: '显示前 {{limit}} 条记录。可能有更多数据。', display: '显示', options: '选项', + viewSettings: '视图设置', layout: '布局', resetToViewDefault: '恢复视图默认设置', recordOpen: '打开记录', @@ -5029,6 +5030,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 3ff3be4e69d..0a285e8de0f 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -979,6 +979,7 @@ const zhHant = { dataLimitReached: '顯示前 {{limit}} 條記錄。可能有更多資料。', display: '顯示', options: '選項', + viewSettings: '檢視設定', layout: '佈局', resetToViewDefault: '恢復檢視預設設定', recordOpen: '開啟記錄', @@ -5029,6 +5030,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 e865e1e8a1a..b433bdad3a9 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'; @@ -20,12 +20,10 @@ import { groupFieldOptions, type ViewSettingsField, type ViewSettingsRecordOpen, - 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, @@ -36,7 +34,6 @@ import { TOOLBAR_USER_FILTERS_LEADING_PHONE, TOOLBAR_CLUSTER, TOOLBAR_CLUSTER_LEADING_PHONE, - TOOLBAR_TEXT_TRIGGER, } from './listToolbarRow'; import { calendarWindowCovers, @@ -458,6 +455,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 @@ -665,7 +679,10 @@ export interface ListViewProps { * * A HOST prop, never a schema key: the preference is the reader's, kept by * the host, and the setter is a function value no document can carry. - * Absent ⇒ the panel draws no such section, exactly as before. + * + * Drawn nowhere since objectstack#35878: the 视图设置 panel has no More + * level. objectstack#35854 retires the preference itself and this prop with + * it; until then a host may still pass it, and it changes nothing. */ recordOpen?: ViewSettingsRecordOpen; /** @@ -2117,6 +2134,8 @@ export const ListView = React.forwardRef(({ initialFilters, initialSearchTerm, toolbarLeading, + toolbarTrailing, + conditionRowEnd, rowAdornment, recordLinkAdornment, rowOpensRecord, @@ -2130,7 +2149,6 @@ export const ListView = React.forwardRef(({ onRenameView, onSaveView, onResetView, - recordOpen, page, onPageChange, hostDrawnConditionFields, @@ -2414,7 +2432,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), ); @@ -2500,7 +2517,6 @@ export const ListView = React.forwardRef(({ ); }, [currentSort, declaredSort]); - const [showFilters, setShowFilters] = React.useState(false); const [currentFilters, setCurrentFilters] = React.useState(() => initialFilters && Array.isArray(initialFilters.conditions) @@ -3340,8 +3356,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, @@ -6787,10 +6801,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, @@ -6866,9 +6876,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 = (
@@ -6939,7 +6949,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 @@ -7141,54 +7220,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 && ( @@ -7239,55 +7273,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) && (
@@ -7411,79 +7396,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} - recordOpen={recordOpen} - 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 && ( @@ -7613,129 +7525,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 && ( @@ -7751,18 +7540,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 @@ -7784,6 +7709,19 @@ export const ListView = React.forwardRef(({ shownFields={shownFieldNames} renderAdvanced={advancedFilterBuilder} onReset={conditionsDifferFromView ? handleResetConditions : undefined} + end={conditionRowEnd} + filterOffered={toolbarFlags.showFilters} + renderSortPanel={toolbarFlags.showSort ? (close) => ( + sortPanelBody} + /> + ) : undefined} />
)} diff --git a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx index e13bcf812aa..fd4fe6a270a 100644 --- a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx +++ b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx @@ -1,26 +1,24 @@ /** - * 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: how a record opens, row numbers, inline edit. - * - * 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 * reader's preference. The wide toolbar form (`compactToolbar: false`) keeps * one button per control in ListView.tsx; content is duplicated between the - * two forms, so change one, change both. Open records is drawn here only. + * two forms, so change one, change both. * * @module */ @@ -39,9 +37,6 @@ import { SelectItem, SelectTrigger, SelectValue, - Switch, - ToggleGroup, - ToggleGroupItem, } from '@object-ui/components'; import { SlidersHorizontal, @@ -51,7 +46,8 @@ import { Check, ChevronLeft, ChevronRight, - RotateCw, + ChevronDown, + Plus, Download, Loader2, Undo2, @@ -214,26 +210,6 @@ export interface ViewSettingsPopoverProps { */ layout?: (closeMenu: () => void) => React.ReactNode; - /** - * The Open records section (objectstack#26681), drawn after Layout. A host - * prop: the console passes it; any other host draws no section. It is not a - * setting of the view, so it neither counts in `changedCount` nor returns - * under Reset. - * - * Drawn in this panel only: no host that passes it draws the wide toolbar - * (`compactToolbar: false`), so the wide form has no twin of it. - */ - recordOpen?: ViewSettingsRecordOpen; - - /** - * 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; @@ -258,16 +234,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 @@ -289,10 +255,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; @@ -301,7 +263,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 @@ -427,93 +389,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 = ( - - {recordOpen && } - {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 ( @@ -963,14 +904,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 058c54b2b97..499ce3aa6ec 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,14 +50,12 @@ import { chipsAreIndependent, defaultQuickOperator, isValuelessOperator, - moveSortItem, newConditionId, quickFilterFamily, readViewConditions, removeCondition, seedValueFor, sortWording, - toggleSortOrder, upsertCondition, type ConditionField, type ViewConditionChip, @@ -480,12 +478,30 @@ 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'; +/** 「Sort」, 「Filter」 and 「+」 before anything is set: dashed, so they do not read as a condition in force. */ +const EMPTY_BUTTON_CLASS = + '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, @@ -500,11 +516,13 @@ export function ConditionChipRow({ renderAdvanced, 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'); @@ -519,13 +537,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} @@ -547,72 +565,48 @@ 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} - > - - - - ); - })} + {/* 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. Either opens the sort panel. */} + {renderSortPanel && ( + setOpenChip(open ? 'sort' : null)}> + + {sort.length > 0 ? ( + + ) : ( + + )} + + + {renderSortPanel(() => setOpenChip(null))} + + + )} {viewChips.map((chip) => { const text = viewChipText(chip, filterFields, t, nameOf); @@ -684,21 +678,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 && (
); } diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 24cec1e9f99..f7a5a70314f 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -1101,6 +1101,8 @@ const ar = { rowHeightSpacious: 'واسع', more: 'المزيد', restoreDefaults: 'استعادة الافتراضي', + shownColumns: 'الأعمدة المعروضة', + addColumn: 'إضافة عمود', recordOpenAlwaysPage: 'تُفتح السجلات دائمًا في صفحة كاملة', }, }, diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 21c4c8e8fa1..72ed99377ab 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -980,6 +980,8 @@ const de = { rowHeightSpacious: 'Großzügig', more: 'Mehr', restoreDefaults: 'Standard wiederherstellen', + shownColumns: 'Angezeigte Spalten', + addColumn: 'Spalte hinzufügen', recordOpenAlwaysPage: 'Datensätze öffnen sich immer als ganze Seite', }, }, diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index d1de2888807..43bd99966f2 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -1269,6 +1269,8 @@ const en = { rowHeightSpacious: 'Spacious', more: 'More', restoreDefaults: 'Restore defaults', + shownColumns: 'Shown columns', + addColumn: 'Add column', recordOpenAlwaysPage: 'Records always open as a full page', }, }, diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 01424689984..62136fa437b 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -1013,6 +1013,8 @@ const es = { rowHeightSpacious: 'Amplio', more: 'Más', restoreDefaults: 'Restaurar valores predeterminados', + shownColumns: 'Columnas mostradas', + addColumn: 'Añadir columna', recordOpenAlwaysPage: 'Los registros siempre se abren a página completa', }, }, diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 7dd961da1a0..769d85b2d82 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -1008,6 +1008,8 @@ const fr = { rowHeightSpacious: 'Spacieuse', more: 'Plus', restoreDefaults: 'Rétablir les valeurs par défaut', + shownColumns: 'Colonnes affichées', + addColumn: 'Ajouter une colonne', recordOpenAlwaysPage: 'Les enregistrements s’ouvrent toujours en pleine page', }, }, diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 17d8bd7d9c9..e05146f5976 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -980,6 +980,8 @@ const ja = { rowHeightSpacious: 'ゆったり', more: 'その他', restoreDefaults: 'デフォルトに戻す', + shownColumns: '表示中の列', + addColumn: '列を追加', recordOpenAlwaysPage: 'レコードは常にページ全体で開きます', }, }, diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index e247c8fa5a8..18e1914f1c3 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -980,6 +980,8 @@ const ko = { rowHeightSpacious: '넓게', more: '더 보기', restoreDefaults: '기본값 복원', + shownColumns: '표시된 열', + addColumn: '열 추가', recordOpenAlwaysPage: '레코드는 항상 전체 페이지로 열립니다', }, }, diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 9a866fbe261..413c94326ae 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -1008,6 +1008,8 @@ const pt = { rowHeightSpacious: 'Espaçosa', more: 'Mais', restoreDefaults: 'Restaurar padrões', + shownColumns: 'Colunas exibidas', + addColumn: 'Adicionar coluna', recordOpenAlwaysPage: 'Os registros sempre abrem em página inteira', }, }, diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index f61bb1b04e5..6cbeb76cb83 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -1042,6 +1042,8 @@ const ru = { rowHeightSpacious: 'Просторная', more: 'Ещё', restoreDefaults: 'Восстановить по умолчанию', + shownColumns: 'Показанные столбцы', + addColumn: 'Добавить столбец', recordOpenAlwaysPage: 'Записи всегда открываются на всю страницу', }, }, diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index cb56ad206bd..217e2547b94 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -1007,6 +1007,8 @@ const zh = { rowHeightSpacious: '宽松', more: '更多', restoreDefaults: '恢复默认', + shownColumns: '显示的列', + addColumn: '添加列', recordOpenAlwaysPage: '记录总是整页打开', }, }, diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 0a285e8de0f..45d0a3cea5d 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -1007,6 +1007,8 @@ const zhHant = { rowHeightSpacious: '寬鬆', more: '更多', restoreDefaults: '恢復預設', + shownColumns: '顯示的列', + addColumn: '新增列', recordOpenAlwaysPage: '記錄總是整頁開啟', }, }, 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 fe2cc016833..179fbd8b1ce 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 @@ -16,7 +16,7 @@ * `ListView` hands the controls and what it does with what they hand back. */ import { describe, it, expect, vi, afterEach } from 'vitest'; -import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; import '@testing-library/jest-dom'; import React from 'react'; import type { DataSource, ListViewSchema } from '@object-ui/types'; @@ -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,25 +97,4 @@ 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 () => { - const onFilterChange = vi.fn(); - const onSortChange = vi.fn(); - const ds = mount( - { sort: [{ field: 'name', order: 'asc' }] }, - { - onFilterChange, - onSortChange, - initialFilters: { id: 'root', logic: 'and', conditions: [{ id: 'c1', field: 'name', operator: 'contains', value: 'a' }] }, - }, - ); - await waitFor(() => expect(ds.getObjectSchema).toHaveBeenCalled()); - fireEvent.click(await within(slot()).findByTestId('sort-chip-toggle-name')); - await waitFor(() => expect(onSortChange.mock.calls.at(-1)?.[0]?.[0]?.order).toBe('desc')); - const reset = within(slot()).getByTestId('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']]); - 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..a497dbcef4d 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 @@ -219,8 +219,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 +261,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 +278,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 +304,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,12 +378,12 @@ 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)', 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..e8be064a96f 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([ @@ -2246,7 +2248,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 +2284,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.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__/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..d3b5f168a4c 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 @@ -88,22 +88,20 @@ describe('ViewSettingsPopover — every export entry stays inside the panel (obj 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() }); - 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 3baef0e0b57..994f4900fbf 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 @@ -89,10 +89,12 @@ describe('Options menu — the first level', () => { 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 +222,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 +237,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 +249,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 +260,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(); @@ -296,27 +298,10 @@ 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('speaks no developer wording on the Open records level', () => { - openMenu({ recordOpen: { resolvedMode: 'drawer', preference: 'drawer', setPreference: () => {} } }, 'zh'); - fireEvent.click(screen.getByTestId('options-row-more')); - const text = screen.getByTestId('view-settings-content').textContent ?? ''; - // The note the menu dropped (its key is gone from every pack). - expect(text).not.toContain('个人偏好'); - expect(text).not.toContain('对象声明'); - cleanup(); - openMenu({ recordOpen: { resolvedMode: 'page', preference: 'drawer', setPreference: () => {} } }, 'zh'); - fireEvent.click(screen.getByTestId('options-row-more')); - expect(screen.getByTestId('display-record-open-declared').textContent).toBe(zhPack.list.optionsMenu.recordOpenAlwaysPage); - expect(screen.getByTestId('view-settings-content').textContent).not.toContain('对象声明'); - }); it('every new key is in the en pack', () => { expect(Object.keys(en.list.optionsMenu).sort()).toEqual(Object.keys(zhPack.list.optionsMenu).sort()); diff --git a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx deleted file mode 100644 index 8dbc16e4c96..00000000000 --- a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx +++ /dev/null @@ -1,143 +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. - */ - -/** - * objectstack#26681 — the Display menu's Open records section. - * - * How a drawer-mode record opens is each reader's own choice (maintainer - * ruling 2026-10-27, objectstack#26677), so the section answers by the mode - * the host resolved for the object and view: - * - * - `drawer`: two segments, Drawer | Full page — the split pane retired - * (objectstack#28915, 「默认改抽屉,分屏彻底退役,只留抽屉和整页」) — each - * writing the reader's preference through the host's setter; the note - * that the choice is the reader's own retired with the Options menu - * (objectstack#35551: no developer wording in the menu); - * - `page`: one read-only line — the declaration wins, nothing to choose; - * - `new_window` / `none`, or no `recordOpen` at all: no section. - * - * The read-only line is read against the packs, not spelled here: what is - * pinned is which line is drawn, not its wording. Rendered in - * zh-CN as well, the language the ruling was given in. - */ -import { describe, it, expect, vi, afterEach } from 'vitest'; -import { render, screen, fireEvent, cleanup } from '@testing-library/react'; -import { I18nProvider, useObjectTranslation } from '@object-ui/i18n'; -import { en, zh as zhPack } from '@object-ui/i18n/locales'; -import { ViewSettingsPopover, type ViewSettingsRecordOpen } from '../components/ViewSettingsPopover'; - -afterEach(cleanup); - -function Harness({ recordOpen }: { recordOpen?: ViewSettingsRecordOpen }) { - const { t } = useObjectTranslation(); - return ( - string} - allFields={[{ name: 'name', label: 'Name' }]} - recordOpen={recordOpen} - onRefresh={() => {}} - /> - ); -} - -function openDisplay(recordOpen: ViewSettingsRecordOpen | undefined, language = 'en') { - render( - - - , - ); - fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - // Open records lives on the Options menu's More level (objectstack#35551). - const more = screen.queryByTestId('options-row-more'); - if (more) fireEvent.click(more); -} - -const drawer = (preference: 'drawer' | 'page', setPreference = vi.fn()): ViewSettingsRecordOpen => ({ - resolvedMode: 'drawer', - preference, - setPreference, -}); - -describe('ViewSettingsPopover — Open records (objectstack#26681)', () => { - it('objectstack#28915 — a drawer object: two segments, Drawer then Full page, the reader\'s choice pressed, and the note', async () => { - openDisplay(drawer('drawer')); - const section = await screen.findByTestId('display-record-open'); - expect(section.textContent).toContain('Open records'); - const group = screen.getByRole('radiogroup', { name: 'Open records' }); - expect(group).toBeTruthy(); - expect(Array.from(group.querySelectorAll('[role="radio"]')).map((radio) => radio.textContent)).toEqual([ - 'Drawer', - 'Full page', - ]); - expect(screen.queryByRole('radio', { name: 'Split' })).toBeNull(); - expect(screen.queryByTestId('display-record-open-split')).toBeNull(); - expect(screen.getByRole('radio', { name: 'Drawer' }).getAttribute('aria-checked')).toBe('true'); - expect(screen.getByRole('radio', { name: 'Full page' }).getAttribute('aria-checked')).toBe('false'); - expect(screen.queryByTestId('display-record-open-note')).toBeNull(); - expect(screen.queryByTestId('display-record-open-declared')).toBeNull(); - }); - - it('choosing Full page hands `page` to the host; pressing the pressed segment writes nothing', async () => { - const setPreference = vi.fn(); - openDisplay(drawer('drawer', setPreference)); - fireEvent.click(await screen.findByRole('radio', { name: 'Drawer' })); - expect(setPreference).not.toHaveBeenCalled(); - fireEvent.click(screen.getByRole('radio', { name: 'Full page' })); - expect(setPreference).toHaveBeenCalledTimes(1); - expect(setPreference).toHaveBeenCalledWith('page'); - }); - - it('a reader who prefers the full page sees Full page pressed, and can go back to Drawer', async () => { - const setPreference = vi.fn(); - openDisplay(drawer('page', setPreference)); - expect((await screen.findByRole('radio', { name: 'Full page' })).getAttribute('aria-checked')).toBe('true'); - fireEvent.click(screen.getByRole('radio', { name: 'Full page' })); - expect(setPreference).not.toHaveBeenCalled(); - fireEvent.click(screen.getByRole('radio', { name: 'Drawer' })); - expect(setPreference).toHaveBeenCalledWith('drawer'); - }); - - it('objectstack#28915 — the packs carry no split label any more', () => { - expect('recordOpenSplit' in en.list).toBe(false); - expect('recordOpenSplit' in zhPack.list).toBe(false); - }); - - it('a `page` object: the read-only line, no segments, no note', async () => { - openDisplay({ resolvedMode: 'page', preference: 'drawer', setPreference: vi.fn() }); - expect((await screen.findByTestId('display-record-open-declared')).textContent).toBe( - en.list.optionsMenu.recordOpenAlwaysPage, - ); - expect(screen.queryByRole('radio')).toBeNull(); - expect(screen.queryByTestId('display-record-open-note')).toBeNull(); - }); - - it.each(['new_window', 'none'] as const)('a `%s` object: no section', async (resolvedMode) => { - openDisplay({ resolvedMode, preference: 'drawer', setPreference: vi.fn() }); - await screen.findByTestId('view-settings-content'); - expect(screen.queryByTestId('display-record-open')).toBeNull(); - }); - - it('a host that passes no `recordOpen`: no section', async () => { - openDisplay(undefined); - await screen.findByTestId('view-settings-content'); - expect(screen.queryByTestId('display-record-open')).toBeNull(); - }); - - it('zh-CN: the section reads the zh pack', async () => { - const zh = zhPack.list; - openDisplay(drawer('drawer'), 'zh'); - // The zh pack loads on demand: wait for its words, not for the section. - expect(await screen.findByRole('radio', { name: zh.recordOpenDrawer })).toBeTruthy(); - expect(screen.getByRole('radio', { name: zh.recordOpenPage })).toBeTruthy(); - expect(screen.getByTestId('display-record-open').textContent).toContain(zh.recordOpen); - expect(screen.queryByTestId('display-record-open-note')).toBeNull(); - cleanup(); - openDisplay({ resolvedMode: 'page', preference: 'drawer', setPreference: vi.fn() }, 'zh'); - expect((await screen.findByText(zh.optionsMenu.recordOpenAlwaysPage)).getAttribute('data-testid')).toBe('display-record-open-declared'); - }); -}); diff --git a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx index 499ce3aa6ec..19d600a9ffa 100644 --- a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx +++ b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx @@ -455,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; @@ -498,14 +502,20 @@ export interface ConditionChipRowProps { 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 = - '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'; + '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, @@ -555,7 +565,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}`} /> @@ -579,8 +591,8 @@ export function ConditionChipRow({ {sort.length > 0 ? ( ) : ( - @@ -684,7 +696,7 @@ export function ConditionChipRow({ {filterOffered && filterPopover( 'add', appliedRows.length === 0 ? ( - diff --git a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx index 4ff48de8f93..64c9a9fcf86 100644 --- a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx +++ b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx @@ -24,7 +24,6 @@ import { ConditionChipRow, FilterPanel, SortPanel, describeConditionValue, sortD import { addSortLevel, chipsAreIndependent, - moveSortItem, quickFilterFamily, readViewConditions, type ConditionField, @@ -463,11 +462,6 @@ describe('ConditionChipRow — the row under the view bar', () => { ); } - it('CONTROL: draws nothing at all with no sort, no view condition and no filter', () => { - const { container } = render(
{}} />
); - expect(screen.getByTestId('slot').childElementCount).toBe(0); - expect(container.textContent).toBe(''); - }); it('a filter chip names the field and its values; × removes it', () => { const onFiltersChange = vi.fn(); @@ -503,37 +497,7 @@ describe('ConditionChipRow — the row under the view bar', () => { expect(chips[2].textContent).toContain(' or '); }); - it('sort chips come before filter chips, name field and direction, and flip on click', () => { - const onSortChange = vi.fn(); - render(); - const row = screen.getByTestId('condition-chips'); - const order = Array.from(row.querySelectorAll('[data-testid^="sort-chip-"], [data-testid^="filter-chip-"]')) - .map((el) => el.getAttribute('data-testid')) - .filter((id) => id === 'sort-chip-amount' || id === 'filter-chip-stage'); - expect(order).toEqual(['sort-chip-amount', 'filter-chip-stage']); - const toggle = screen.getByTestId('sort-chip-toggle-amount'); - expect(toggle.textContent).toBe('Amount'); - expect(toggle.getAttribute('title')).toBe('Low → High'); - fireEvent.click(toggle); - expect(onSortChange).toHaveBeenCalledWith([{ id: 's1', field: 'amount', order: 'desc' }]); - }); - - it('two sort levels: dragging the second chip onto the first changes the priority', () => { - const onSortChange = vi.fn(); - const sort: SortItem[] = [ - { id: 's1', field: 'stage', order: 'asc' }, - { id: 's2', field: 'amount', order: 'desc' }, - ]; - render(); - const first = screen.getByTestId('sort-chip-stage'); - const second = screen.getByTestId('sort-chip-amount'); - expect(second.getAttribute('draggable')).toBe('true'); - fireEvent.dragStart(second); - fireEvent.dragOver(first); - fireEvent.drop(first); - expect(onSortChange.mock.calls[0][0].map((s: SortItem) => s.field)).toEqual(['amount', 'stage']); - expect(moveSortItem(sort, 0, 1).map((s) => s.field)).toEqual(['amount', 'stage']); - }); + it('「Reset」 calls the host, and is not drawn at all while the host passes none (objectstack#35727)', () => { const onReset = vi.fn(); @@ -567,10 +531,6 @@ describe('ConditionChipRow — the row under the view bar', () => { expect(screen.getAllByTestId('view-condition-chip').map((c) => c.getAttribute('data-field'))).toEqual(['account', 'amount']); }); - it('when every view condition is the host\'s and the reader has none, the row draws nothing', () => { - render(
); - expect(screen.getByTestId('slot').childElementCount).toBe(0); - }); it('a locked lookup chip names the record it points at, read through the data source', async () => { const ds = lookupSource(async () => ({ data: [{ id: 'a1', title: 'Globex' }] })); @@ -621,14 +581,6 @@ describe('ConditionChipRow — the row under the view bar', () => { expect(screen.getByTestId('advanced-builder')).toBeTruthy(); }); - it('an unfinished row draws no chip', () => { - const { container } = render( -
- -
, - ); - expect(container.querySelector('[data-testid="condition-chips"]')).toBeNull(); - }); }); describe('condition model', () => { @@ -658,3 +610,91 @@ describe('condition model', () => { expect(describeConditionValue(STAGE, 'is_empty', undefined, t as never)).toBe('is empty'); }); }); + +describe('ConditionChipRow — the resident row of the two-row toolbar (objectstack#35878)', () => { + const sortPanel = (close: () => void) => ( + + ); + function TwoRow(props: Partial>) { + return ( + {}} + filters={EMPTY} + filterFields={FIELDS} + onFiltersChange={() => {}} + renderAdvanced={() =>
} + 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」, and it opens the sort panel', () => { + const sort: SortItem[] = [ + { id: 's1', field: 'amount', order: 'desc' }, + { id: 's2', field: 'name', order: 'asc' }, + { id: 's3', field: 'stage', order: 'asc' }, + ]; + 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'); + fireEvent.click(chips[0]); + expect(screen.getByTestId('sort-panel-stand-in')).toBeInTheDocument(); + // The panel's close closes the popover. + 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'])); + }); +}); From 53a7404c1fb339a146cc0896581f489005127129 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 18:54:56 +0000 Subject: [PATCH 4/6] test(list): drop the retired View settings props from two panel tests Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgXbiCh84nxg4WvGahS --- .../ViewSettingsPopover.exportFooter-29175.test.tsx | 4 +--- .../__tests__/ViewSettingsPopover.optionsMenu-35551.test.tsx | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) 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 d3b5f168a4c..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,7 +80,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: vi.fn(), }); @@ -100,7 +98,7 @@ describe('ViewSettingsPopover — every export entry stays inside the panel (obj }); 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).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 994f4900fbf..f409b431b4f 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,8 +85,6 @@ 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'); // objectstack#35878: the shown columns are in place on this level. @@ -286,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'))) { From c8030bbf6ad7fe41bbdfadeb45e807a418652c0a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 19:33:15 +0000 Subject: [PATCH 5/6] test(list): migrate the list e2e specs and checklist clauses to the two-row bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - list-condition-row-35549: one resident Sort chip with a level count, 40 px row - list-toolbar-view-name-phone: read the 视图设置 trigger from ViewSettingsPopover - list-frame-geometry-35548 / list-left-edge-35663: no page bar; the view bar carries the object name, icon and the page actions - view bar: object icon and ⋮ sit 16 px from the column edge (sm:pl-1.5 / sm:pr-0.5) - records-forms checklist: list-view-capabilities rev 13, bulk-select-all-matching rev 11 Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgXbiCh84nxg4WvGahS --- .../areas/records-forms.json | 30 ++++---- ui/e2e/list-condition-row-35549.spec.ts | 68 ++++++++++------- ui/e2e/list-frame-geometry-35548.spec.ts | 76 +++++++++++-------- ui/e2e/list-left-edge-35663.spec.ts | 71 ++++++++++------- ui/e2e/list-toolbar-view-name-phone.spec.ts | 14 ++-- ...ectView.headerSelectionGate-27831.test.tsx | 3 + .../src/views/objectViewPageHeader.tsx | 19 ++++- 7 files changed, 169 insertions(+), 112 deletions(-) diff --git a/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index 29804880369..78a868fc3e5 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" } ] }, { @@ -3825,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": [ @@ -3844,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", @@ -3854,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" @@ -3968,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 f80b4ab6862..386b44e3385 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`. @@ -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 count bar reads, once the list has answered. */ const count = async (page: Page) => (await page.getByTestId('record-count-bar').textContent())?.match(/\d+/)?.[0]; @@ -279,12 +281,18 @@ 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 }) => { @@ -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,10 +321,15 @@ 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 header click 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; it opens the sort panel, where the + // levels are ordered (the per-level chips and their drag are gone). + test('sort: Sort → Descending → Amount is three clicks; one chip with +N comes before the filter chips; a header click shows on it; Reset restores', async ({ page }) => { test.setTimeout(120_000); await mount(page); await expect.poll(() => count(page)).toBe('12'); @@ -326,23 +337,26 @@ test.describe('list condition row under the view bar (objectstack#35549, objects 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-toggle-amount')).toHaveText('Amount'); - await expect(page.getByTestId('sort-chip-toggle-amount')).toHaveAttribute('title', 'High → Low'); - // a second level + const sortChip = page.getByTestId('condition-sort'); + await expect(sortChip).toHaveAttribute('data-levels', '1'); + await expect(sortChip).toHaveText('Sorted by Amount'); + // a second level: still one chip, now carrying +1 await click(page, 'condition-sort'); 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 expect(sortChip).toHaveAttribute('data-levels', '2'); + await expect(page.getByTestId('sort-chip-more')).toHaveText('+1'); + // 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,18 +365,16 @@ 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']); - // 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); - // a click on a column header sorts, and the row shows it as a chip + expect(Math.round(await slotHeight(page))).toBe(ROW_HEIGHT); + await expect(sortChip).toHaveAttribute('data-levels', '0'); + // a click on a column header sorts, and the row shows it on the one chip await page.getByRole('columnheader', { name: /Amount/ }).click(); await style(page); - await expect(page.getByTestId('sort-chip-amount')).toBeVisible(); + await expect(sortChip).toHaveText(/^Sorted by Amount/); expect((await sortNow(page))[0]).toMatch(/^amount:/); }); }); 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 64a841e849c..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="condition-add-filter"/.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/ObjectView.headerSelectionGate-27831.test.tsx b/ui/packages/app-shell/src/views/ObjectView.headerSelectionGate-27831.test.tsx index abe9c840efb..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'; diff --git a/ui/packages/app-shell/src/views/objectViewPageHeader.tsx b/ui/packages/app-shell/src/views/objectViewPageHeader.tsx index f69df78b20d..f7ced1166ca 100644 --- a/ui/packages/app-shell/src/views/objectViewPageHeader.tsx +++ b/ui/packages/app-shell/src/views/objectViewPageHeader.tsx @@ -14,6 +14,7 @@ import { createContext, createElement, useCallback, useContext, useLayoutEffect, import type { Dispatch, ReactNode, SetStateAction } from 'react'; import { Button, + cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, @@ -229,6 +230,20 @@ export const ListViewBarHostContext = createContext<((hosted: boolean) => void) /** 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 @@ -239,7 +254,7 @@ export function ObjectViewBarObjectName({ objectPluralLabel, }: Pick) { return ( - + @@ -278,7 +293,7 @@ export function ObjectViewBarTrailing({ tools, ...props }: ObjectViewPageBarProp return (
{/* Always mounted, so the slot is there the moment a row is ticked. */} From 03e1946ea29e26d9cb0f07560a739834a4421216 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 19:44:58 +0000 Subject: [PATCH 6/6] fix(list): keep the Open records section, last on the View settings first level The More level it sat on is gone with the two-row toolbar; the section moves up instead of going away, so a reader keeps the choice until the record-open preference itself is retired. Docs and tests as main has them, the tests opening the panel's first level. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgXbiCh84nxg4WvGahS --- .changeset/35878-list-toolbar-two-rows.md | 4 +- content/docs/ui/views.mdx | 10 +- ...bjectView.recordOpenDisplay-26681.test.tsx | 90 ++++++++--- ui/packages/plugin-list/src/ListView.tsx | 9 +- ...SettingsPopover.optionsMenu-35551.test.tsx | 12 ++ ...wSettingsPopover.recordOpen-26681.test.tsx | 141 ++++++++++++++++++ .../src/components/ViewSettingsPopover.tsx | 73 +++++++++ 7 files changed, 306 insertions(+), 33 deletions(-) create mode 100644 ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx diff --git a/.changeset/35878-list-toolbar-two-rows.md b/.changeset/35878-list-toolbar-two-rows.md index dddf57621cf..5d77fe2da23 100644 --- a/.changeset/35878-list-toolbar-two-rows.md +++ b/.changeset/35878-list-toolbar-two-rows.md @@ -13,7 +13,7 @@ The console's object list drew three rows above the table: the object's name wit - 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 (how records open, inline edit) and Refresh are gone. +- 「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, then Open records where the host offers it, and Save, Restore defaults and export in its footer. The More level and its inline edit switch, and Refresh, are gone; Open records moved up to the first level. - 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. The `recordOpen` prop is accepted but no longer drawn: the panel has no More level. +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. The `recordOpen` prop still draws the Open records section, now last on the panel's first level. diff --git a/content/docs/ui/views.mdx b/content/docs/ui/views.mdx index 024149a1077..9fb4b78289a 100644 --- a/content/docs/ui/views.mdx +++ b/content/docs/ui/views.mdx @@ -594,11 +594,11 @@ from. `modal`, `split` and `popover` were removed in @objectstack/spec 18.3.0 (A a stored value is refused with its fix, and `os migrate meta --from 17` drops it. On a phone every record opens as a page, whatever the view declares. -Whether a row opens the drawer or the full page is the reader's, not the view's. **Drawer** -(the default) draws the record over the list, which keeps its full width, and **Full page** -navigates. A choice made earlier is kept in the browser for every drawer-mode object; the -list's **View settings** panel no longer offers it, and it does not apply to an object declared -to open as a page. A record's **↗** always opens the full page. The reader also drags the drawer's edge, +Whether a row opens the drawer or the full page is the reader's choice, not the view's. The +list's **Display** menu offers **Open records**: **Drawer** (the default) draws the record over +the list, which keeps its full width, and **Full page** navigates. The choice is kept in the +browser for every drawer-mode object, and is not offered for an object declared to open as a +page; a record's **↗** always opens the full page. The reader also drags the drawer's edge, **⤢** maximizes it in place, **Open as full page** leaves the drawer, and **Collapse to drawer** returns to the stack it left. The `size` bucket on `navigation` sets only the drawer's starting width; `width` is deprecated. diff --git a/ui/packages/app-shell/src/views/ObjectView.recordOpenDisplay-26681.test.tsx b/ui/packages/app-shell/src/views/ObjectView.recordOpenDisplay-26681.test.tsx index dbd7eb46155..eb973444925 100644 --- a/ui/packages/app-shell/src/views/ObjectView.recordOpenDisplay-26681.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.recordOpenDisplay-26681.test.tsx @@ -7,19 +7,21 @@ */ /** - * objectstack#26681 — opening a record from the console list, and the name - * cell's ↗ that opens it as the full page. + * objectstack#26681 — the console object page's Display menu writes the + * reader's record-open preference, and the name cell's ↗ opens the record as + * the full page. * * End to end through `ObjectView`, the host that resolves the mode and keeps * the preference (`utils/recordOpenPreference.ts`): * - * - a drawer object with no choice made, or a stored `split` - * (objectstack#28915: the split pane retired): the row opens the drawer; - * - the list toolbar draws no Open records section since objectstack#35878 - * (its 视图设置 panel has no More level; objectstack#35854 retires the - * preference itself), so the cases that chose Drawer / Full page there - * are void; - * - a view that declares `page`: no ↗ (its rows already open the page); + * - a drawer object: the Open records section draws Drawer | Full page + * only (objectstack#28915: the split pane retired); with no choice made + * the row opens the drawer over the list, choosing Full page keeps `page` + * under `os:record-open-mode` and makes the next row click land on the + * record page, and choosing Drawer again keeps `drawer` — no reload, no + * remount; + * - a view that declares `page`: the read-only line, no segments, and no ↗ + * (its rows already open the page); * - the ↗ beside a drawer row's record link is a real anchor to the record route, * and a plain click on it lands there, leaving the preference as it was. * @@ -32,7 +34,7 @@ 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 } from '@testing-library/react'; +import { render, cleanup, screen, fireEvent, waitFor, within } from '@testing-library/react'; import { MemoryRouter, Routes, Route } from 'react-router-dom'; import { createI18n, I18nProvider } from '@object-ui/i18n'; @@ -168,11 +170,26 @@ async function openList(objects: ReturnType) { await screen.findByTestId('primary-field-link', undefined, { timeout: 5000 }); } -// objectstack#35878: the list's 视图设置 panel has no More level, so it no -// longer draws the Open records section (the setting itself is retired by -// objectstack#35854). What stays pinned here is the host's reading of the -// stored preference and the ↗ anchor. -describe('objectstack#26681 — record open from the list', () => { +/** + * Open records is drawn last on the 视图设置 panel's first level + * (objectstack#35878 retired the More level it sat on). + */ +async function openDisplay() { + fireEvent.click(screen.getByTestId('toolbar-display-trigger')); + await screen.findByTestId('view-settings-content'); +} + +describe('objectstack#26681 — Open records in the Display menu', () => { + it('objectstack#28915 — a drawer object: the section offers Drawer and Full page only', async () => { + await openList(objectsWith()); + await openDisplay(); + const drawerSegment = await screen.findByRole('radio', { name: 'Drawer' }); + expect(drawerSegment.getAttribute('aria-checked')).toBe('true'); + const segments = within(screen.getByTestId('display-record-open')).getAllByRole('radio'); + expect(segments.map((el) => el.textContent)).toEqual(['Drawer', 'Full page']); + expect(screen.queryByRole('radio', { name: 'Split' })).toBeNull(); + }); + it('objectstack#28915 — a drawer object with no choice made: the row opens the drawer over the list', async () => { await openList(objectsWith()); fireEvent.click(screen.getByTestId('primary-field-link')); @@ -181,25 +198,54 @@ describe('objectstack#26681 — record open from the list', () => { expect(screen.queryByTestId('record-count-footer')).toBeNull(); }); - it('objectstack#28915 — a stored `split`: the row opens the drawer', async () => { + it('objectstack#28915 — a stored `split`: the section reads Drawer, and the row opens the drawer', async () => { window.localStorage.setItem(RECORD_OPEN_PREFERENCE_KEY, 'split'); await openList(objectsWith()); + await openDisplay(); + expect((await screen.findByRole('radio', { name: 'Drawer' })).getAttribute('aria-checked')).toBe('true'); + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); + fireEvent.click(screen.getByTestId('primary-field-link')); + expect(await screen.findByRole('dialog', undefined, { timeout: 5000 })).toBeTruthy(); + }); + + it('a reader who prefers the page chooses Drawer: the preference is kept, and the next row click opens the drawer', async () => { + window.localStorage.setItem(RECORD_OPEN_PREFERENCE_KEY, 'page'); + await openList(objectsWith()); + await openDisplay(); + const pageSegment = await screen.findByRole('radio', { name: 'Full page' }); + expect(pageSegment.getAttribute('aria-checked')).toBe('true'); + fireEvent.click(screen.getByRole('radio', { name: 'Drawer' })); + + expect(window.localStorage.getItem(RECORD_OPEN_PREFERENCE_KEY)).toBe('drawer'); + // The section reads the live value back: no reload, no remount. + await waitFor(() => + expect(screen.getByRole('radio', { name: 'Drawer' }).getAttribute('aria-checked')).toBe('true'), + ); + + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); fireEvent.click(screen.getByTestId('primary-field-link')); expect(await screen.findByRole('dialog', undefined, { timeout: 5000 })).toBeTruthy(); + expect(screen.queryByTestId('record-page-route')).toBeNull(); }); - it('the list toolbar offers no Open records section', async () => { + it('objectstack#27545 — choosing Full page: the next row click lands on the record page', async () => { await openList(objectsWith()); - fireEvent.click(screen.getByTestId('toolbar-display-trigger')); - await screen.findByTestId('view-settings-content'); - expect(screen.queryByTestId('options-row-more')).toBeNull(); - expect(screen.queryByTestId('display-record-open')).toBeNull(); + await openDisplay(); + fireEvent.click(await screen.findByRole('radio', { name: 'Full page' })); + expect(window.localStorage.getItem(RECORD_OPEN_PREFERENCE_KEY)).toBe('page'); + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); + fireEvent.click(screen.getByTestId('primary-field-link')); + expect(await screen.findByTestId('record-page-route', undefined, { timeout: 5000 })).toBeTruthy(); + expect(screen.queryByRole('dialog')).toBeNull(); }); - it('a view that declares `page`: no ↗', async () => { + it('a view that declares `page`: the read-only line, no segments, and no ↗', async () => { window.localStorage.setItem(RECORD_OPEN_PREFERENCE_KEY, 'drawer'); await openList(objectsWith({ mode: 'page' })); expect(screen.queryByTestId('record-open-as-page')).toBeNull(); + await openDisplay(); + expect(await screen.findByTestId('display-record-open-declared')).toBeTruthy(); + expect(within(screen.getByTestId('display-record-open')).queryByRole('radio')).toBeNull(); }); it('the ↗ beside a drawer row is an anchor to the record route, and a click lands there without changing the preference', async () => { diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index b433bdad3a9..51847e53b19 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -679,10 +679,9 @@ export interface ListViewProps { * * A HOST prop, never a schema key: the preference is the reader's, kept by * the host, and the setter is a function value no document can carry. - * - * Drawn nowhere since objectstack#35878: the 视图设置 panel has no More - * level. objectstack#35854 retires the preference itself and this prop with - * it; until then a host may still pass it, and it changes nothing. + * Absent ⇒ the panel draws no such section, exactly as before. Drawn last + * on the 视图设置 panel's first level since objectstack#35878 retired the + * More level; objectstack#35854 retires the preference and this prop. */ recordOpen?: ViewSettingsRecordOpen; /** @@ -2149,6 +2148,7 @@ export const ListView = React.forwardRef(({ onRenameView, onSaveView, onResetView, + recordOpen, page, onPageChange, hostDrawnConditionFields, @@ -7033,6 +7033,7 @@ export const ListView = React.forwardRef(({ }} /> ) : undefined} + recordOpen={recordOpen} showGroup={toolbarFlags.showGroup} groupingConfig={chosenGroupingConfig} setGroupingConfig={changeGrouping} 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 f409b431b4f..0eff79947b4 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 @@ -298,6 +298,18 @@ describe('Options menu — words', () => { }); + it('speaks no developer wording in the Open records section', () => { + openMenu({ recordOpen: { resolvedMode: 'drawer', preference: 'drawer', setPreference: () => {} } }, 'zh'); + const text = screen.getByTestId('view-settings-content').textContent ?? ''; + // The note the menu dropped (its key is gone from every pack). + expect(text).not.toContain('个人偏好'); + expect(text).not.toContain('对象声明'); + cleanup(); + openMenu({ recordOpen: { resolvedMode: 'page', preference: 'drawer', setPreference: () => {} } }, 'zh'); + expect(screen.getByTestId('display-record-open-declared').textContent).toBe(zhPack.list.optionsMenu.recordOpenAlwaysPage); + expect(screen.getByTestId('view-settings-content').textContent).not.toContain('对象声明'); + }); + it('every new key is in the en pack', () => { expect(Object.keys(en.list.optionsMenu).sort()).toEqual(Object.keys(zhPack.list.optionsMenu).sort()); }); diff --git a/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx new file mode 100644 index 00000000000..1cd115b204c --- /dev/null +++ b/ui/packages/plugin-list/src/__tests__/ViewSettingsPopover.recordOpen-26681.test.tsx @@ -0,0 +1,141 @@ +/** + * 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. + */ + +/** + * objectstack#26681 — the Display menu's Open records section. + * + * How a drawer-mode record opens is each reader's own choice (maintainer + * ruling 2026-10-27, objectstack#26677), so the section answers by the mode + * the host resolved for the object and view: + * + * - `drawer`: two segments, Drawer | Full page — the split pane retired + * (objectstack#28915, 「默认改抽屉,分屏彻底退役,只留抽屉和整页」) — each + * writing the reader's preference through the host's setter; the note + * that the choice is the reader's own retired with the Options menu + * (objectstack#35551: no developer wording in the menu); + * - `page`: one read-only line — the declaration wins, nothing to choose; + * - `new_window` / `none`, or no `recordOpen` at all: no section. + * + * The read-only line is read against the packs, not spelled here: what is + * pinned is which line is drawn, not its wording. Rendered in + * zh-CN as well, the language the ruling was given in. + */ +import { describe, it, expect, vi, afterEach } from 'vitest'; +import { render, screen, fireEvent, cleanup } from '@testing-library/react'; +import { I18nProvider, useObjectTranslation } from '@object-ui/i18n'; +import { en, zh as zhPack } from '@object-ui/i18n/locales'; +import { ViewSettingsPopover, type ViewSettingsRecordOpen } from '../components/ViewSettingsPopover'; + +afterEach(cleanup); + +function Harness({ recordOpen }: { recordOpen?: ViewSettingsRecordOpen }) { + const { t } = useObjectTranslation(); + return ( + string} + allFields={[{ name: 'name', label: 'Name' }]} + recordOpen={recordOpen} + /> + ); +} + +function openDisplay(recordOpen: ViewSettingsRecordOpen | undefined, language = 'en') { + render( + + + , + ); + // Open records is drawn last on the 视图设置 panel's first level + // (objectstack#35878 retired the More level it sat on). + fireEvent.click(screen.getByTestId('toolbar-display-trigger')); +} + +const drawer = (preference: 'drawer' | 'page', setPreference = vi.fn()): ViewSettingsRecordOpen => ({ + resolvedMode: 'drawer', + preference, + setPreference, +}); + +describe('ViewSettingsPopover — Open records (objectstack#26681)', () => { + it('objectstack#28915 — a drawer object: two segments, Drawer then Full page, the reader\'s choice pressed, and the note', async () => { + openDisplay(drawer('drawer')); + const section = await screen.findByTestId('display-record-open'); + expect(section.textContent).toContain('Open records'); + const group = screen.getByRole('radiogroup', { name: 'Open records' }); + expect(group).toBeTruthy(); + expect(Array.from(group.querySelectorAll('[role="radio"]')).map((radio) => radio.textContent)).toEqual([ + 'Drawer', + 'Full page', + ]); + expect(screen.queryByRole('radio', { name: 'Split' })).toBeNull(); + expect(screen.queryByTestId('display-record-open-split')).toBeNull(); + expect(screen.getByRole('radio', { name: 'Drawer' }).getAttribute('aria-checked')).toBe('true'); + expect(screen.getByRole('radio', { name: 'Full page' }).getAttribute('aria-checked')).toBe('false'); + expect(screen.queryByTestId('display-record-open-note')).toBeNull(); + expect(screen.queryByTestId('display-record-open-declared')).toBeNull(); + }); + + it('choosing Full page hands `page` to the host; pressing the pressed segment writes nothing', async () => { + const setPreference = vi.fn(); + openDisplay(drawer('drawer', setPreference)); + fireEvent.click(await screen.findByRole('radio', { name: 'Drawer' })); + expect(setPreference).not.toHaveBeenCalled(); + fireEvent.click(screen.getByRole('radio', { name: 'Full page' })); + expect(setPreference).toHaveBeenCalledTimes(1); + expect(setPreference).toHaveBeenCalledWith('page'); + }); + + it('a reader who prefers the full page sees Full page pressed, and can go back to Drawer', async () => { + const setPreference = vi.fn(); + openDisplay(drawer('page', setPreference)); + expect((await screen.findByRole('radio', { name: 'Full page' })).getAttribute('aria-checked')).toBe('true'); + fireEvent.click(screen.getByRole('radio', { name: 'Full page' })); + expect(setPreference).not.toHaveBeenCalled(); + fireEvent.click(screen.getByRole('radio', { name: 'Drawer' })); + expect(setPreference).toHaveBeenCalledWith('drawer'); + }); + + it('objectstack#28915 — the packs carry no split label any more', () => { + expect('recordOpenSplit' in en.list).toBe(false); + expect('recordOpenSplit' in zhPack.list).toBe(false); + }); + + it('a `page` object: the read-only line, no segments, no note', async () => { + openDisplay({ resolvedMode: 'page', preference: 'drawer', setPreference: vi.fn() }); + expect((await screen.findByTestId('display-record-open-declared')).textContent).toBe( + en.list.optionsMenu.recordOpenAlwaysPage, + ); + expect(screen.queryByRole('radio')).toBeNull(); + expect(screen.queryByTestId('display-record-open-note')).toBeNull(); + }); + + it.each(['new_window', 'none'] as const)('a `%s` object: no section', async (resolvedMode) => { + openDisplay({ resolvedMode, preference: 'drawer', setPreference: vi.fn() }); + await screen.findByTestId('view-settings-content'); + expect(screen.queryByTestId('display-record-open')).toBeNull(); + }); + + it('a host that passes no `recordOpen`: no section', async () => { + openDisplay(undefined); + await screen.findByTestId('view-settings-content'); + expect(screen.queryByTestId('display-record-open')).toBeNull(); + }); + + it('zh-CN: the section reads the zh pack', async () => { + const zh = zhPack.list; + openDisplay(drawer('drawer'), 'zh'); + // The zh pack loads on demand: wait for its words, not for the section. + expect(await screen.findByRole('radio', { name: zh.recordOpenDrawer })).toBeTruthy(); + expect(screen.getByRole('radio', { name: zh.recordOpenPage })).toBeTruthy(); + expect(screen.getByTestId('display-record-open').textContent).toContain(zh.recordOpen); + expect(screen.queryByTestId('display-record-open-note')).toBeNull(); + cleanup(); + openDisplay({ resolvedMode: 'page', preference: 'drawer', setPreference: vi.fn() }, 'zh'); + expect((await screen.findByText(zh.optionsMenu.recordOpenAlwaysPage)).getAttribute('data-testid')).toBe('display-record-open-declared'); + }); +}); diff --git a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx index fd4fe6a270a..9b7dcc494da 100644 --- a/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx +++ b/ui/packages/plugin-list/src/components/ViewSettingsPopover.tsx @@ -37,6 +37,8 @@ import { SelectItem, SelectTrigger, SelectValue, + ToggleGroup, + ToggleGroupItem, } from '@object-ui/components'; import { SlidersHorizontal, @@ -210,6 +212,16 @@ export interface ViewSettingsPopoverProps { */ layout?: (closeMenu: () => void) => React.ReactNode; + /** + * The Open records section (objectstack#26681), drawn last on the panel's + * first level (objectstack#35878 retired the More level it sat on). A host + * prop: the console passes it; any other host draws no section. It is not a + * setting of the view, so it neither counts in `changedCount` nor returns + * under Reset. objectstack#35854 retires the preference and this section + * with it. + */ + recordOpen?: ViewSettingsRecordOpen; + showGroup?: boolean; groupingConfig?: any; setGroupingConfig?: (next: any) => void; @@ -526,6 +538,65 @@ function FieldsPage({ ); } +/** + * The Open records section — see {@link ViewSettingsRecordOpen}. `null` for a + * mode it draws nothing for. + */ +function RecordOpenSection({ + t, + recordOpen, +}: { + t: ViewSettingsPopoverProps['t']; + recordOpen: ViewSettingsRecordOpen; +}) { + const { resolvedMode, preference, setPreference } = recordOpen; + if (resolvedMode !== 'drawer' && resolvedMode !== 'page') return null; + const title = t('list.recordOpen', { defaultValue: 'Open records' }); + return ( +
+
+ {title} + {resolvedMode === 'drawer' ? ( + { + if (next === preference) return; + if (next === 'drawer' || next === 'page') setPreference(next); + }} + aria-label={title} + className="gap-0" + data-testid="display-record-open-choice" + > + + {t('list.recordOpenDrawer', { defaultValue: 'Drawer' })} + + + {t('list.recordOpenPage', { defaultValue: 'Full page' })} + + + ) : ( + + {t('list.optionsMenu.recordOpenAlwaysPage', { defaultValue: 'Records always open as a full page' })} + + )} +
+
+ ); +} + /** * The 视图设置 panel's content (objectstack#35878), apart from what holds it: * the desktop popover below is one container, and a phone's bottom sheet can @@ -542,6 +613,7 @@ export function ViewSettingsContent(props: ViewSettingsPopoverProps & { closeMen onFieldOrderChange, fieldType, layout, + recordOpen, showGroup, groupingConfig, setGroupingConfig, @@ -686,6 +758,7 @@ export function ViewSettingsContent(props: ViewSettingsPopoverProps & { closeMen /> )}
+ {recordOpen && }
);