From 812191823b36be5bea99a81cb3d4bdec49bfda74 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:21:04 +0000 Subject: [PATCH 1/5] feat(studio): records tab add field, header click selects, name column leads, field inspector order (WIP) Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../inspectors/ObjectFieldInspector.tsx | 189 +++++++++++++++--- .../studio-design/StudioDesignSurface.tsx | 84 ++++++-- .../studio-design/StudioGridAddField.tsx | 51 +++++ .../src/context/gridFieldAuthoring.tsx | 8 + .../src/renderers/complex/data-table.tsx | 27 +++ ui/packages/i18n/src/namespaces/studio/en.ts | 5 + ui/packages/i18n/src/namespaces/studio/zh.ts | 5 + 7 files changed, 330 insertions(+), 39 deletions(-) create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioGridAddField.tsx diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx index f18372c77b1..ec481896e89 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx @@ -82,12 +82,24 @@ import { InspectorNumberField, InspectorSelectField, InspectorCheckboxField, - InspectorRemoveButton, InspectorEmptyState, moveArray, } from './_shared.js'; import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, Button, + cn, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, Input, Label, Badge, @@ -101,7 +113,7 @@ import { TooltipProvider, TooltipTrigger, } from '@object-ui/components'; -import { Plus, X, ArrowUp, ArrowDown, Copy, AlertTriangle } from 'lucide-react'; +import { Plus, X, ArrowUp, ArrowDown, Copy, AlertTriangle, ChevronRight, MoreHorizontal, Trash2 } from 'lucide-react'; import { InspectorComboField, type InspectorComboOption } from './InspectorComboField.js'; import { ObjectPicker } from './ObjectPicker.js'; import { useObjectFields } from '../previews/useObjectFields.js'; @@ -1381,6 +1393,24 @@ export function ObjectFieldInspector({ /* ─── Render ─── */ + // objectstack#34794 — delete is in the header's ⋯ menu, confirmed first, + // not the panel's most prominent button. An external field offers none. + const removeLabel = typeof def.label === 'string' && def.label ? def.label : entry.name; + const moreMenu = external ? null : ( + + + + ); + const headerActions = (
{!ddlLocked && ( @@ -1405,21 +1435,10 @@ export function ObjectFieldInspector({ /> )} + {moreMenu}
); - const footer = external ? undefined : ( - - - - ); - const typeMetaLabel = typeMeta ? t(`engine.fieldType.${typeMeta.id}`, locale) : undefined; // objectui#11786 — read off the field as it stands, for the hints below. const heldNeed = locked ? null : guardHeldNeed(entry.name, def); @@ -1444,7 +1463,6 @@ export function ObjectFieldInspector({ onClose={onClearSelection} closeLabel={tr('designer.field.close')} headerActions={headerActions} - footer={footer} > {/* Basic */}
@@ -1462,16 +1480,8 @@ export function ObjectFieldInspector({ )} - - - + {/* objectstack#34794 — the label leads; the API name is in the + collapsed Developer info section below. */}
+ {/* objectstack#34794 — the field's API name: how the API and formulas + refer to it. Collapsed by default, since an everyday edit never + needs it; the rename, its checks and its hints are unchanged. */} + + + + + {/* Type-specific */} {(isPicklist(type) || isLookup(type) || offersReferenceNameVisible(type) || isComputed(type) || isNumeric(type) || isTexty(type) || offersValueDomain(type)) && ( @@ -1968,7 +1996,7 @@ export function ObjectFieldInspector({ ); - // The shell draws the header's reorder pair and the footer's Remove, so the + // The shell draws the header's reorder pair and the ⋯ menu's Remove, so the // reason their locks read is provided above it. return {shell}; } @@ -1986,6 +2014,115 @@ function Section({ title, children }: { title: string; children: React.ReactNode ); } +/** + * objectstack#34794 — a section collapsed by default: its title is the toggle, + * its one-line hint says what is inside, and the body mounts only while open. + * Ephemeral UI state (AGENTS.md #8): each field opens with it collapsed. + */ +function DeveloperSection({ title, hint, children }: { title: string; hint: string; children: React.ReactNode }) { + const [open, setOpen] = React.useState(false); + const bodyId = React.useId(); + return ( +
+ +

{hint}

+ {open && ( +
+ {children} +
+ )} +
+ ); +} + +/** + * objectstack#34794 — the field header's ⋯ menu. Its Delete asks first: the + * delete leaves the panel's footer, so a confirmation stands in for the + * visibility the button had there. + */ +function FieldMoreMenu({ + label, + removeLabel, + confirmTitle, + confirmBody, + confirmAction, + cancelLabel, + onRemove, + disabled, +}: { + label: string; + removeLabel: string; + confirmTitle: string; + confirmBody: string; + confirmAction: string; + cancelLabel: string; + onRemove: () => void; + disabled?: boolean; +}) { + const [confirming, setConfirming] = React.useState(false); + return ( + <> + + + + + + setConfirming(true)} + > + + + + + + + {confirmTitle} + {confirmBody} + + + {cancelLabel} + { + setConfirming(false); + onRemove(); + }} + > + {confirmAction} + + + + + + ); +} + /** * The label this field is SHOWN with, when a translation overrides the source * label the Label input edits (objectui#11782). diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index 2deb3c4862c..7066cc71e9e 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -18,6 +18,7 @@ import * as React from 'react'; import { createPortal } from 'react-dom'; import { useParams, useNavigate, useSearchParams, useLocation, Link, Navigate } from 'react-router-dom'; import { useAdapter, SchemaRendererProvider, useMetadata } from '@object-ui/react'; +import { leadWithNameField } from '@object-ui/core'; // The ONE draft-envelope reader (objectui#8181): unwrap AND strip the // framework's read decorations in one place. This file used to carry its own // copy that did the unwrap and skipped the strip. @@ -411,6 +412,7 @@ import { import { readAuthoredDraft } from './authoredDraft.js'; import { CreateItemDialog } from './CreateItemDialog.js'; import { AddFieldPopover } from './AddFieldPopover.js'; +import { StudioGridAddFieldButton, StudioGridAddFieldProvider, type StudioGridAddFieldValue } from './StudioGridAddField.js'; // objectui#11787 — the shared draft autosave, moved to its own module unchanged. import { useDraftAutoSave, type DraftSend } from './useDraftAutoSave.js'; import { FLOW_PRESETS, flowPresetTrigger, type FlowPreset } from './flowPresets.js'; @@ -5397,6 +5399,10 @@ export function renderStudioGridList(props: { onEdit={onEdit} onAddRecord={onAddRecord} className={className} + // objectstack#34794 — the Records tab's always-visible Add field, at the + // start of this toolbar row; it draws only where the grid's "+" column + // does (see `StudioGridAddFieldButton`). + toolbarLeading={} /> ); } @@ -6232,13 +6238,28 @@ export function DataPillar({ * a PRODUCER-side fix; ListView's by-identity dependency is correct for a genuine * column change and is left alone. */ + const draftNameField = shownDraft.nameField; + const draftDisplayNameField = shownDraft.displayNameField; const gridColumnsComputed = React.useMemo(() => { - // objectstack#29793 — the served object's columns the buffer does not - // declare (`owner_id` and the other injected ones) lead, as they lead the - // served object: the grid shows the records as the server has them. + // objectstack#29793 — the grid also shows the served object's columns the + // buffer does not declare (`owner_id` and the other injected ones). + // objectstack#34794 — they follow the author's fields, and the object's + // name field leads: the design grid opens on the column that tells its + // rows apart. The lead is the ADR-0079 D4 order through the shared + // `leadWithNameField`, over the fields this memo already holds. This is + // the design grid's default only; runtime list views keep their order. const held = readFields(shownDraft.fields).entries; const heldNames = new Set(held.map((e) => e.name)); - return [...servedOnly.filter((e) => !heldNames.has(e.name)), ...held] + const all = [...held, ...servedOnly.filter((e) => !heldNames.has(e.name))]; + // Only the declared pointer keys and the fields reach the helper, so the + // memo stays keyed on them rather than on the whole draft (see above). + const ordered = leadWithNameField( + { nameField: draftNameField, displayNameField: draftDisplayNameField, fields: Object.fromEntries(all.map((e) => [e.name, e.def])) }, + all.map((e) => e.name), + ); + const byName = new Map(all.map((e) => [e.name, e])); + return ordered + .map((n) => byName.get(n)!) // objectui#11780 — a column the platform injects AND hides (`__search`, // `owning_business_unit_id`) is no column an author manages. Read off // the definition this memo already holds, so the key stays @@ -6259,7 +6280,7 @@ export function DataPillar({ // inspector, which is where it gets configured; it joins the grid once // it is published and therefore queryable. .filter((n) => publishedFieldNames.has(n)); - }, [shownDraft.fields, publishedFieldNames, servedOnly]); + }, [shownDraft.fields, draftNameField, draftDisplayNameField, publishedFieldNames, servedOnly]); // objectstack#28575 — with a base object's extension open, the folded object // (`shownDraft`) is rebuilt on every extension edit, so a label typed into an // extension field would hand the grid a fresh columns array per keystroke: @@ -6766,6 +6787,13 @@ export function DataPillar({ // take focus back when the popover closes. const [gridAddFieldOpen, setGridAddFieldOpen] = React.useState(false); const gridAddFieldButton = React.useRef(null); + // Scopes the selected-header outline rule to this records body. + const recordsColumnsScope = React.useId(); + // objectstack#34794 — what the Records toolbar's Add field creates with. + const gridAddFieldCreate = React.useMemo( + () => ({ onCreate: addField, takenNames: addFieldTakenNames, extensionField: extendsBase }), + [addField, addFieldTakenNames, extendsBase], + ); // Drag-reorder columns → reorder the object's `fields` metadata (field display // order follows metadata order), saved as a DRAFT. Published later via the @@ -7166,8 +7194,10 @@ export function DataPillar({ } icon={current ? HeaderIcon : undefined} title={current ? current.label : t('engine.studio.data.objects', locale)} - titleProps={current ? undefined : { className: 'text-[13px] font-normal text-muted-foreground' }} - apiName={current?.name} + // objectstack#34794 — the object's machine name is the title's + // tooltip, not a chip beside it: the header reads as the label + // the app shows, and the name stays one hover away. + titleProps={current ? { title: current.name } : { className: 'text-[13px] font-normal text-muted-foreground' }} chips={current?.addedIn ? : undefined} meta={current && objLoaded ? fieldCountText : undefined} status={objDraftStatus} @@ -7211,9 +7241,10 @@ export function DataPillar({ {/* objectui#12511 — the header holds no actions of its own, so it reads the same on every tab. Object settings retired: the Settings tab is that control. Add field is a field action, - offered where fields are laid out: the Form toolbar and the - Records grid's own "+" column, both opening the Add field - popover that runs `addField` (objectui#12516). The + offered where fields are laid out: the Form toolbar, the + Records toolbar (objectstack#34794) and the Records grid's + own "+" column, all opening the Add field popover that + runs `addField` (objectui#12516). The More menu went with it, since the header has no object-level action left to put in one. */} {/* objectui#12453 — on the Form tab it carries the layout's @@ -7411,14 +7442,38 @@ export function DataPillar({
{ // React carries a click inside the (portalled) popover here // too; only a click in the body's own DOM is the grid's. - if (e.target instanceof Element && e.currentTarget.contains(e.target)) { - gridAddFieldButton.current = e.target.closest('button'); - } + if (!(e.target instanceof Element) || !e.currentTarget.contains(e.target)) return; + gridAddFieldButton.current = e.target.closest('button'); + // objectstack#34794 — a click on a field's column header + // selects that field and opens its properties, as the + // Interfaces canvas does (objectui#12725's + // `ColumnHeaderSelect`): taken in the capture phase, before + // the header's own sort handler. Sort and hide stay in the + // header's column menu (`columnMenuLabel` below). A control + // inside the header (the menu caret, the edit button) keeps + // its job, and a column the buffer does not declare (an + // injected one) keeps the grid's own click. + const header = e.target.closest('thead th[data-column-key]'); + if (!header || !e.currentTarget.contains(header)) return; + const control = e.target.closest('button, input, a, [role="checkbox"]'); + if (control && header.contains(control)) return; + const field = header.getAttribute('data-column-key'); + if (!field || !readFields(shownDraft.fields).entries.some((en) => en.name === field)) return; + e.stopPropagation(); + e.preventDefault(); + setFieldSel({ kind: 'field', id: field }); }} > + {fieldSel?.kind === 'field' ? ( + // The selected field's header is outlined, as the Interfaces + // canvas outlines its selected column: a style rule, since + // the grid owns its cells and redraws them. + + ) : null} {canAddFields && ( { // ignore non-field columns (e.g. the row-actions column) if (readFields(shownDraft.fields).entries.some((e) => e.name === fieldName)) { @@ -7453,6 +7509,7 @@ export function DataPillar({ editColumnLabel: t('engine.studio.data.editFieldProps', locale), }} > + {/* Provide the adapter as the dataSource context so the object-grid's * inline-edit save can write back: the ListView only fetches and * passes data inline, leaving the grid itself without a write dataSource. */} @@ -7485,6 +7542,7 @@ export function DataPillar({ renderListView={renderStudioGridList} /> +
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioGridAddField.tsx b/ui/packages/app-shell/src/views/studio-design/StudioGridAddField.tsx new file mode 100644 index 00000000000..60195c51080 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioGridAddField.tsx @@ -0,0 +1,51 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34794 — the Records tab's always-visible "Add field": a button at + * the start of the records grid's own toolbar row (`ListView`'s host prop + * `toolbarLeading`), opening the Data pillar's `AddFieldPopover` from itself. + * The grid's trailing "+" column stays; the toolbar entry is the one that is on + * screen however wide the object is. + * + * It draws only where the trailing "+" column draws: the grid's field-authoring + * context carries `onAddColumn` exactly when the pillar's `canAddFields` holds + * (not on a read-only package, not on an external object), so the two entries + * cannot disagree about who may add a field. + */ + +import * as React from 'react'; +import { useGridFieldAuthoring } from '@object-ui/components'; +import { Plus } from 'lucide-react'; +import { AddFieldPopover, type AddFieldPopoverProps } from './AddFieldPopover.js'; + +/** What the toolbar's popover creates with: the pillar's own `addField` inputs. */ +export type StudioGridAddFieldValue = Pick; + +const StudioGridAddFieldContext = React.createContext(null); + +/** Provided by the Data pillar around its records grid. */ +export const StudioGridAddFieldProvider = StudioGridAddFieldContext.Provider; + +/** The toolbar entry; draws nothing outside a pillar that may add a field. */ +export function StudioGridAddFieldButton(): React.ReactElement | null { + const authoring = useGridFieldAuthoring(); + const create = React.useContext(StudioGridAddFieldContext); + if (!authoring?.onAddColumn || !create) return null; + const label = authoring.addColumnLabel ?? 'Add field'; + return ( + + + + ); +} diff --git a/ui/packages/components/src/context/gridFieldAuthoring.tsx b/ui/packages/components/src/context/gridFieldAuthoring.tsx index 9c25153c981..f33d1abd98a 100644 --- a/ui/packages/components/src/context/gridFieldAuthoring.tsx +++ b/ui/packages/components/src/context/gridFieldAuthoring.tsx @@ -33,6 +33,14 @@ export interface GridFieldAuthoring { onEditColumn?: (fieldName: string) => void; /** Optional tooltip/aria-label for the edit-field button (defaults to "Edit field"). */ editColumnLabel?: string; + /** + * Set to draw a visible caret in every column header that opens the + * table's own column menu (sort, hide) — the menu a right-click opens. + * The value is the caret's tooltip/aria-label. A design host that takes + * the header click for itself (Studio selects the field) sets it so sort + * and hide stay one click away. Omit it and the header draws no caret. + */ + columnMenuLabel?: string; /** * Invoked when the user drag-reorders columns. Receives the new column order * as accessorKeys (= field names, including any non-field columns). Providing diff --git a/ui/packages/components/src/renderers/complex/data-table.tsx b/ui/packages/components/src/renderers/complex/data-table.tsx index f19704007c0..78af43e1f3d 100644 --- a/ui/packages/components/src/renderers/complex/data-table.tsx +++ b/ui/packages/components/src/renderers/complex/data-table.tsx @@ -1374,6 +1374,9 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { const fieldAuthoring = useGridFieldAuthoring(); const addColumnEnabled = !!fieldAuthoring?.onAddColumn; const editColumnEnabled = !!fieldAuthoring?.onEditColumn; + // A host that takes the header click (Studio selects the field) asks for a + // visible caret onto the column menu, so sort and hide stay one click away. + const columnMenuLabel = fieldAuthoring?.columnMenuLabel; // The table already implements column drag-reorder; a design host enables it by // providing onReorderFields (to persist the order to the object's field metadata). const reorderEnabled = reorderableColumns || !!fieldAuthoring?.onReorderFields; @@ -3577,6 +3580,30 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { )} + {columnMenuLabel && ( + + )} {resizableColumns && col.resizable !== false && (
= { 'designer.field.missing': 'This field no longer exists in the draft.', 'designer.field.remove': 'Remove “{label}”', 'designer.field.section.basic': 'Basic', + 'designer.field.section.developer': 'Developer info', + 'designer.field.section.developerHint': 'The internal name the API and formulas refer to. Everyday edits do not need it.', + 'designer.field.removeConfirmTitle': 'Delete the field “{label}”?', + 'designer.field.removeConfirmBody': 'The field leaves this object\'s draft. The change takes effect when you publish.', 'designer.field.section.advanced': 'Advanced', 'designer.field.section.options': '{type} options', 'designer.field.section.computed': 'Computed value', @@ -2531,6 +2535,7 @@ const STUDIO_EN: Record = { 'engine.studio.data.addFieldApiNameNotDerived': 'The label has no Latin letters to make an API name from. Type one: lowercase letters, digits and underscores.', 'engine.studio.data.addFieldApiNameTaken': 'Another field is already named {name}. Type a different API name.', 'engine.studio.data.editFieldProps': 'Edit field properties', + 'engine.studio.data.columnMenu': 'Sort and hide', 'engine.studio.data.draftObjectTitle': 'Unpublished new object', 'engine.studio.data.draftObjectHint': 'The Records grid queries real data, but this object has no table until it’s published. Design fields and groups in “Form · Layout” first, then click “Publish” in the top bar — after publishing, this becomes its live data grid.', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 22f3054ecd5..f1201d765fe 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -292,6 +292,10 @@ const STUDIO_ZH: Record = { 'designer.field.missing': '该字段已不在草稿中。', 'designer.field.remove': '删除“{label}”', 'designer.field.section.basic': '基础', + 'designer.field.section.developer': '开发者信息', + 'designer.field.section.developerHint': '内部名在接口与公式里引用,日常改字段用不到。', + 'designer.field.removeConfirmTitle': '删除字段“{label}”?', + 'designer.field.removeConfirmBody': '字段会从这个对象的草稿中移除,发布后生效。', 'designer.field.section.advanced': '高级', 'designer.field.section.options': '{type} 选项', 'designer.field.section.computed': '计算值', @@ -2275,6 +2279,7 @@ const STUDIO_ZH: Record = { 'engine.studio.data.addFieldApiNameNotDerived': '标签里没有可用来生成 API 名称的英文字母,请手动填写(小写字母、数字和下划线)。', 'engine.studio.data.addFieldApiNameTaken': '已有字段名为 {name},请填写其他 API 名称。', 'engine.studio.data.editFieldProps': '编辑字段属性', + 'engine.studio.data.columnMenu': '排序与隐藏', 'engine.studio.data.draftObjectTitle': '未发布的新对象', 'engine.studio.data.draftObjectHint': '「记录」网格查询真实数据,而这个对象发布前还没有数据表。请先在「表单 · 布局」里设计字段与分组,然后点顶栏「发布」— 发布后这里就是它的实时数据网格。', From b7ed203e2f37755c2f24096cbe863d33a3e1c09d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 14:38:22 +0000 Subject: [PATCH 2/5] feat(studio): delete in the header menu with a confirm, tests follow the new inspector and grid Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../34794-studio-records-tab-authoring.md | 24 +++ ...nspector.displayPatchReason-28986.test.tsx | 3 +- .../inspectors/ObjectFieldInspector.test.tsx | 77 +++++++ .../inspectors/ObjectFieldInspector.tsx | 16 +- .../previews/external-object.test.tsx | 6 +- .../DataPillar.authoredBuffer-29793.test.tsx | 7 +- .../studio-design/DataPillar.celGate.test.tsx | 8 +- .../DataPillar.recordsTab-34794.test.tsx | 198 ++++++++++++++++++ ...esignSurface.heldDataCreate-26845.test.tsx | 4 +- ...DesignSurface.heldDataLeave-26705.test.tsx | 4 +- ...esignSurface.heldFlowCreate-26845.test.tsx | 2 +- ...tudioItemHeader.statusPlace-12524.test.tsx | 5 +- ...ta-table-header-column-menu-34794.test.tsx | 127 +++++++++++ 13 files changed, 460 insertions(+), 21 deletions(-) create mode 100644 .changeset/34794-studio-records-tab-authoring.md create mode 100644 ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx create mode 100644 ui/packages/components/src/renderers/complex/__tests__/data-table-header-column-menu-34794.test.tsx diff --git a/.changeset/34794-studio-records-tab-authoring.md b/.changeset/34794-studio-records-tab-authoring.md new file mode 100644 index 00000000000..343f9a1e2b3 --- /dev/null +++ b/.changeset/34794-studio-records-tab-authoring.md @@ -0,0 +1,24 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +'@object-ui/components': patch +--- + +feat(studio): the Data pillar's Records tab keeps Add field on screen, a header click opens the field, the name field leads, and the field inspector puts the label first + +Clause-②: yes (widening) — an optional `columnMenuLabel` member on the exported `GridFieldAuthoring` context type of `@object-ui/components`, and new keys in the lazy `studio` namespace of the `@object-ui/i18n` packs; nothing that worked before is refused +Metadata-protocol: none + +Studio's Data pillar, Records tab: + +- **Add field is always on screen.** The records grid's toolbar row now starts with an Add field button that opens the same Add field popover. The trailing "+" column is kept. Both entries are offered only where a field may be added: not on a read-only package, not on an external object. +- **A header click opens the field.** Clicking a field's column header selects the field and opens its properties, and no longer sorts. Sort and hide are in the column menu, which a caret in every header now opens (the same menu a right-click opens). A column the object does not declare (such as the server's owner column) keeps the old click. +- **The name field leads.** The grid puts the object's name field first, frozen, in the shared order every list uses, and the server-injected columns (`owner_id`) after the author's fields. Only the Studio grid changes; runtime list views keep their column order. +- **The machine name is a tooltip.** The object's title no longer carries its machine name as a chip beside it; hovering the title shows it. + +Field inspector: + +- **The label comes first.** The display name is the first box. The API name moves into a collapsed "Developer info" section. +- **Delete is confirmed.** Remove moves from the inspector's footer into the header's "⋯" menu, and asks before it removes the field from the draft. + +`@object-ui/components`: `GridFieldAuthoring` gains an optional `columnMenuLabel`. When a host sets it, every column header draws a caret, named by the value, that opens the table's own column menu (sort ascending, sort descending, hide). A table with no provider, or a provider that does not set the member, draws exactly the header it drew before. diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx index 6f3aad6c9dc..be6ec9ebfd6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx @@ -163,7 +163,8 @@ describe('ObjectFieldInspector — display-patch mode explains every locked cont within(rail).getByLabelText(t('designer.field.visibleWhen', LOCALE)), // The header's pair and each option row's. ...within(rail).getAllByRole('button', { name: t('engine.inspector.reorder.up', LOCALE) }), - within(rail).getByRole('button', { name: tFormat('designer.field.remove', LOCALE, { label: 'Industry' }) }), + // objectstack#34794 — Remove is the header's ⋯ menu, its one entry. + within(rail).getByTestId('field-more-menu'), within(rail).getAllByTestId('option-value')[0]!, ]; for (const control of named) { diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx index fda8265af25..6f78754c02a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.test.tsx @@ -977,3 +977,80 @@ describe('ObjectFieldInspector — stored expression editor (objectstack#32576)' await waitFor(() => expect(onBlocking).toHaveBeenLastCalledWith(0), { timeout: 3000 }); }); }); + +describe('ObjectFieldInspector — label first, API name under Developer info, delete behind ⋯ (objectstack#34794)', () => { + it('the label is the first input; the API name is in a Developer info section that opens collapsed', async () => { + renderField({ title: { type: 'text', label: 'Meeting' } }, 'title'); + // The first input in document order, so the first one an author meets. + const inputs = Array.from(document.querySelectorAll('input, textarea')); + expect(inputs[0]).toBe(screen.getByTestId('field-label-input')); + expect(screen.getByTestId('field-apiname-input')).not.toBeVisible(); + const toggle = screen.getByTestId('field-developer-toggle'); + expect(toggle).toHaveTextContent(t('designer.field.section.developer', 'en-US')); + expect(toggle).toHaveAttribute('aria-expanded', 'false'); + await userEvent.click(toggle); + expect(toggle).toHaveAttribute('aria-expanded', 'true'); + expect(screen.getByTestId('field-apiname-input')).toBeVisible(); + expect(screen.getByTestId('field-apiname-input')).toHaveValue('title'); + }); + + it('renaming from the opened section still renames, and a taken name is still refused', async () => { + const { onPatch } = renderField( + { title: { type: 'text', label: 'Meeting' }, place: { type: 'text', label: 'Place' } }, + 'title', + ); + await userEvent.click(screen.getByTestId('field-developer-toggle')); + const box = screen.getByTestId('field-apiname-input'); + fireEvent.change(box, { target: { value: 'meeting_name' } }); + expect(Object.keys(onPatch.mock.calls.at(-1)![0].fields)).toEqual(['meeting_name', 'place']); + fireEvent.change(box, { target: { value: 'place' } }); + expect(screen.getByTestId('field-apiname-refusal')).toBeInTheDocument(); + }); + + it('no Remove button in the panel; Delete is in the header ⋯ menu and asks first — Cancel keeps the field, Delete removes it', async () => { + const onClearSelection = vi.fn(); + const { onPatch } = renderField( + { title: { type: 'text', label: 'Meeting' }, place: { type: 'text', label: 'Place' } }, + 'place', + { onClearSelection }, + ); + const removeName = `Remove “Place”`; + expect(screen.queryByRole('button', { name: removeName })).not.toBeInTheDocument(); + + const more = screen.getByTestId('field-more-menu'); + await userEvent.click(more); + await userEvent.click(await screen.findByRole('menuitem', { name: removeName })); + const dialog = await screen.findByRole('alertdialog'); + expect(dialog).toHaveTextContent('Delete the field “Place”?'); + await userEvent.click(within(dialog).getByTestId('field-remove-confirm-cancel')); + expect(onPatch).not.toHaveBeenCalled(); + expect(onClearSelection).not.toHaveBeenCalled(); + + await userEvent.click(screen.getByTestId('field-more-menu')); + await userEvent.click(await screen.findByRole('menuitem', { name: removeName })); + await userEvent.click(within(await screen.findByRole('alertdialog')).getByTestId('field-remove-confirm-action')); + expect(Object.keys(onPatch.mock.calls.at(-1)![0].fields)).toEqual(['title']); + expect(onClearSelection).toHaveBeenCalled(); + }); + + it('a read-only inspector draws the ⋯ menu disabled; an external object offers no Delete at all', () => { + renderField({ title: { type: 'text', label: 'Meeting' } }, 'title', { readOnly: true }); + expect(screen.getByTestId('field-more-menu')).toBeDisabled(); + cleanup(); + + render( + , + ); + expect(screen.getByTestId('field-label-input')).toBeInTheDocument(); + expect(screen.queryByTestId('field-more-menu')).not.toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx index ec481896e89..4d56af7bcc4 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx @@ -2016,8 +2016,9 @@ function Section({ title, children }: { title: string; children: React.ReactNode /** * objectstack#34794 — a section collapsed by default: its title is the toggle, - * its one-line hint says what is inside, and the body mounts only while open. - * Ephemeral UI state (AGENTS.md #8): each field opens with it collapsed. + * its one-line hint says what is inside. The body stays mounted and is only + * hidden while collapsed, so a control inside keeps its state across a toggle. + * Ephemeral UI state (ui/AGENTS.md #8): each field opens with it collapsed. */ function DeveloperSection({ title, hint, children }: { title: string; hint: string; children: React.ReactNode }) { const [open, setOpen] = React.useState(false); @@ -2036,11 +2037,9 @@ function DeveloperSection({ title, hint, children }: { title: string; hint: stri
); } @@ -2082,6 +2081,9 @@ function FieldMoreMenu({ aria-label={label} title={label} data-testid="field-more-menu" + // Its one entry is Delete: a locked field offers the menu disabled, + // so the lock's reason wraps a disabled control. + disabled={disabled} > diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx index 237ba5c8ee2..6ac83dfc669 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx @@ -176,6 +176,8 @@ describe('ObjectFieldInspector — field of an external object', () => { expect(screen.getByTestId('field-apiname-input')).toBeDisabled(); expect(screen.getByRole('combobox', { name: 'Type' })).toBeDisabled(); expect(screen.queryByRole('button', { name: 'Duplicate field' })).toBeNull(); + // objectstack#34794 — Remove is the header ⋯ menu's entry: no menu at all here. + expect(screen.queryByTestId('field-more-menu')).toBeNull(); expect(screen.queryByRole('button', { name: /Remove/ })).toBeNull(); // Label is display metadata, not the remote column: it stays editable. expect(screen.getByTestId('field-label-input')).not.toBeDisabled(); @@ -187,7 +189,7 @@ describe('ObjectFieldInspector — field of an external object', () => { expect(screen.getByTestId('field-apiname-input')).not.toBeDisabled(); expect(screen.getByRole('combobox', { name: 'Type' })).not.toBeDisabled(); expect(screen.getByRole('button', { name: 'Duplicate field' })).toBeInTheDocument(); - const footer = screen.getByRole('button', { name: /Remove/ }); - expect(within(footer).getByText(/Task name/)).toBeInTheDocument(); + // objectstack#34794 — Remove is the header ⋯ menu's entry. + expect(screen.getByTestId('field-more-menu')).not.toBeDisabled(); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx index cd61e021c63..867c0ac5a5f 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx @@ -241,10 +241,11 @@ describe('DataPillar in a zh-CN console — the object buffer is the authored do const own = tFormat('engine.studio.data.fieldCount', 'zh-CN', { count: 2 }); const system = tFormat('engine.studio.data.systemFieldCount', 'zh-CN', { count: 5 }); await screen.findByText(`${own} ${system}`, undefined, { timeout: 8000 }); - // The grid shows the records as the server has them: the served `owner_id` - // column leads, the author's columns follow; hidden ones stay out. + // The grid keeps the served `owner_id` column; hidden ones stay out. + // objectstack#34794 — the name field leads and the served column follows + // the author's fields. await waitFor( - () => expect(JSON.parse(screen.getByTestId('grid-columns').textContent ?? 'null')).toEqual(['owner_id', 'title', 'severity']), + () => expect(JSON.parse(screen.getByTestId('grid-columns').textContent ?? 'null')).toEqual(['title', 'severity', 'owner_id']), { timeout: 8000 }, ); }); diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx index 3220cb0af8b..05091f07121 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx @@ -34,7 +34,8 @@ import '@testing-library/jest-dom/vitest'; import * as React from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react'; +import { render, screen, fireEvent, cleanup, waitFor, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import { MemoryRouter } from 'react-router-dom'; const objectDef = { @@ -258,7 +259,10 @@ describe('DataPillar — the CEL hold belongs to the draft, not to the open insp it('removing the field ends the hold: nothing judged is left in the draft', async () => { await breakFormula(); - fireEvent.click(screen.getByRole('button', { name: 'Remove “Total”' })); + // objectstack#34794 — Delete is the header ⋯ menu's entry, confirmed first. + await userEvent.click(screen.getByTestId('field-more-menu')); + await userEvent.click(await screen.findByRole('menuitem', { name: 'Remove “Total”' })); + await userEvent.click(within(await screen.findByRole('alertdialog')).getByTestId('field-remove-confirm-action')); await waitFor(() => expect(mockClient.save).toHaveBeenCalled(), { timeout: 4000 }); const body = (mockClient.save.mock.calls.at(-1) as unknown[] | undefined)?.[2] as { fields: Array<{ name: string }> }; expect(body.fields.map((f) => f.name)).toEqual(['est_hours']); diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx new file mode 100644 index 00000000000..25a71966f1e --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx @@ -0,0 +1,198 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34794 — the Data pillar's Records tab, on the REAL records grid + * (plugin-view's ObjectView, plugin-list's ListView, the components data + * table), so every assertion reads what an author sees: + * + * - an "Add field" in the grid's own toolbar row, always on screen, opening + * the Add field popover; offered exactly where the grid's trailing "+" + * column is (not on a read-only package); + * - a click on a field's column header selects that field (its properties + * open) and does not sort; sort and hide are in the header's column menu, + * one caret away; + * - the object's name field is the first column and the served-only columns + * (`owner_id`) follow the author's fields; + * - the object's machine name is the title's tooltip, not a chip. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +// Module scope: the cold transform is paid during collection, which no test or +// hook timeout clocks (ui/AGENTS.md, flaky-test discipline). +import '@object-ui/components'; +import { render, screen, cleanup, waitFor, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { MemoryRouter } from 'react-router-dom'; + +const OBJECT = 'showcase_meeting'; + +/** The object as its author wrote it: the name field is not declared first. */ +const AUTHORED = { + name: OBJECT, + label: 'Meeting', + fields: { + place: { type: 'text', label: 'Place' }, + title: { type: 'text', label: 'Meeting name' }, + held_on: { type: 'date', label: 'Held on' }, + }, +}; + +/** What the server serves: its injected owner column leads. */ +const SERVED = { + ...AUTHORED, + fields: { + owner_id: { type: 'lookup', reference: 'sys_user', label: 'Owner', system: true, readonly: false }, + ...AUTHORED.fields, + }, +}; + +const mockClient = { + list: vi.fn(async (type: string) => (type === 'object' ? [{ name: OBJECT, label: 'Meeting' }] : [])), + listDrafts: vi.fn(async () => []), + layered: vi.fn(async () => ({ effective: SERVED, code: AUTHORED })), + getDraft: vi.fn(async () => null), + save: vi.fn(async () => ({})), +}; + +const ROWS = [ + { id: 'm2', title: 'Budget review', place: 'Room B', held_on: '2026-11-24', owner_id: null }, + { id: 'm1', title: 'All hands', place: 'Room A', held_on: '2026-11-20', owner_id: null }, +]; + +function createDataSource() { + return { + find: vi.fn(async () => ROWS), + findOne: vi.fn(async () => null), + create: vi.fn(async () => ({})), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + getObjectSchema: vi.fn(async () => SERVED), + }; +} +let dataSource = createDataSource(); + +vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) }; +}); + +vi.mock('./packages-io', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, fetchPackages: vi.fn(async () => []) }; +}); + +vi.mock('@object-ui/react', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, useAdapter: () => dataSource }; +}); + +import { DataPillar } from './StudioDesignSurface'; +import { t } from '../metadata-admin/i18n'; +import { registerMetadataInspector } from '../metadata-admin/inspector-registry'; +import { ObjectFieldInspector } from '../metadata-admin/inspectors/ObjectFieldInspector'; +import { completeAddFieldPopover } from './__tests__/dataPillarAddField'; + +registerMetadataInspector('object', ObjectFieldInspector); + +const ADD_FIELD = t('engine.studio.data.addField', 'en'); +const COLUMN_MENU = t('engine.studio.data.columnMenu', 'en'); + +beforeEach(() => { + dataSource = createDataSource(); + for (const m of ['hasPointerCapture', 'setPointerCapture', 'releasePointerCapture'] as const) { + if (!(m in Element.prototype)) { + (Element.prototype as unknown as Record)[m] = m === 'hasPointerCapture' ? () => false : () => {}; + } + } + if (!('scrollIntoView' in Element.prototype)) { + (Element.prototype as unknown as Record).scrollIntoView = () => {}; + } + // A grid with rows asks for their edit verdicts; answer from a double. + vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false, status: 404, json: async () => ({}) }))); +}); + +afterEach(() => { + cleanup(); + vi.clearAllMocks(); + vi.unstubAllGlobals(); +}); + +async function renderGrid(props: { readOnly?: boolean } = {}) { + render( + + + , + ); + await waitFor(() => expect(document.querySelector('thead th[data-column-key="title"]')).not.toBeNull(), { + timeout: 8000, + }); +} + +const header = (key: string) => document.querySelector(`thead th[data-column-key="${key}"]`) as HTMLElement; +const columnOrder = () => + Array.from(document.querySelectorAll('thead th[data-column-key]')) + .map((th) => th.getAttribute('data-column-key')) + .filter((k) => k !== '_actions'); +/** The rows' order, read off the body's text: the served order puts Budget review first. */ +const firstTitles = () => { + const text = document.querySelector('tbody')?.textContent ?? ''; + return ['Budget review', 'All hands'].sort((a, b) => text.indexOf(a) - text.indexOf(b)); +}; + +describe('Data pillar Records tab (objectstack#34794)', () => { + it("the name field leads and is the frozen first column; the served owner column follows the author's fields", async () => { + await renderGrid(); + expect(columnOrder()).toEqual(['title', 'place', 'held_on', 'owner_id']); + expect(header('title').className).toContain('sticky'); + }); + + it("Add field sits in the grid's toolbar row and opens the Add field popover there", async () => { + await renderGrid(); + const toolbarAdd = within(screen.getByTestId('list-toolbar-leading')).getByTestId('data-records-add-field'); + expect(toolbarAdd).toHaveTextContent(ADD_FIELD); + // The trailing "+" column is kept. + expect(screen.getByTestId('grid-add-column')).toBeInTheDocument(); + await userEvent.click(toolbarAdd); + await completeAddFieldPopover({ label: 'Agenda' }); + await waitFor(() => expect(mockClient.save).toHaveBeenCalled(), { timeout: 8000 }); + const calls = mockClient.save.mock.calls as unknown as Array<[string, string, { fields: Record }]>; + expect(Object.keys(calls.at(-1)![2].fields)).toContain('agenda'); + }); + + it('a read-only package offers neither Add field entry', async () => { + await renderGrid({ readOnly: true }); + expect(screen.queryByTestId('data-records-add-field')).not.toBeInTheDocument(); + expect(screen.queryByTestId('grid-add-column')).not.toBeInTheDocument(); + }); + + it("a header click selects the field and opens its properties, and does not sort; the caret's menu sorts and hides", async () => { + await renderGrid(); + const before = firstTitles(); + await userEvent.click(within(header('title')).getByText('Meeting name')); + // The field's properties are open: its label box holds the field's label. + expect(await screen.findByTestId('field-label-input')).toHaveValue('Meeting name'); + expect(firstTitles()).toEqual(before); + + const caret = within(header('title')).getByRole('button', { name: COLUMN_MENU }); + await userEvent.click(caret); + const menu = screen.getByTestId('column-context-menu'); + expect(within(menu).getAllByRole('button')).toHaveLength(3); + // The caret's click selected nothing else and did not sort either. + expect(firstTitles()).toEqual(before); + }); + + it("a click on a column the author's buffer does not declare (the served owner column) selects nothing", async () => { + await renderGrid(); + await userEvent.click(within(header('owner_id')).getByText('Owner')); + expect(screen.queryByTestId('field-label-input')).not.toBeInTheDocument(); + }); + + it("the object's machine name is the title's tooltip, not a chip beside it", async () => { + await renderGrid(); + const head = screen.getByTestId('data-object-header'); + expect(within(head).getByRole('heading', { level: 1 })).toHaveAttribute('title', OBJECT); + expect(within(head).queryByTestId('studio-item-api-name')).not.toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx index 13f1e08d0b3..bec0a63e012 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx @@ -144,10 +144,10 @@ afterEach(() => { window.history.replaceState(null, '', '/'); }); -/** The object the header names: its api-name chip. */ +/** The object the header names: its title's tooltip (objectstack#34794). */ async function openObjectIs(name: string): Promise { await waitFor( - () => expect(within(screen.getByTestId('data-object-header')).getByTestId('studio-item-api-name')).toHaveTextContent(name), + () => expect(within(screen.getByTestId('data-object-header')).getByRole('heading', { level: 1 })).toHaveAttribute('title', name), { timeout: 8000 }, ); } diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx index 1e805fc89ca..437f1761946 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx @@ -121,10 +121,10 @@ afterEach(() => { window.history.replaceState(null, '', '/'); }); -/** The object the header names: its api-name chip. */ +/** The object the header names: its title's tooltip (objectstack#34794). */ async function openObjectIs(name: string): Promise { await waitFor( - () => expect(within(screen.getByTestId('data-object-header')).getByTestId('studio-item-api-name')).toHaveTextContent(name), + () => expect(within(screen.getByTestId('data-object-header')).getByRole('heading', { level: 1 })).toHaveAttribute('title', name), { timeout: 8000 }, ); } diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx index d87584cbcb7..a4551bdcbae 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx @@ -198,7 +198,7 @@ const pendingRequest = () => fireEvent.click(screen.getByRole('button', { name: async function noteIsOpen(): Promise { await screen.findByTestId('studio-rail-data', undefined, { timeout: 8000 }); await waitFor( - () => expect(within(screen.getByTestId('data-object-header')).getByTestId('studio-item-api-name')).toHaveTextContent('acme_note'), + () => expect(within(screen.getByTestId('data-object-header')).getByRole('heading', { level: 1 })).toHaveAttribute('title', 'acme_note'), { timeout: 8000 }, ); } diff --git a/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx index 4ad9a8161ba..2abf26e9021 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx @@ -171,8 +171,11 @@ const CASES: PillarCase[] = [ pillar: 'Data', testId: 'data-object-header', element: (readOnly) => , + // objectstack#34794 — the object's machine name is the title's tooltip. settled: async (header) => { - await within(header).findByText(OBJECT.name, undefined, { timeout: 8000 }); + await waitFor(() => expect(within(header).getByRole('heading', { level: 1 })).toHaveAttribute('title', OBJECT.name), { + timeout: 8000, + }); }, }, { diff --git a/ui/packages/components/src/renderers/complex/__tests__/data-table-header-column-menu-34794.test.tsx b/ui/packages/components/src/renderers/complex/__tests__/data-table-header-column-menu-34794.test.tsx new file mode 100644 index 00000000000..c13ceb4d9bb --- /dev/null +++ b/ui/packages/components/src/renderers/complex/__tests__/data-table-header-column-menu-34794.test.tsx @@ -0,0 +1,127 @@ +/** + * 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#34794 — a design host can ask the column header for a visible + * caret onto the table's own column menu (`GridFieldAuthoring.columnMenuLabel`). + * + * Studio's Records tab takes the header click for itself (it selects the + * field), so sort and hide need a visible way in: the caret opens the menu a + * right-click opens, with the same entries. The caret's own click neither + * sorts nor reaches the header. Without a provider, or with a provider that + * does not set the member, the header is exactly what it was: the caret is + * the only node the member adds. + */ +import { describe, it, expect, afterEach } from 'vitest'; +import { render, screen, cleanup, fireEvent, within } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import React from 'react'; +import { ComponentRegistry } from '@object-ui/core'; +import { GridFieldAuthoringProvider, type GridFieldAuthoring } from '../../../context/gridFieldAuthoring'; +import '../data-table'; + +// Not in either column's order, so a sort by either one is visible. +const ROWS = [ + { id: '1', name: 'Bob', status: 'open' }, + { id: '2', name: 'Ada', status: 'done' }, + { id: '3', name: 'Cyd', status: 'hold' }, +]; + +const SCHEMA = { + type: 'data-table', + data: ROWS, + columns: [ + { header: 'Name', accessorKey: 'name' }, + { header: 'Status', accessorKey: 'status' }, + ], + pagination: false, +}; + +const MENU_LABEL = 'Sort and hide'; + +afterEach(cleanup); + +function DataTable(props: { schema: Record }) { + const Impl = ComponentRegistry.get('data-table') as React.ComponentType<{ schema: Record }> | undefined; + if (!Impl) throw new Error('data-table not registered'); + return ; +} + +function renderTable(authoring?: GridFieldAuthoring | null) { + const table = ; + return render( + authoring === undefined ? table : {table}, + ); +} + +const firstColumnValues = () => + Array.from(document.querySelectorAll('tbody tr')).map((tr) => (tr.querySelector('td')?.textContent ?? '').trim()); + +const headerHtml = (container: HTMLElement) => container.querySelector('thead')!.innerHTML; + +describe('data-table — the header caret onto the column menu (objectstack#34794)', () => { + it('no provider, or a provider without the member: no caret, and the header markup is the one a plain table draws', () => { + const plain = renderTable(); + expect(plain.container.querySelector('[data-testid^="grid-column-menu-"]')).toBeNull(); + const plainHtml = headerHtml(plain.container); + cleanup(); + + const withoutMember = renderTable({ onReorderFields: undefined }); + expect(withoutMember.container.querySelector('[data-testid^="grid-column-menu-"]')).toBeNull(); + expect(headerHtml(withoutMember.container)).toBe(plainHtml); + cleanup(); + + // With the member, the caret is the ONLY node it adds: drop the carets + // and the header is byte-identical to the plain table's. + const withMember = renderTable({ columnMenuLabel: MENU_LABEL }); + const thead = withMember.container.querySelector('thead')!; + const carets = thead.querySelectorAll('[data-testid^="grid-column-menu-"]'); + expect(carets).toHaveLength(2); + carets.forEach((c) => c.remove()); + expect(thead.innerHTML).toBe(plainHtml); + }); + + it('the caret is named by the member and opens the column menu: sort ascending, sort descending, hide', () => { + renderTable({ columnMenuLabel: MENU_LABEL }); + const caret = screen.getByTestId('grid-column-menu-name'); + expect(caret).toHaveAccessibleName(MENU_LABEL); + expect(caret).toHaveAttribute('aria-expanded', 'false'); + + fireEvent.click(caret); + const menu = screen.getByTestId('column-context-menu'); + expect(within(menu).getAllByRole('button').map((b) => b.textContent)).toEqual(['Sort ascending', 'Sort descending', 'Hide column']); + expect(caret).toHaveAttribute('aria-expanded', 'true'); + // Opening the menu did not sort: the rows keep their order. + expect(firstColumnValues()).toEqual(['Bob', 'Ada', 'Cyd']); + + // The caret toggles its own menu shut. + fireEvent.click(caret); + expect(screen.queryByTestId('column-context-menu')).toBeNull(); + }); + + it('the menu sorts and hides the column it was opened on', () => { + renderTable({ columnMenuLabel: MENU_LABEL }); + fireEvent.click(screen.getByTestId('grid-column-menu-name')); + fireEvent.click(within(screen.getByTestId('column-context-menu')).getByText('Sort descending')); + expect(firstColumnValues()).toEqual(['Cyd', 'Bob', 'Ada']); + fireEvent.click(screen.getByTestId('grid-column-menu-name')); + fireEvent.click(within(screen.getByTestId('column-context-menu')).getByText('Sort ascending')); + expect(firstColumnValues()).toEqual(['Ada', 'Bob', 'Cyd']); + + fireEvent.click(screen.getByTestId('grid-column-menu-status')); + fireEvent.click(within(screen.getByTestId('column-context-menu')).getByText('Hide column')); + expect(document.querySelector('thead th[data-column-key="status"]')).toBeNull(); + expect(document.querySelector('thead th[data-column-key="name"]')).not.toBeNull(); + }); + + it("the header's own click still sorts: taking it is the host's choice, not the member's", () => { + renderTable({ columnMenuLabel: MENU_LABEL }); + fireEvent.click(document.querySelector('thead th[data-column-key="name"]')!); + expect(firstColumnValues()).toEqual(['Ada', 'Bob', 'Cyd']); + }); +}); From 32680d0025a5a891ab58b44a23476b47e83e4c50 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 15:30:33 +0000 Subject: [PATCH 3/5] test(studio): collection-time loads for the edited suites, the Tab lock opens Developer info first, celGate removes through the confirm Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- ...tFieldInspector.displayPatchReason-28986.test.tsx | 3 +++ .../metadata-admin/previews/external-object.test.tsx | 4 ++++ .../DataPillar.authoredBuffer-29793.test.tsx | 3 +++ .../views/studio-design/DataPillar.celGate.test.tsx | 12 +++++++----- .../DataPillar.recordsTab-34794.test.tsx | 3 +++ ...StudioDesignSurface.heldDataCreate-26845.test.tsx | 3 +++ .../StudioDesignSurface.heldDataLeave-26705.test.tsx | 3 +++ ...StudioDesignSurface.heldFlowCreate-26845.test.tsx | 3 +++ .../StudioItemHeader.statusPlace-12524.test.tsx | 3 +++ 9 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx index be6ec9ebfd6..d86cc8b1bfa 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx @@ -178,6 +178,9 @@ describe('ObjectFieldInspector — display-patch mode explains every locked cont it('Tab reaches a lock, and focus or hover shows the reason as a tooltip', async () => { const rail = mount('name'); const sentence = within(rail).getByTestId('field-base-patch-only').textContent!.trim(); + // objectstack#34794 — the API name sits in the collapsed Developer info + // section: open it, as an author must, before Tab can reach its lock. + await userEvent.click(within(rail).getByTestId('field-developer-toggle')); const apiNameLock = within(rail).getByTestId('field-apiname-input').closest('[data-disabled-reason]')!; let reached = false; for (let i = 0; i < 12 && !reached; i++) { diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx index 6ac83dfc669..68d24bda4b8 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx @@ -26,6 +26,10 @@ vi.mock('../../../hooks/useAiSurface', () => ({ })); import { ObjectFormCanvas } from './ObjectFormCanvas'; +// The source under test reaches a dynamic import of `@objectstack/lint` and `@objectstack/formula`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; +import '@objectstack/formula'; import { ObjectFieldInspector } from '../inspectors/ObjectFieldInspector'; import { readExternalBinding } from './external-object'; diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx index 867c0ac5a5f..8f502c56a54 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.authoredBuffer-29793.test.tsx @@ -124,6 +124,9 @@ vi.mock('@object-ui/plugin-view', async (importOriginal) => { return { ...mod, ObjectView: GridDouble }; }); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { DataPillar } from './StudioDesignSurface'; import { t, tFormat } from '../metadata-admin/i18n'; import { registerMetadataInspector } from '../metadata-admin/inspector-registry'; diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx index 05091f07121..760d1f2d705 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.celGate.test.tsx @@ -35,7 +35,6 @@ import '@testing-library/jest-dom/vitest'; import * as React from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { render, screen, fireEvent, cleanup, waitFor, within } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import { MemoryRouter } from 'react-router-dom'; const objectDef = { @@ -110,6 +109,9 @@ vi.mock('@object-ui/react', async (importOriginal) => { import { DataPillar } from './StudioDesignSurface'; import { createEmptyDataSource, failOnAbsorbedFetchError } from './__tests__/emptyDataSource'; import { registerBuiltinInspectors } from '../metadata-admin/inspectors'; +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { __setCelFormulaLoader } from '../metadata-admin/celAuthoring'; const dataSource = createEmptyDataSource(); @@ -259,10 +261,10 @@ describe('DataPillar — the CEL hold belongs to the draft, not to the open insp it('removing the field ends the hold: nothing judged is left in the draft', async () => { await breakFormula(); - // objectstack#34794 — Delete is the header ⋯ menu's entry, confirmed first. - await userEvent.click(screen.getByTestId('field-more-menu')); - await userEvent.click(await screen.findByRole('menuitem', { name: 'Remove “Total”' })); - await userEvent.click(within(await screen.findByRole('alertdialog')).getByTestId('field-remove-confirm-action')); + // objectstack#34794 — Delete is the header ⋯ menu's entry (a passthrough + // here, see the mock above), and it asks before it removes. + fireEvent.click(screen.getByRole('button', { name: 'Remove “Total”' })); + fireEvent.click(within(await screen.findByRole('alertdialog')).getByTestId('field-remove-confirm-action')); await waitFor(() => expect(mockClient.save).toHaveBeenCalled(), { timeout: 4000 }); const body = (mockClient.save.mock.calls.at(-1) as unknown[] | undefined)?.[2] as { fields: Array<{ name: string }> }; expect(body.fields.map((f) => f.name)).toEqual(['est_hours']); diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx index 25a71966f1e..b266f1961a3 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.recordsTab-34794.test.tsx @@ -88,6 +88,9 @@ vi.mock('@object-ui/react', async (importOriginal) => { return { ...mod, useAdapter: () => dataSource }; }); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { DataPillar } from './StudioDesignSurface'; import { t } from '../metadata-admin/i18n'; import { registerMetadataInspector } from '../metadata-admin/inspector-registry'; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx index bec0a63e012..d157a7d8677 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataCreate-26845.test.tsx @@ -87,6 +87,9 @@ vi.mock('../../preview/DraftChangesPanel', async () => { }; }); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { StudioDesignSurface } from './StudioDesignSurface'; import { addFieldFromFormToolbar } from './__tests__/dataPillarAddField'; import { createEmptyDataSource } from './__tests__/emptyDataSource'; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx index 437f1761946..b9590ff5e6f 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx @@ -64,6 +64,9 @@ vi.mock('@object-ui/react', async (importOriginal) => { vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null })); vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { StudioDesignSurface } from './StudioDesignSurface'; import { addFieldFromFormToolbar } from './__tests__/dataPillarAddField'; import { createEmptyDataSource } from './__tests__/emptyDataSource'; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx index a4551bdcbae..592789805ba 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowCreate-26845.test.tsx @@ -98,6 +98,9 @@ vi.mock('../../preview/DraftChangesPanel', async () => { }; }); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { StudioDesignSurface } from './StudioDesignSurface'; import { createEmptyDataSource } from './__tests__/emptyDataSource'; import { registerMetadataPreview } from '../metadata-admin/preview-registry'; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx index 2abf26e9021..28afecbb005 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioItemHeader.statusPlace-12524.test.tsx @@ -111,6 +111,9 @@ vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } })); vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null })); vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null })); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { AccessPillar, AutomationsPillar, DataPillar, InterfacesPillar } from './StudioDesignSurface'; import '../../services/builtinComponents.js'; import { t } from '../metadata-admin/i18n'; From 44f9722c390fd76384db97847052449e8bd2b210 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 15:47:51 +0000 Subject: [PATCH 4/5] test(studio): the read-only rail's Remove is the disabled header menu Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../DataPillar.readOnlyRailReason-12303.test.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.readOnlyRailReason-12303.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.readOnlyRailReason-12303.test.tsx index 29f5f13516c..97d6cd3f747 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.readOnlyRailReason-12303.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.readOnlyRailReason-12303.test.tsx @@ -59,6 +59,9 @@ vi.mock('@object-ui/react', async (importOriginal) => { return { ...mod, useAdapter: () => dataSource }; }); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { DataPillar } from './StudioDesignSurface'; import { createEmptyDataSource, failOnAbsorbedFetchError } from './__tests__/emptyDataSource'; import { registerMetadataInspector } from '../metadata-admin/inspector-registry'; @@ -112,8 +115,8 @@ describe('Data pillar Field properties on a read-only package — the reason rea const apiName = within(body).getByDisplayValue('priority'); expect(apiName).toBeDisabled(); - const remove = within(body).getByRole('button', { name: /^Remove/ }); - expect(remove).toBeDisabled(); + // objectstack#34794 — Remove is the header ⋯ menu's entry; the menu is disabled. + expect(within(body).getByTestId('field-more-menu')).toBeDisabled(); }); it('hovering the disabled controls opens a tooltip with the reason', async () => { From 8239a213b0cf42c851b71f2c89e48a62fb40214c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:37:33 +0000 Subject: [PATCH 5/5] test(app-shell): drop two unused test imports flagged by Lint UI Lint UI on d2e0c11ab7 failed with object-ui/no-unused-imports on `tFormat` in ObjectFieldInspector.displayPatchReason-28986.test.tsx and `within` in external-object.test.tsx, left over after the moved Remove control's reads were re-pointed. Imports only; no test logic changes. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../ObjectFieldInspector.displayPatchReason-28986.test.tsx | 2 +- .../src/views/metadata-admin/previews/external-object.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx index d86cc8b1bfa..a93453c2a0c 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.displayPatchReason-28986.test.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { cleanup, render, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { t, tFormat } from '../i18n'; +import { t } from '../i18n'; type Row = Record; diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx index 68d24bda4b8..72691e4112a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/external-object.test.tsx @@ -10,7 +10,7 @@ import * as React from 'react'; import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; -import { render, screen, fireEvent, cleanup, waitFor, within } from '@testing-library/react'; +import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react'; import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; const metaGet = vi.fn();