feat: Extract RowActionMenu + add BulkActionBar to ObjectGrid#784
feat: Extract RowActionMenu + add BulkActionBar to ObjectGrid#784
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Extract row action dropdown into RowActionMenu component - Create BulkActionBar component for bulk operations - Integrate both components into ObjectGrid - Pass bulkActions from ListView to ObjectGrid as batchActions - Add 23 unit tests covering all new functionality Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估需要实现任务中的所有功能 |
…add tests - ListView passes onRowSelect to SchemaRenderer so grid selection updates parent - Skip ListView's own bulk action bar in grid view (grid has its own) - Add tests for bulkActions alias and onRowSelect callback - All 25 tests pass; 490 total pass (6 pre-existing failures unchanged) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…s callback Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Completed thorough evaluation. Here's the full feature checklist: RowActions ✅
BulkActions ✅
ListView → Grid sync ✅ (fixed in
Tests ✅ (26 tests, all passing in
All 490 tests pass (6 pre-existing failures unrelated to this PR). |
There was a problem hiding this comment.
Pull request overview
This PR extracts reusable row/bulk action UI from ObjectGrid into standalone components and integrates a grid-level bulk action bar, while updating ListView to pass bulk-action config/selection state appropriately for grid view.
Changes:
- Extracts
RowActionMenu(andformatActionLabel) and introducesBulkActionBarunderpackages/plugin-grid/src/components/. - Integrates
RowActionMenu+BulkActionBarintoObjectGrid, addingselectedRowstracking viaonSelectionChange. - Updates
ListViewto mapbulkActions → batchActionsfor grid view schema and avoid rendering a duplicate bulk bar whencurrentView === 'grid'.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-list/src/ListView.tsx | Maps bulkActions into grid schema as batchActions, passes onRowSelect, and suppresses ListView bulk bar in grid view. |
| packages/plugin-grid/src/index.tsx | Exports new RowActionMenu/BulkActionBar components and their prop types. |
| packages/plugin-grid/src/components/RowActionMenu.tsx | New extracted dropdown menu for per-row actions + shared formatActionLabel. |
| packages/plugin-grid/src/components/BulkActionBar.tsx | New bulk action bar component rendered when rows are selected. |
| packages/plugin-grid/src/tests/row-bulk-actions.test.tsx | Adds unit + integration tests for label formatting, row menu, bulk bar, selection callback propagation, and alias support. |
| packages/plugin-grid/src/ObjectGrid.tsx | Replaces inline dropdown with RowActionMenu, tracks selection locally, and renders BulkActionBar (including bulkActions alias support). |
| import { useGroupedData } from './useGroupedData'; | ||
| import { GroupRow } from './GroupRow'; | ||
| import { useColumnSummary } from './useColumnSummary'; | ||
| import { RowActionMenu, formatActionLabel } from './components/RowActionMenu'; |
There was a problem hiding this comment.
formatActionLabel is imported from ./components/RowActionMenu but not used in this file anymore. This will typically fail lint/typecheck with an unused import. Remove the unused import (or use it if intended).
| import { RowActionMenu, formatActionLabel } from './components/RowActionMenu'; | |
| import { RowActionMenu } from './components/RowActionMenu'; |
| <BulkActionBar | ||
| selectedRows={selectedRows} | ||
| actions={effectiveBulkActions ?? []} | ||
| onAction={(action, rows) => executeAction({ type: action, params: { records: rows } })} | ||
| onClearSelection={() => setSelectedRows([])} | ||
| /> |
There was a problem hiding this comment.
onClearSelection={() => setSelectedRows([])} only clears ObjectGrid's local selectedRows state, but it does not clear the underlying DataTable's internal selection state (checkboxes will remain checked). Consider wiring a real selection reset (e.g., add a clear-selection signal/controlled selection to the DataTable schema, or force a remount/reset of the DataTable selection state) and also notify onRowSelect with an empty array when cleared.
| <BulkActionBar | ||
| selectedRows={selectedRows} | ||
| actions={effectiveBulkActions ?? []} | ||
| onAction={(action, rows) => executeAction({ type: action, params: { records: rows } })} | ||
| onClearSelection={() => setSelectedRows([])} | ||
| /> |
There was a problem hiding this comment.
Same issue as the split-pane path: onClearSelection={() => setSelectedRows([])} hides the BulkActionBar but does not clear the DataTable's actual row selection state. Clearing should reset the table selection itself (and ideally propagate onRowSelect([])), otherwise the UI ends up with checked rows but no bulk bar.
RowActions and BulkActions specs (
rowActions: string[],batchActions: string[]) existed in types but had no standalone components. The row action dropdown was inline in ObjectGrid; bulk action bar only existed in ListView with no grid-level support.New components
RowActionMenu— Extracted from ObjectGrid inline code. Configurable viarowActions,canEdit/canDelete, and action callbacks.BulkActionBar— Shows"N selected"+ action buttons + Clear. Auto-hides when empty. Renders below grid content.ObjectGrid integration
DropdownMenuwith<RowActionMenu>componentselectedRowsstate tracking viaonSelectionChangepassthrough<BulkActionBar>in both normal and split-pane pathsbatchActions(ObjectUI naming) andbulkActions(spec naming)ListView integration
schema.bulkActions→batchActionswhen generating grid view schemaonRowSelect={setSelectedRows}to SchemaRenderer so grid selection changes sync to ListView's statecurrentView === 'grid'to avoid duplicate bars (grid renders its ownBulkActionBar)Usage
Tests
26 new tests covering
formatActionLabel,RowActionMenu(standalone + integrated),BulkActionBar(standalone + integrated),onRowSelectcallback propagation with checkbox interaction, andbulkActionsalias support. All existing grid tests pass unchanged.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.