Skip to content

Commit ac40c6f

Browse files
authored
fix: Made some plugin types generic (#1769)
I missed making `WidgetPanelProps` generic in the last PR which is needed to version bump plotly express. resolves #1759
1 parent 1e631a4 commit ac40c6f

8 files changed

Lines changed: 15 additions & 19 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async function createChartModel(
114114
}
115115

116116
export const ChartPanelPlugin = forwardRef(
117-
(props: WidgetPanelProps, ref: React.Ref<ChartPanel>) => {
117+
(props: WidgetPanelProps<Figure>, ref: React.Ref<ChartPanel>) => {
118118
const dh = useApi();
119119
const chartTheme = useChartTheme();
120120
const connection = useConnection();
@@ -139,7 +139,7 @@ export const ChartPanelPlugin = forwardRef(
139139
chartTheme,
140140
connection,
141141
metadata as ChartPanelMetadata,
142-
fetch as () => Promise<Figure>,
142+
fetch,
143143
panelState
144144
);
145145
},

packages/dashboard-core-plugins/src/ChartPluginConfig.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 { vsGraph } from '@deephaven/icons';
3+
import type { Figure } from '@deephaven/jsapi-types';
34
import { ChartWidgetPlugin } from './ChartWidgetPlugin';
45
import { ChartPanelPlugin } from './ChartPanelPlugin';
56

6-
const ChartPluginConfig: WidgetPlugin = {
7+
const ChartPluginConfig: WidgetPlugin<Figure> = {
78
name: 'ChartPanel',
89
title: 'Chart',
910
type: PluginType.WIDGET_PLUGIN,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Figure } from '@deephaven/jsapi-types';
1010
import { type WidgetComponentProps } from '@deephaven/plugin';
1111

1212
export function ChartWidgetPlugin(
13-
props: WidgetComponentProps
13+
props: WidgetComponentProps<Figure>
1414
): JSX.Element | null {
1515
const dh = useApi();
1616
const chartTheme = useChartTheme();

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import ConnectedIrisGridPanel, {
77
} from './panels/IrisGridPanel';
88

99
export const GridPanelPlugin = forwardRef(
10-
(props: WidgetPanelProps, ref: React.Ref<IrisGridPanel>) => {
10+
(props: WidgetPanelProps<Table>, ref: React.Ref<IrisGridPanel>) => {
1111
const { localDashboardId, fetch } = props;
12-
const hydratedProps = useHydrateGrid(
13-
fetch as () => Promise<Table>,
14-
localDashboardId
15-
);
12+
const hydratedProps = useHydrateGrid(fetch, localDashboardId);
1613

1714
// eslint-disable-next-line react/jsx-props-no-spreading
1815
return <ConnectedIrisGridPanel ref={ref} {...props} {...hydratedProps} />;

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import { PandasPanel } from './panels';
55
import useHydrateGrid from './useHydrateGrid';
66

77
export const PandasPanelPlugin = forwardRef(
8-
(props: WidgetPanelProps, ref: React.Ref<PandasPanel>) => {
8+
(props: WidgetPanelProps<Table>, ref: React.Ref<PandasPanel>) => {
99
const { localDashboardId, fetch } = props;
10-
const hydratedProps = useHydrateGrid(
11-
fetch as () => Promise<Table>,
12-
localDashboardId
13-
);
10+
const hydratedProps = useHydrateGrid(fetch, localDashboardId);
1411

1512
return (
1613
// eslint-disable-next-line react/jsx-props-no-spreading

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

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { LoadingOverlay } from '@deephaven/components';
1010
import { PandasReloadButton } from './panels/PandasReloadButton';
1111

1212
export function PandasWidgetPlugin(
13-
props: WidgetComponentProps
13+
props: WidgetComponentProps<Table>
1414
): JSX.Element | null {
1515
const dh = useApi();
1616
const [model, setModel] = useState<IrisGridModel>();
@@ -20,7 +20,7 @@ export function PandasWidgetPlugin(
2020
const { fetch } = props;
2121

2222
const makeModel = useCallback(async () => {
23-
const table = (await fetch()) as unknown as Table;
23+
const table = await fetch();
2424
return IrisGridModelFactory.makeModel(dh, table);
2525
}, [dh, fetch]);
2626

packages/plugin/src/PluginTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export interface WidgetComponentProps<T = unknown> {
109109
fetch: () => Promise<T>;
110110
}
111111

112-
export interface WidgetPanelProps extends WidgetComponentProps {
112+
export interface WidgetPanelProps<T = unknown> extends WidgetComponentProps<T> {
113113
metadata?: {
114114
id?: string;
115115
name?: string;
@@ -154,7 +154,7 @@ export interface WidgetPlugin<T = unknown> extends Plugin {
154154
*
155155
* See @deephaven/dashboard-core-plugins WidgetPanel for the component that should be used here.
156156
*/
157-
panelComponent?: React.ComponentType<WidgetPanelProps>;
157+
panelComponent?: React.ComponentType<WidgetPanelProps<T>>;
158158

159159
/**
160160
* The icon to display next to the console button.

0 commit comments

Comments
 (0)