From f087c82c9cd9ee2c198bb7693c19a71ed2e0326e Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Fri, 19 Jan 2024 13:27:02 -0600 Subject: [PATCH] Made WidgetComponentProps generic #1728 #1728 --- packages/dashboard-core-plugins/src/GridPluginConfig.ts | 3 ++- packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx | 4 ++-- packages/plugin/src/PluginTypes.ts | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/dashboard-core-plugins/src/GridPluginConfig.ts b/packages/dashboard-core-plugins/src/GridPluginConfig.ts index 0627464a82..81dd00104c 100644 --- a/packages/dashboard-core-plugins/src/GridPluginConfig.ts +++ b/packages/dashboard-core-plugins/src/GridPluginConfig.ts @@ -1,9 +1,10 @@ import { PluginType, type WidgetPlugin } from '@deephaven/plugin'; import { dhTable } from '@deephaven/icons'; +import { Table } from '@deephaven/jsapi-types'; import { GridWidgetPlugin } from './GridWidgetPlugin'; import { GridPanelPlugin } from './GridPanelPlugin'; -const GridPluginConfig: WidgetPlugin = { +const GridPluginConfig: WidgetPlugin = { name: 'IrisGridPanel', title: 'Table', type: PluginType.WIDGET_PLUGIN, diff --git a/packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx b/packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx index f53a920160..119f128292 100644 --- a/packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx +++ b/packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx @@ -9,7 +9,7 @@ import { } from '@deephaven/iris-grid'; export function GridWidgetPlugin( - props: WidgetComponentProps + props: WidgetComponentProps
): JSX.Element | null { const dh = useApi(); const [model, setModel] = useState(); @@ -19,7 +19,7 @@ export function GridWidgetPlugin( useEffect(() => { let cancelled = false; async function init() { - const table = (await fetch()) as unknown as Table; + const table = await fetch(); const newModel = await IrisGridModelFactory.makeModel(dh, table); if (!cancelled) { setModel(newModel); diff --git a/packages/plugin/src/PluginTypes.ts b/packages/plugin/src/PluginTypes.ts index 1588a60259..8738fbe983 100644 --- a/packages/plugin/src/PluginTypes.ts +++ b/packages/plugin/src/PluginTypes.ts @@ -105,8 +105,8 @@ export function isDashboardPlugin( return 'type' in plugin && plugin.type === PluginType.DASHBOARD_PLUGIN; } -export interface WidgetComponentProps { - fetch: () => Promise; +export interface WidgetComponentProps { + fetch: () => Promise; } export interface WidgetPanelProps extends WidgetComponentProps { @@ -120,7 +120,7 @@ export interface WidgetPanelProps extends WidgetComponentProps { glEventHub: EventEmitter; } -export interface WidgetPlugin extends Plugin { +export interface WidgetPlugin extends Plugin { type: typeof PluginType.WIDGET_PLUGIN; /** * The component that can render the widget types the plugin supports. @@ -129,7 +129,7 @@ export interface WidgetPlugin extends Plugin { * then `panelComponent` will be used instead. * The component will be wrapped in a default panel if `panelComponent` is not provided. */ - component: React.ComponentType; + component: React.ComponentType>; /** * The server widget types that this plugin will handle.