Skip to content

Commit 771f24c

Browse files
committed
Register as a WidgetDashboard type to allow opening widgets as dashboards
- So we can still open widgets as dashboards from code studios
1 parent 209e903 commit 771f24c

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

plugins/ui/src/js/src/DashboardPlugin.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import PortalPanel from './layout/PortalPanel';
2323
import PortalPanelManager from './layout/PortalPanelManager';
2424
import DashboardWidgetHandler from './widget/DashboardWidgetHandler';
2525
import { usePanelId } from './layout/ReactPanelContext';
26-
27-
const PLUGIN_NAME = '@deephaven/js-plugin-ui.DashboardPlugin';
26+
import { DASHBOARD_PLUGIN_NAME } from './UIWidgetPlugin';
2827

2928
const log = Log.module('@deephaven/js-plugin-ui.DashboardPlugin');
3029

@@ -66,7 +65,7 @@ function InnerDashboardPlugin(
6665
const { id, layout } = props;
6766
const [pluginData, setPluginData] = useDashboardPluginData(
6867
id,
69-
PLUGIN_NAME
68+
DASHBOARD_PLUGIN_NAME
7069
) as unknown as [DashboardPluginData, (data: DashboardPluginData) => void];
7170
const [initialPluginData] = useState(pluginData);
7271

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1+
import type { WidgetDescriptor } from '@deephaven/dashboard';
12
import { type WidgetPlugin, PluginType } from '@deephaven/plugin';
23
import { vsGraph } from '@deephaven/icons';
34
import type { dh } from '@deephaven/jsapi-types';
45
import { DASHBOARD_ELEMENT, WIDGET_ELEMENT } from './widget/WidgetUtils';
56
import PortalPanel from './layout/PortalPanel';
67
import UIWidget from './UIWidget';
78

9+
export const DASHBOARD_PLUGIN_NAME = '@deephaven/js-plugin-ui.DashboardPlugin';
10+
811
/**
912
* Plugin for rendering deephaven.ui widgets, such as Element or Dashboard.
1013
* PortalPanels are registered as they are used by the legacy DashboardPlugin to render elements.
1114
*/
12-
export const UIWidgetPlugin: WidgetPlugin<dh.Widget> = {
15+
export const UIWidgetPlugin: WidgetPlugin<dh.Widget> & {
16+
// TODO: Remove these extra types when it's updated in web-client-ui
17+
dashboardTypes: string[];
18+
createDashboardPayload: (widget: WidgetDescriptor) => unknown;
19+
} = {
1320
name: '@deephaven/js-plugin-ui',
1421
type: PluginType.WIDGET_PLUGIN,
1522
supportedTypes: [WIDGET_ELEMENT, DASHBOARD_ELEMENT, PortalPanel.displayName],
1623
component: UIWidget,
1724
icon: vsGraph,
25+
26+
dashboardTypes: [DASHBOARD_ELEMENT],
27+
createDashboardPayload: (widget: WidgetDescriptor) => ({
28+
pluginId: DASHBOARD_PLUGIN_NAME,
29+
title: widget?.name ?? 'Untitled',
30+
data: { openWidgets: { [DASHBOARD_PLUGIN_NAME]: { descriptor: widget } } },
31+
}),
1832
};
1933

2034
export default UIWidgetPlugin;

0 commit comments

Comments
 (0)