forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Convert DashboardPlugins to WidgetPlugins (deephaven#1598)
Fixes deephaven#1573
- Loading branch information
1 parent
e0bbdf0
commit a260842
Showing
12 changed files
with
137 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { PluginType, DashboardPlugin } from '@deephaven/plugin'; | ||
import { PluginType, type WidgetPlugin } from '@deephaven/plugin'; | ||
import { vsGraph } from '@deephaven/icons'; | ||
import ChartPlugin from './ChartPlugin'; | ||
|
||
const ChartPluginConfig: DashboardPlugin = { | ||
name: 'ChartPlugin', | ||
type: PluginType.DASHBOARD_PLUGIN, | ||
const ChartPluginConfig: WidgetPlugin = { | ||
name: 'ChartPanel', | ||
title: 'Chart', | ||
type: PluginType.WIDGET_PLUGIN, | ||
component: ChartPlugin, | ||
panelComponent: ChartPlugin, | ||
supportedTypes: 'Figure', | ||
icon: vsGraph, | ||
}; | ||
|
||
export default ChartPluginConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
import { useMemo } from 'react'; | ||
import { | ||
assertIsDashboardPluginProps, | ||
DashboardPluginComponentProps, | ||
useDashboardPanel, | ||
} from '@deephaven/dashboard'; | ||
import { useApi } from '@deephaven/jsapi-bootstrap'; | ||
import { IrisGridPanel } from './panels'; | ||
import { forwardRef, useMemo } from 'react'; | ||
import { type WidgetComponentProps } from '@deephaven/plugin'; | ||
import { type DashboardPanelProps } from '@deephaven/dashboard'; | ||
import useHydrateGrid from './useHydrateGrid'; | ||
import ConnectedIrisGridPanel, { | ||
IrisGridPanelProps, | ||
type IrisGridPanel, | ||
} from './panels/IrisGridPanel'; | ||
|
||
export function GridPlugin( | ||
props: DashboardPluginComponentProps | ||
): JSX.Element | null { | ||
assertIsDashboardPluginProps(props); | ||
const dh = useApi(); | ||
const hydrate = useHydrateGrid(); | ||
export const GridPlugin = forwardRef( | ||
(props: WidgetComponentProps, ref: React.Ref<IrisGridPanel>) => { | ||
const hydrate = useHydrateGrid< | ||
DashboardPanelProps & Pick<IrisGridPanelProps, 'panelState'> | ||
>(); | ||
const { localDashboardId } = props; | ||
const hydratedProps = useMemo( | ||
() => | ||
hydrate( | ||
props as WidgetComponentProps & | ||
Pick<IrisGridPanelProps, 'panelState'>, | ||
localDashboardId | ||
), | ||
[hydrate, props, localDashboardId] | ||
); | ||
|
||
const supportedTypes = useMemo( | ||
() => [ | ||
dh.VariableType.TABLE, | ||
dh.VariableType.TREETABLE, | ||
dh.VariableType.HIERARCHICALTABLE, | ||
], | ||
[dh] | ||
); | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <ConnectedIrisGridPanel ref={ref} {...hydratedProps} />; | ||
} | ||
); | ||
|
||
useDashboardPanel({ | ||
dashboardProps: props, | ||
componentName: IrisGridPanel.COMPONENT, | ||
component: IrisGridPanel, | ||
supportedTypes, | ||
hydrate, | ||
}); | ||
|
||
return null; | ||
} | ||
GridPlugin.displayName = 'GridPlugin'; | ||
|
||
export default GridPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { PluginType, DashboardPlugin } from '@deephaven/plugin'; | ||
import { PluginType, type WidgetPlugin } from '@deephaven/plugin'; | ||
import { dhTable } from '@deephaven/icons'; | ||
import GridPlugin from './GridPlugin'; | ||
|
||
const GridPluginConfig: DashboardPlugin = { | ||
name: 'GridPlugin', | ||
type: PluginType.DASHBOARD_PLUGIN, | ||
const GridPluginConfig: WidgetPlugin = { | ||
name: 'IrisGridPanel', | ||
title: 'Table', | ||
type: PluginType.WIDGET_PLUGIN, | ||
component: GridPlugin, | ||
panelComponent: GridPlugin, | ||
supportedTypes: ['Table', 'TreeTable', 'HierarchicalTable'], | ||
icon: dhTable, | ||
}; | ||
|
||
export default GridPluginConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,6 @@ export function WrapWidgetPlugin( | |
{...props} | ||
/> | ||
)} | ||
) | ||
</WidgetPanel> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.