Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TESTING_COVERAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion browser/data-browser/UI_COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
152 changes: 53 additions & 99 deletions browser/data-browser/src/chunks/TablePage/RowActionDialog.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -14,10 +20,8 @@ import { PropertyOption } from './DerivedColumnDialog';
import {
ROW_ACTION_GENERATORS,
ROW_ACTION_KINDS,
isRowActionComplete,
propertiesForRowAction,
rowActionValueInput,
type RowActionKind,
type RowActionSpec,
} from './rowActions';

Expand All @@ -42,120 +46,70 @@ export function RowActionDialog({
editing,
onSave,
}: Props): JSX.Element {
const [dialogProps, show, hide, isOpen] = useDialog({ bindShow });

const [kind, setKind] = useState<RowActionKind>('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: <PropertyOption key={candidate.subject} property={candidate} />,
values: candidate.allowsOnly?.map(tag => ({
key: tag,
option: <TagOption key={tag} subject={tag} />,
})),
}),
),
}));

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: <PropertyOption key={property.subject} property={property} />,
values: property.allowsOnly?.map(tag => ({
key: tag,
option: <TagOption key={tag} subject={tag} />,
})),
})),
}));

return (
<Dialog {...dialogProps}>
<DialogTitle>
<h2>{editing ? 'Edit action' : 'Add an action'}</h2>
</DialogTitle>
<DialogContent>
<TableRowActionFields
kinds={kinds}
kind={kind}
property={property}
label={label}
value={value}
values={
target?.allowsOnly?.map(tag => ({
key: tag,
option: <TagOption key={tag} subject={tag} />,
})) ?? []
}
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 && (
<TableRowActionFields
initial={editing}
kinds={kinds}
Input={ActionInput}
onChange={(draft, valid) => 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.',
}}
/>
)}
</DialogContent>
<DialogActions>
<Button subtle onClick={() => hide()}>
Cancel
</Button>
<Button
data-testid='action-config-save'
disabled={!complete}
disabled={!state?.valid}
onClick={() => {
onSave(draft);
if (!state?.valid) return;
onSave(state.draft);
hide();
}}
>
Expand Down
4 changes: 4 additions & 0 deletions browser/data-browser/src/locales/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -13512,3 +13512,7 @@ msgstr ""
#: src/chunks/TablePage/PropertyForm/ExternalPropertyDialog.tsx
msgid "Attachment started. Retry to finish adding this property to the table."
msgstr ""

#: src/chunks/TablePage/RowActionDialog.tsx
msgid "Enter a finite number."
msgstr ""
4 changes: 4 additions & 0 deletions browser/data-browser/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -13525,3 +13525,7 @@ msgstr "Property attachment is unavailable. Check access and the selected table.
#: src/chunks/TablePage/PropertyForm/ExternalPropertyDialog.tsx
msgid "Attachment started. Retry to finish adding this property to the table."
msgstr "Attachment started. Retry to finish adding this property to the table."

#: src/chunks/TablePage/RowActionDialog.tsx
msgid "Enter a finite number."
msgstr "Enter a finite number."
4 changes: 4 additions & 0 deletions browser/data-browser/src/locales/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -13512,3 +13512,7 @@ msgstr ""
#: src/chunks/TablePage/PropertyForm/ExternalPropertyDialog.tsx
msgid "Attachment started. Retry to finish adding this property to the table."
msgstr ""

#: src/chunks/TablePage/RowActionDialog.tsx
msgid "Enter a finite number."
msgstr ""
4 changes: 4 additions & 0 deletions browser/data-browser/src/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -13512,3 +13512,7 @@ msgstr ""
#: src/chunks/TablePage/PropertyForm/ExternalPropertyDialog.tsx
msgid "Attachment started. Retry to finish adding this property to the table."
msgstr ""

#: src/chunks/TablePage/RowActionDialog.tsx
msgid "Enter a finite number."
msgstr ""
5 changes: 5 additions & 0 deletions browser/table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,8 @@ fresh UI; already accepted writes finish against their captured backend and late
successes do not notify the new page. Failed values stay visible with their error
and are never retried automatically. Backend adapters retain creation defaults,
validation, identity and persistence policy.

`TableRowActionFields` owns row-action configuration fields, compatible target and
tag choices, target/literal resets, raw finite-decimal validation and stable local
action identity. Adapters provide compatibility and subscribed option elements;
execution and dialog lifecycle remain backend/host responsibilities.
Loading
Loading