Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Made WidgetComponentProps generic #1760

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading