diff --git a/TESTING_COVERAGE.md b/TESTING_COVERAGE.md index e44f81a84..3fc6abcad 100644 --- a/TESTING_COVERAGE.md +++ b/TESTING_COVERAGE.md @@ -1,3 +1,5 @@ +Row-action configuration (#2552): `browser/table/src/RowActionFields.test.tsx` verifies unfinished numeric drafts and original action identity, target resets, subscribed allowed-value removal/restoration (including an empty allowed list), and unrestricted literals. + Shared view tabs: `browser/table/src/views/ViewTabs.test.tsx` mounts tabs without an Atomic Store or theme, checks selection/disabled state and rename commit-once, trim, blur, blank/unchanged rejection and Escape cancellation. `browser/data-browser/src/chunks/TablePage/TableViewTabs.test.tsx` exercises the Atomic resource/menu adapter; ELFA native-browser tests cover its separate NextGraph adapter. These tests do not establish drag-order persistence or menu/backend parity for external consumers. Table workspace package: `browser/table/src/chunks/TableEditor/*.test.tsx`, helper and height-hook tests own the extracted grid interaction/loading coverage. `browser/data-browser/src/chunks/TablePage/EditorCells/DateCell.test.tsx` and `TruncatedText.test.tsx` verify the Atomic display/editor adapters. The dedicated `table-package.yml` lane lints, typechecks, tests and packs the package, then installs it in a clean temporary consumer to mount it and check NodeNext declarations without Data Browser aliases or backend services. Full table/server integration remains in the main pipeline. diff --git a/browser/data-browser/UI_COMPONENTS.md b/browser/data-browser/UI_COMPONENTS.md index f72630845..af336b18a 100644 --- a/browser/data-browser/UI_COMPONENTS.md +++ b/browser/data-browser/UI_COMPONENTS.md @@ -10,7 +10,7 @@ This document might not be entirely up to date. If you need anything that is not ## Table grid -- `@tomic/table` (`browser/table`) owns the virtual grid, selection/context and primitive editors. Data Browser callers use the `chunks/TableEditor` compatibility entry so application control locks and loading UI are supplied by `AtomicTable`. Its `ViewTab`, `ViewTabsBar`, `ViewTabList` and `ViewTabActions` also own saved-view tab presentation and inline rename. Shared `TableFilterMenu`, `TableFilterBar`, `TableFilterChip`, `TableFilterValueInput`, `TablePropertyHeading`, `TablePropertyMenu` and `TableColumnsMenu` provide filter selection/editing, sortable headings and column visibility with backend metadata adapters. `TablePropertyDialog` owns the page-mounted property edit and new-column lifecycle, with Atomic modal/metadata adapters and checkpointed datatype-replacement retries. `TablePropertyForm` and `TablePropertyFields` own the actual property-form submission/name/category layout, with Atomic metadata controllers and resource/tag/currency leaves. `PropertyPrecisionField` and `PropertyDateFormatField` own raw precision validation and date-format choices/previews; Atomic supplies metadata bindings and locale examples. `TableColumnRemovalDialog` owns asynchronous removal confirmation and is mounted by the page, outside column headings. Resource queries, formatting, permissions, property-command services and view persistence stay in the host. +- `@tomic/table` (`browser/table`) owns the virtual grid, selection/context and primitive editors. Data Browser callers use the `chunks/TableEditor` compatibility entry so application control locks and loading UI are supplied by `AtomicTable`. Its `ViewTab`, `ViewTabsBar`, `ViewTabList` and `ViewTabActions` also own saved-view tab presentation and inline rename. Shared `TableFilterMenu`, `TableFilterBar`, `TableFilterChip`, `TableFilterValueInput`, `TablePropertyHeading`, `TablePropertyMenu` and `TableColumnsMenu` provide filter selection/editing, sortable headings and column visibility with backend metadata adapters. `TablePropertyDialog` owns the page-mounted property edit and new-column lifecycle, with Atomic modal/metadata adapters and checkpointed datatype-replacement retries. `TablePropertyForm` and `TablePropertyFields` own the actual property-form submission/name/category layout, with Atomic metadata controllers and resource/tag/currency leaves. `PropertyPrecisionField` and `PropertyDateFormatField` own raw precision validation and date-format choices/previews; Atomic supplies metadata bindings and locale examples. `TableColumnRemovalDialog` owns asynchronous removal confirmation and is mounted by the page, outside column headings. `TableNewColumnMenu` owns add-column capability dispatch; external attachment also uses the shared property-dialog lifecycle. `TableQuickAddBar` owns the actual quick-add field/button and scoped serial queue. `TableRowActionFields` owns action kind/target/literal transitions and raw numeric validation, with Atomic resource/tag options. Resource queries, formatting, permissions, property-command services and view persistence stay in the host. ## Layout diff --git a/browser/data-browser/src/chunks/TablePage/RowActionDialog.tsx b/browser/data-browser/src/chunks/TablePage/RowActionDialog.tsx index 7349aff5b..6932a43ba 100644 --- a/browser/data-browser/src/chunks/TablePage/RowActionDialog.tsx +++ b/browser/data-browser/src/chunks/TablePage/RowActionDialog.tsx @@ -1,5 +1,11 @@ import { core, useResource, useString, type Property } from '@tomic/react'; -import { useEffect, useState, type JSX, type InputHTMLAttributes } from 'react'; +import { + useCallback, + useEffect, + useState, + type InputHTMLAttributes, + type JSX, +} from 'react'; import { TableRowActionFields } from '@tomic/table'; import { Dialog, @@ -14,10 +20,8 @@ import { PropertyOption } from './DerivedColumnDialog'; import { ROW_ACTION_GENERATORS, ROW_ACTION_KINDS, - isRowActionComplete, propertiesForRowAction, rowActionValueInput, - type RowActionKind, type RowActionSpec, } from './rowActions'; @@ -42,69 +46,34 @@ export function RowActionDialog({ editing, onSave, }: Props): JSX.Element { - const [dialogProps, show, hide, isOpen] = useDialog({ bindShow }); - - const [kind, setKind] = useState('setNow'); - const [label, setLabel] = useState(''); - const [property, setProperty] = useState(''); - const [value, setValue] = useState(''); - + const [state, setState] = useState<{ + draft: RowActionSpec; + valid: boolean; + }>(); + const clear = useCallback(() => setState(undefined), []); + const [dialogProps, show, hide, isOpen] = useDialog({ + bindShow, + onCancel: clear, + onSuccess: clear, + }); useEffect(() => { - if (open) { - show(); - } + if (open) show(); }, [open, show]); - - useEffect(() => { - if (!isOpen) { - return; - } - - setKind(editing?.kind ?? 'setNow'); - setLabel(editing?.label ?? ''); - setProperty(editing?.property ?? ''); - setValue(editing?.value === undefined ? '' : String(editing.value)); - // Only on open: re-syncing while the dialog is up would overwrite what is - // being typed every time a commit lands. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isOpen]); - - const generator = ROW_ACTION_GENERATORS[kind]; - const valueField = rowActionValueInput(kind); - const target = classProperties.find(p => p.subject === property); - - const kinds = ROW_ACTION_KINDS.map(actionKind => ({ - kind: actionKind, - title: ROW_ACTION_GENERATORS[actionKind].title, - description: ROW_ACTION_GENERATORS[actionKind].description, - defaultLabel: ROW_ACTION_GENERATORS[actionKind].defaultLabel, - valueField: rowActionValueInput(actionKind), - targets: propertiesForRowAction(classProperties, actionKind).map( - candidate => ({ - key: candidate.subject, - option: , - values: candidate.allowsOnly?.map(tag => ({ - key: tag, - option: , - })), - }), - ), - })); - - const draft: RowActionSpec = { - id: editing?.id ?? '', - label: label || generator.defaultLabel, + const kinds = ROW_ACTION_KINDS.map(kind => ({ kind, - property, - ...(valueField - ? { - value: - valueField.input === 'number' ? Number(value) : (value as string), - } - : {}), - }; - - const complete = isRowActionComplete(draft) && !!property; + title: ROW_ACTION_GENERATORS[kind].title, + description: ROW_ACTION_GENERATORS[kind].description, + defaultLabel: ROW_ACTION_GENERATORS[kind].defaultLabel, + valueField: rowActionValueInput(kind), + targets: propertiesForRowAction(classProperties, kind).map(property => ({ + key: property.subject, + option: , + values: property.allowsOnly?.map(tag => ({ + key: tag, + option: , + })), + })), + })); return ( @@ -112,40 +81,24 @@ export function RowActionDialog({

{editing ? 'Edit action' : 'Add an action'}

- ({ - key: tag, - option: , - })) ?? [] - } - onKindChange={next => { - setKind(next); - setProperty(''); - setValue(''); - }} - onPropertyChange={next => { - setProperty(next); - setValue(''); - }} - onValueChange={setValue} - onLabelChange={setLabel} - Input={ActionInput} - messages={{ - kind: 'Does what', - property: 'To column', - pickProperty: 'Pick a column…', - pickOption: 'Pick an option…', - label: 'Button says', - noTargets: - 'This table has no column of the right kind for that yet.', - }} - /> + {isOpen && ( + setState({ draft, valid })} + messages={{ + kind: 'Does what', + property: 'To column', + pickProperty: 'Pick a column…', + pickOption: 'Pick an option…', + label: 'Button says', + noTargets: + 'This table has no column of the right kind for that yet.', + invalidNumber: 'Enter a finite number.', + }} + /> + )}