Skip to content

Commit

Permalink
Made WidgetComponentProps generic
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Jan 29, 2024
1 parent f0ae055 commit f087c82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/dashboard-core-plugins/src/GridPluginConfig.ts
Original file line number Diff line number Diff line change
@@ -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<Table> = {
name: 'IrisGridPanel',
title: 'Table',
type: PluginType.WIDGET_PLUGIN,
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@deephaven/iris-grid';

export function GridWidgetPlugin(
props: WidgetComponentProps
props: WidgetComponentProps<Table>
): JSX.Element | null {
const dh = useApi();
const [model, setModel] = useState<IrisGridModel>();
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin/src/PluginTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export function isDashboardPlugin(
return 'type' in plugin && plugin.type === PluginType.DASHBOARD_PLUGIN;
}

export interface WidgetComponentProps {
fetch: () => Promise<unknown>;
export interface WidgetComponentProps<T = unknown> {
fetch: () => Promise<T>;
}

export interface WidgetPanelProps extends WidgetComponentProps {
Expand All @@ -120,7 +120,7 @@ export interface WidgetPanelProps extends WidgetComponentProps {
glEventHub: EventEmitter;
}

export interface WidgetPlugin extends Plugin {
export interface WidgetPlugin<T = unknown> extends Plugin {
type: typeof PluginType.WIDGET_PLUGIN;
/**
* The component that can render the widget types the plugin supports.
Expand All @@ -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<WidgetComponentProps>;
component: React.ComponentType<WidgetComponentProps<T>>;

/**
* The server widget types that this plugin will handle.
Expand Down

0 comments on commit f087c82

Please sign in to comment.