Skip to content

Commit 8cb0a10

Browse files
authored
fix: Made WidgetComponentProps generic (#1760)
Made `PluginType` generic. This fixes a breaking change that impacts `PlotlyExpressChartPanel` and `PlotlyExpressChart` in the plugins repo so that our next version bump will be cleaner. fixes #1759
1 parent f0ae055 commit 8cb0a10

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

packages/dashboard-core-plugins/src/GridPluginConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { PluginType, type WidgetPlugin } from '@deephaven/plugin';
22
import { dhTable } from '@deephaven/icons';
3+
import { Table } from '@deephaven/jsapi-types';
34
import { GridWidgetPlugin } from './GridWidgetPlugin';
45
import { GridPanelPlugin } from './GridPanelPlugin';
56

6-
const GridPluginConfig: WidgetPlugin = {
7+
const GridPluginConfig: WidgetPlugin<Table> = {
78
name: 'IrisGridPanel',
89
title: 'Table',
910
type: PluginType.WIDGET_PLUGIN,

packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '@deephaven/iris-grid';
1010

1111
export function GridWidgetPlugin(
12-
props: WidgetComponentProps
12+
props: WidgetComponentProps<Table>
1313
): JSX.Element | null {
1414
const dh = useApi();
1515
const [model, setModel] = useState<IrisGridModel>();
@@ -19,7 +19,7 @@ export function GridWidgetPlugin(
1919
useEffect(() => {
2020
let cancelled = false;
2121
async function init() {
22-
const table = (await fetch()) as unknown as Table;
22+
const table = await fetch();
2323
const newModel = await IrisGridModelFactory.makeModel(dh, table);
2424
if (!cancelled) {
2525
setModel(newModel);

packages/plugin/src/PluginTypes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ export function isDashboardPlugin(
105105
return 'type' in plugin && plugin.type === PluginType.DASHBOARD_PLUGIN;
106106
}
107107

108-
export interface WidgetComponentProps {
109-
fetch: () => Promise<unknown>;
108+
export interface WidgetComponentProps<T = unknown> {
109+
fetch: () => Promise<T>;
110110
}
111111

112112
export interface WidgetPanelProps extends WidgetComponentProps {
@@ -120,7 +120,7 @@ export interface WidgetPanelProps extends WidgetComponentProps {
120120
glEventHub: EventEmitter;
121121
}
122122

123-
export interface WidgetPlugin extends Plugin {
123+
export interface WidgetPlugin<T = unknown> extends Plugin {
124124
type: typeof PluginType.WIDGET_PLUGIN;
125125
/**
126126
* The component that can render the widget types the plugin supports.
@@ -129,7 +129,7 @@ export interface WidgetPlugin extends Plugin {
129129
* then `panelComponent` will be used instead.
130130
* The component will be wrapped in a default panel if `panelComponent` is not provided.
131131
*/
132-
component: React.ComponentType<WidgetComponentProps>;
132+
component: React.ComponentType<WidgetComponentProps<T>>;
133133

134134
/**
135135
* The server widget types that this plugin will handle.

0 commit comments

Comments
 (0)