Skip to content

Commit fafa49f

Browse files
committed
docs(plugin-grid): the demo and README name only declared actions; changeset for the undeclared-name narrowing
Claude-Session: https://claude.ai/code/session_01Utp6CZ1rxZPzain2p5bv5x Co-authored-by: Claude <noreply@anthropic.com>
1 parent d7b8e9a commit fafa49f

3 files changed

Lines changed: 43 additions & 19 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/plugin-grid': minor
3+
---
4+
5+
fix(plugin-grid)!: a list's selection bar and row menu draw only actions the object declares; an undeclared bare `bulkActions` / `rowActions` name draws nothing and warns once in development (#30169)
6+
7+
Clause-②: no (narrowing) — the grid stops drawing a bare `bulkActions` or legacy `rowActions` name that matches no action the object declares, which it drew before by humanized name. `packages/spec/src/ui/bulk-action.zod.ts` already says the member "names an action the object declares", and lint `action-name-undefined` (ADR-0049) refuses any other at authoring. Nothing is widened.
8+
Metadata-protocol: narrowed
9+
Skills-docs: no move — `skills/**` teaches no handler-only bulk or row action name (searched for `bulkActions` / `rowActions` examples and runner-handler text); `content/docs/ui/**` already names only declared actions in its `bulkActions` / `rowActions` examples.
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema, export or stored row changes shape: `bulkActions` and `rowActions` keep their `string[]` form and meaning. What narrows is the renderer's draw set, back to the spec's own sentence. Whether an undeclared name was a misspelling, an action still to declare or a handler the host meant to keep is a judgement about the view, so no rewrite derives the fix; the development warning names each name. -->
12+
13+
**BREAKING** for a host that registered a runner handler under a bare name the object does not declare (`ActionProvider handlers` / `runner.registerHandler('NAME', …)`) and listed that name in a view's `bulkActions` or `rowActions`.
14+
15+
- **Before.** `resolveBulkActions` and `resolveLegacyRowActions` kept a name that matched no declared action, and `ObjectGrid` drew it by humanized name and dispatched it to the runner by name. A name nothing handled toasted "not executable" on click. This is how a list whose app had a package disabled kept a ghost button: the server withholds that package's actions from the served object, so their names matched nothing.
16+
- **Now.** Such a name gets no selection-bar button and no row-menu entry, and in development the console logs one warning per list naming the key, the block and each name. The resolvers return those names as `undeclared` (renamed from `unresolved`), used only for that warning. The canonical `'delete'` (and the row menu's `'edit'` / `'delete'`) keep their own paths, unchanged.
17+
- **Unchanged.** A name that matches a declared action is promoted to that action's def exactly as before, under the action's own label, icon, params, `visible` and `requiredPermissions`.
18+
19+
**FROM → TO.** `bulkActions: ['NAME']` (or `rowActions: ['NAME']`) where the object declares no `NAME` action, served by a runner handler → declare `NAME` as an action on the object, or remove the name. An action withheld by a disabled package needs nothing: it returns when the package is enabled.

‎ui/packages/plugin-grid/README.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ const schema: ObjectGridBlockNode = {
549549
objectName: 'users',
550550
columns: ['name', 'email'],
551551
selection: { type: 'multiple' },
552-
bulkActions: ['delete', 'export'],
552+
// `deactivate` is an action the `users` object declares.
553+
bulkActions: ['delete', 'deactivate'],
553554
} satisfies ObjectGridProps,
554555
};
555556
```
@@ -757,6 +758,13 @@ const schema: ObjectGridBlockNode = {
757758
themselves live in the object's action set, so the same action behaves identically
758759
wherever it is offered. They are `string[]`, not inline definitions with callbacks.
759760

761+
Each name must name an action the object declares; `'edit'` and `'delete'` are the
762+
built-in exceptions. A name the object does not declare draws nothing: no row-menu
763+
entry and no selection-bar button, and in development the console logs one warning
764+
naming it. That includes a misspelling and an action a disabled package withholds,
765+
which the server leaves out of the object. A runner handler registered under a bare
766+
name is not a declaration and does not bring the entry back.
767+
760768
```typescript
761769
import type { ObjectGridBlockNode } from '@object-ui/types';
762770
import type { ObjectGridProps } from '@objectstack/spec/ui';
@@ -766,9 +774,10 @@ const schema: ObjectGridBlockNode = {
766774
properties: {
767775
objectName: 'users',
768776
columns: ['name', 'email'],
769-
rowActions: ['view', 'edit', 'delete'],
777+
// `deactivate` is an action the `users` object declares.
778+
rowActions: ['deactivate', 'edit', 'delete'],
770779
selection: { type: 'multiple' },
771-
bulkActions: ['delete', 'export'],
780+
bulkActions: ['delete', 'deactivate'],
772781
} satisfies ObjectGridProps,
773782
};
774783
```

‎ui/packages/plugin-grid/demo/bulk-actions.tsx‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
* action (spec 17 retired `action.bulkEnabled` as a tombstone). Both
1717
* names used to dispatch as `{ type: '<name>' }` and never run; the
1818
* buttons also carried none of the def's label / icon / params.
19-
* 2. `legacy_only_handler` resolves to no declared action and stays a
20-
* by-name dispatch — it must still render ALONGSIDE the two defs above.
19+
* 2. `not_declared` names no action the object declares, so the bar draws
20+
* NO button for it (the spec: a bare name "names an action the object
21+
* declares"), and the browser console logs one warning naming it. An
22+
* action a disabled package withholds reads the same way: it leaves the
23+
* served object, so its name draws nothing (objectstack#30169).
2124
* 3. Record `t3` fails server-side (422), proving per-record attribution: the
2225
* result panel reports 4/5 with an error row rather than a blanket success.
2326
* 4. Rich `bulkActionDefs` with picker params (#3064 / ADR-0059): `Set
@@ -237,8 +240,9 @@ const schema: any = {
237240
{ field: 'progress', label: 'Progress' },
238241
],
239242
pagination: { pageSize: 50 },
240-
// Bare names: two resolve to declared actions, one doesn't.
241-
bulkActions: ['bulk_mark_done', 'bulk_recalc_estimate', 'legacy_only_handler'],
243+
// Bare names: two resolve to declared actions; `not_declared` names nothing
244+
// the object declares, so it draws no button and warns once in the console.
245+
bulkActions: ['bulk_mark_done', 'bulk_recalc_estimate', 'not_declared'],
242246
// Rich defs with picker params — the shared-field-widget surface (#3064).
243247
bulkActionDefs: [
244248
// Aggregate mode (#3139): names the declared action, ONE dispatch for the
@@ -285,8 +289,9 @@ function Demo() {
285289
Select rows → the bar shows <b>Mark Done</b> and <b>Recalculate Estimate</b> (names
286290
from the view&apos;s <code>bulkActions</code>, promoted to their declared object
287291
actions), <b>Export Zip</b> (an <code>execution: &apos;aggregate&apos;</code> def —
288-
ONE dispatch carrying every selected id, #3139) and <b>Legacy Only
289-
Handler</b> (unresolvable, dispatched by name).
292+
ONE dispatch carrying every selected id, #3139). The view also names{' '}
293+
<code>not_declared</code>, which the object does not declare: no button, and one
294+
warning in the browser console.
290295
</p>
291296
</header>
292297

@@ -324,16 +329,7 @@ function Demo() {
324329

325330
createRoot(document.getElementById('root')!).render(
326331
<I18nProvider resources={{ en }} language="en">
327-
{/* A handler registered under a bare NAME — the compat path that legacy
328-
`bulkActions` entries must keep working for. */}
329-
<ActionProvider
330-
handlers={{
331-
legacy_only_handler: async () => {
332-
pushLog({ url: '(runner handler)', recordId: 'all-selected', params: '{}', status: 200 });
333-
return { success: true };
334-
},
335-
}}
336-
>
332+
<ActionProvider>
337333
<Demo />
338334
</ActionProvider>
339335
</I18nProvider>,

0 commit comments

Comments
 (0)