Skip to content

Commit 0c3236b

Browse files
Copilothotlong
andcommitted
fix: resolve TypeScript errors in plugin-dashboard and plugin-grid
- Add `filter` to isObjectProvider type guard return type - Add `searchable` and `pagination` to DashboardWidgetSchema - Annotate normalizedConfig as Record<string,any> to preserve index signature - Resolve I18nLabel col.label to string in ObjectGrid ListColumn path Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 88aeae3 commit 0c3236b

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/plugin-dashboard/src/WidgetConfigPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export function WidgetConfigPanel({
509509
availableFields,
510510
}: WidgetConfigPanelProps) {
511511
// Pre-process config to resolve any I18nLabel values for title/description
512-
const normalizedConfig = React.useMemo(() => ({
512+
const normalizedConfig: Record<string, any> = React.useMemo(() => ({
513513
...config,
514514
title: typeof config.title === 'object' ? resolveLabel(config.title) : config.title,
515515
description: typeof config.description === 'object' ? resolveLabel(config.description) : config.description,

packages/plugin-dashboard/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
/** Returns true when the widget data config uses provider: 'object' (async data source). */
10-
export function isObjectProvider(widgetData: unknown): widgetData is { provider: 'object'; object?: string; aggregate?: any } {
10+
export function isObjectProvider(widgetData: unknown): widgetData is { provider: 'object'; object?: string; aggregate?: any; filter?: any } {
1111
return (
1212
widgetData != null &&
1313
typeof widgetData === 'object' &&

packages/plugin-grid/src/ObjectGrid.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ export const ObjectGrid: React.FC<ObjectGridProps> = ({
619619
return (cols as ListColumn[])
620620
.filter((col) => col?.field && typeof col.field === 'string' && !col.hidden)
621621
.map((col, colIndex) => {
622-
const rawHeader = col.label || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
622+
const rawLabel = col.label;
623+
const rawHeader = (typeof rawLabel === 'string' ? rawLabel : typeof rawLabel === 'object' && rawLabel ? (rawLabel as any).defaultValue || (rawLabel as any).key : null) || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
623624
const header = schema.objectName ? resolveFieldLabel(schema.objectName, col.field, rawHeader) : rawHeader;
624625

625626
// Build custom cell renderer based on column configuration

packages/types/src/complex.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,16 @@ export interface DashboardWidgetSchema {
544544
* Aligned with @objectstack/spec DashboardWidgetSchema.responsive.
545545
*/
546546
responsive?: any;
547+
/**
548+
* Enable search input for table-type widgets.
549+
* @default false
550+
*/
551+
searchable?: boolean;
552+
/**
553+
* Enable pagination for table-type widgets.
554+
* @default false
555+
*/
556+
pagination?: boolean;
547557
/**
548558
* ARIA accessibility attributes.
549559
* Aligned with @objectstack/spec AriaPropsSchema.

0 commit comments

Comments
 (0)