Skip to content

Commit 4b4ea70

Browse files
committed
Add support for Deephaven express multi plugin support
1 parent 62fc97c commit 4b4ea70

3 files changed

Lines changed: 30 additions & 67 deletions

File tree

plugins/plotly-express/src/js/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"@deephaven/jsapi-types": "^1.0.0-dev0.39.5",
42-
"@deephaven/test-utils": "0.105.0",
42+
"@deephaven/test-utils": "^1.8.0",
4343
"@types/deep-equal": "^1.0.1",
4444
"@types/plotly.js": "^3.0.0",
4545
"@types/plotly.js-dist-min": "^2.3.1",
@@ -54,17 +54,17 @@
5454
"react-dom": "^17.0.2"
5555
},
5656
"dependencies": {
57-
"@deephaven/chart": "^1.2.0",
58-
"@deephaven/components": "^1.2.0",
59-
"@deephaven/dashboard": "^1.2.0",
60-
"@deephaven/dashboard-core-plugins": "^1.2.0",
57+
"@deephaven/chart": "^1.17.0",
58+
"@deephaven/components": "^1.17.0",
59+
"@deephaven/dashboard": "^1.17.1",
60+
"@deephaven/dashboard-core-plugins": "^1.17.1",
6161
"@deephaven/icons": "^1.2.0",
62-
"@deephaven/jsapi-bootstrap": "1.2.0",
63-
"@deephaven/jsapi-utils": "1.1.1",
64-
"@deephaven/log": "1.1.0",
65-
"@deephaven/plugin": "^1.2.0",
66-
"@deephaven/redux": "^1.2.0",
67-
"@deephaven/utils": "^1.1.0",
62+
"@deephaven/jsapi-bootstrap": "^1.17.0",
63+
"@deephaven/jsapi-utils": "^1.16.0",
64+
"@deephaven/log": "^1.8.0",
65+
"@deephaven/plugin": "^1.17.1",
66+
"@deephaven/redux": "^1.17.0",
67+
"@deephaven/utils": "^1.10.0",
6868
"deep-equal": "^2.2.1",
6969
"memoizee": "^0.4.17",
7070
"nanoid": "^5.0.7",

plugins/plotly-express/src/js/src/DashboardPlugin.tsx

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,13 @@
1-
import { useCallback, useEffect } from 'react';
2-
import { nanoid } from 'nanoid';
3-
import {
4-
DashboardPluginComponentProps,
5-
LayoutUtils,
6-
PanelEvent,
7-
useListener,
8-
} from '@deephaven/dashboard';
9-
import type { dh } from '@deephaven/jsapi-types';
1+
import { useEffect } from 'react';
2+
import { DashboardPluginComponentProps } from '@deephaven/dashboard';
103
import PlotlyExpressChartPanel from './PlotlyExpressChartPanel.js';
11-
import type { PlotlyChartWidget } from './PlotlyExpressChartUtils.js';
124

135
export function DashboardPlugin(
146
props: DashboardPluginComponentProps
157
): JSX.Element | null {
16-
const { id, layout, registerComponent } = props;
17-
18-
const handlePanelOpen = useCallback(
19-
async ({
20-
dragEvent,
21-
fetch,
22-
metadata = {},
23-
panelId = nanoid(),
24-
widget,
25-
}: {
26-
dragEvent?: MouseEvent;
27-
fetch: () => Promise<PlotlyChartWidget>;
28-
metadata?: Record<string, unknown>;
29-
panelId?: string;
30-
widget: dh.ide.VariableDescriptor;
31-
}) => {
32-
const { type, name } = widget;
33-
if (type !== 'deephaven.plot.express.DeephavenFigure') {
34-
return;
35-
}
36-
37-
const config = {
38-
type: 'react-component' as const,
39-
component: 'PlotlyPanel',
40-
props: {
41-
localDashboardId: id,
42-
id: panelId,
43-
metadata: {
44-
...metadata,
45-
...widget,
46-
figure: name,
47-
},
48-
fetch,
49-
},
50-
title: name ?? undefined,
51-
id: panelId,
52-
};
53-
54-
const { root } = layout;
55-
LayoutUtils.openComponent({ root, config, dragEvent });
56-
},
57-
[id, layout]
58-
);
8+
const { registerComponent } = props;
599

10+
// Register the PlotlyPanel for legacy panels created before the WidgetPlugin was being used.
6011
useEffect(
6112
function registerComponentsAndReturnCleanup() {
6213
const cleanups = [
@@ -69,8 +20,6 @@ export function DashboardPlugin(
6920
[registerComponent]
7021
);
7122

72-
useListener(layout.eventHub, PanelEvent.OPEN, handlePanelOpen);
73-
7423
return null;
7524
}
7625

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
import { PluginType } from '@deephaven/plugin';
12
import { PlotlyExpressPlugin } from './PlotlyExpressPlugin.js';
3+
import { DashboardPlugin } from './DashboardPlugin.js';
24

35
// Export legacy dashboard plugin as named export for backwards compatibility
46
export * from './DashboardPlugin.js';
57
export * from './PlotlyExpressChartModel.js';
68
export * from './PlotlyExpressChartUtils.js';
79

8-
export default PlotlyExpressPlugin;
10+
const PlotlyExpressDashboardPlugin = {
11+
name: '@deephaven/js-plugin-plotly-express.DashboardPlugin',
12+
type: PluginType.DASHBOARD_PLUGIN,
13+
component: DashboardPlugin,
14+
};
15+
16+
const PlotlyExpressMultiPlugin = {
17+
name: '@deephaven/js-plugin-plotly-express',
18+
type: PluginType.MULTI_PLUGIN,
19+
plugins: [PlotlyExpressPlugin, PlotlyExpressDashboardPlugin],
20+
};
21+
22+
export default PlotlyExpressMultiPlugin;

0 commit comments

Comments
 (0)