Skip to content

Commit 138c165

Browse files
Copilothotlong
andcommitted
fix: address code review feedback - consistent data checking, add documentation comments
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b4cb2bd commit 138c165

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

ROADMAP.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,14 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
470470
- [x] I18nLabel resolution: `WidgetConfigPanel` pre-processes `title` and `description` config values via `resolveLabel()` to prevent `[object Object]` display
471471
- [x] `DashboardRenderer`: widget description rendered in card headers with `line-clamp-2`; I18nLabel resolved via `resolveLabel()`
472472
- [x] `ObjectPivotTable`: new async-aware pivot wrapper (following ObjectChart pattern) — skeleton loading, error state, no-data-source message, empty state delegation to PivotTable
473+
- [x] `ObjectDataTable`: new async-aware table wrapper — skeleton loading, error state, empty state, auto-column derivation from fetched data keys
473474
- [x] `DashboardRenderer`: pivot widgets with `objectName` or `provider: 'object'` routed to `object-pivot` type (ObjectPivotTable) for async data loading
475+
- [x] `DashboardRenderer`: table widgets with `objectName` or `provider: 'object'` routed to `object-data-table` type (ObjectDataTable) for async data loading
474476
- [x] `DashboardRenderer`: grid column clamping — widget `layout.w` clamped to `Math.min(w, columns)` preventing layout overflow
475477
- [x] `MetricWidget`: overflow protection — `overflow-hidden` on Card, `truncate` on label/value/description, `shrink-0` on icon/trend
476478
- [x] `PivotTable`: friendly empty state with grid icon + "No data available" message instead of empty table body
477479
- [x] `PivotTable`: improved total/subtotal row styling — `bg-muted/40` on tfoot, `bg-muted/20` on row-total column, `font-bold` on grand total
478-
- [x] Add 23 new Vitest tests: ObjectPivotTable (8), context-aware sections (6), I18nLabel resolution (2), pivot type option (1), pivot object binding (1), widget description rendering (2), grid column clamping (1), pivot empty state (2)
480+
- [x] Add 29 new Vitest tests: ObjectPivotTable (8), ObjectDataTable (6), context-aware sections (6), I18nLabel resolution (2), pivot type option (1), pivot object binding (1), widget description rendering (2), grid column clamping (1), pivot empty state (2)
479481

480482
### P1.11 Console — Schema-Driven View Config Panel Migration
481483

packages/plugin-dashboard/src/ObjectDataTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ export const ObjectDataTable: React.FC<ObjectDataTableProps> = ({ schema, dataSo
103103
const derivedColumns = useMemo(() => {
104104
if (schema.columns && schema.columns.length > 0) return schema.columns;
105105
if (finalData.length === 0) return [];
106+
// Exclude internal/private fields (prefixed with '_') from auto-derived columns
106107
const keys = Object.keys(finalData[0]).filter(k => !k.startsWith('_'));
108+
// Convert camelCase keys to human-readable headers (e.g. firstName → First Name)
107109
return keys.map(k => ({
108110
header: k.charAt(0).toUpperCase() + k.slice(1).replace(/([A-Z])/g, ' $1'),
109111
accessorKey: k,

packages/plugin-dashboard/src/ObjectPivotTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const ObjectPivotTable: React.FC<ObjectPivotTableProps> = ({ schema, data
7979
}
8080
};
8181

82-
if (schema.objectName && !boundData && !schema.data?.length) {
82+
if (schema.objectName && !boundData && (!schema.data || schema.data.length === 0)) {
8383
fetchData();
8484
}
8585

0 commit comments

Comments
 (0)