-
Notifications
You must be signed in to change notification settings - Fork 17
feat: DH-21757: WidgetPlugin support in deephaven.ui #1341
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
Open
mofojed
wants to merge
31
commits into
deephaven:main
Choose a base branch
from
mofojed:DH-21757-resolve-deephaven.ui-widget-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c68e7ad
feat: DH-21757: WidgetPlugin support in deephaven.ui
mofojed 16c6325
Update types, remove duplicate types
mofojed fd4c6f9
Cleanup after self-review
mofojed d2b4b1c
fix: update unit tests for WidgetPlugin changes
mofojed 7258fab
Fix up styling fix up tests
mofojed 022311d
fix: update e2e selectors from .dh-react-panel to .dh-panel.widget-lo…
mofojed 1a587ce
fix: panel padding, error display, and nested dashboard padding
mofojed 2ed7530
package-lock updates
mofojed 5e71959
WIP update snapshots
mofojed 7303d1b
fix: avoid nested panel tab when widget is a single ui.panel
mofojed d4f2271
Update some more snapshots...
mofojed def07ab
WIP show a loading spinner when loading
mofojed 5206dd3
Fix jest config
mofojed 3c12046
fix: provide WidgetStatusContext in DocumentHandler tests
mofojed 8985543
Change up how things were named...
mofojed 1cd9196
Remove updated snapshots...
mofojed 5dc2ae0
Get rid of dh-react-panel css on the defaultpanelcontent
mofojed 0cf90fb
Clean up some scss
mofojed eca77e8
Clean up some of the test selectors
mofojed 676c9aa
Update ui loading spec
mofojed 1fe9308
Update a test that was referencing wrong panel type
mofojed 2c00340
Clean up some more tests
mofojed 563f9d9
Fix up wiring for the render all ui components tests
mofojed 3219d0a
Update snapshots for multi-panel
mofojed c721b22
Update nested dashboard snapshots with correct active tab indicator
mofojed e901a09
Merge remote-tracking branch 'origin/main' into DH-21757-resolve-deep…
mofojed b6ac649
Fix issue with toggle table snapshots
mofojed 2364957
docs: add show_headers example to dashboard docs
mofojed f0dbf6f
Update architecture docs with some details
mofojed 2a26402
docs: add ui.resolve nested panel example to URI docs
mofojed b5987f8
Add docs snapshots
mofojed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
1 change: 1 addition & 0 deletions
1
plugins/ui/docs/snapshots/1d8b6032316168e0cd14ff061a00e0d5.json
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"file":"components/dashboard.md","objects":{"dash_no_headers":{"type":"deephaven.ui.Dashboard","data":{"document":{"props":{"showHeaders":false,"children":{"__dhElemName":"deephaven.ui.components.Row","props":{"children":[{"__dhElemName":"deephaven.ui.components.Panel","props":{"title":"A","direction":"column","alignItems":"start","gap":"size-100","overflow":"auto","padding":"size-100","children":"A"}},{"__dhElemName":"deephaven.ui.components.Panel","props":{"title":"B","direction":"column","alignItems":"start","gap":"size-100","overflow":"auto","padding":"size-100","children":"B"}}]}}},"__dhElemName":"deephaven.ui.components.Dashboard"},"state":"{}"}}}} |
1 change: 1 addition & 0 deletions
1
plugins/ui/docs/snapshots/5ef4aa2cf2eb0aa5430fcfe3100c6ff7.json
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"file":"components/uri.md","objects":{"remote_widget":{"type":"deephaven.ui.Element","data":{"document":{"props":{"uri":"pq://DataServiceQuery/scope/my_widget"},"__dhElemName":"deephaven.ui.elements.UriElement"},"state":"{}"}},"my_dashboard":{"type":"deephaven.ui.Dashboard","data":{"document":{"props":{"showHeaders":true,"children":{"__dhElemName":"__main__.cross_query_dashboard","props":{"children":{"__dhElemName":"deephaven.ui.components.Row","props":{"children":[{"__dhElemName":"deephaven.ui.components.Panel","props":{"title":"Remote Widget","direction":"column","alignItems":"start","gap":"size-100","overflow":"auto","padding":"size-100","children":{"__dhElemName":"deephaven.ui.elements.UriElement","props":{"uri":"pq://DataServiceQuery/scope/my_widget"}}}},{"__dhElemName":"deephaven.ui.components.Panel","props":{"title":"Local","direction":"column","alignItems":"start","gap":"size-100","overflow":"auto","padding":"size-100","children":"Local Content"}}]}}}}},"__dhElemName":"deephaven.ui.components.Dashboard"},"state":"{}"}}}} |
This file contains hidden or 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 hidden or 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 hidden or 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,8 +1,12 @@ | ||
| // Mock @deephaven/plugin package | ||
| const React = require('react'); | ||
| const PluginActual = jest.requireActual('@deephaven/plugin'); | ||
|
|
||
| module.exports = { | ||
| ...PluginActual, | ||
| useDashboardPlugins: jest.fn(() => []), | ||
| // Mock usePersistentState to behave like useState. | ||
| // The real implementation requires FiberProvider which is internal to Dashboard. | ||
| usePersistentState: (initialState, _config) => React.useState(initialState), | ||
| __esModule: true, | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React, { useCallback, useMemo } from 'react'; | ||
| import { type UriVariableDescriptor } from '@deephaven/jsapi-bootstrap'; | ||
| import type { dh } from '@deephaven/jsapi-types'; | ||
| import { | ||
| usePersistentState, | ||
| type WidgetComponentProps, | ||
| } from '@deephaven/plugin'; | ||
| import { nanoid } from 'nanoid'; | ||
| import { type WidgetData, type WidgetDataUpdate } from './widget/WidgetTypes'; | ||
| import WidgetHandler from './widget/WidgetHandler'; | ||
|
|
||
| type UIComponentProps = WidgetComponentProps<dh.Widget> & { | ||
| // Might be loading a URI resolved widget... | ||
| uri?: UriVariableDescriptor; | ||
| }; | ||
|
|
||
| export function UIComponent(props: UIComponentProps): JSX.Element | null { | ||
| const { metadata: widgetDescriptor, uri, __dhId } = props; | ||
|
|
||
| const [widgetData, setWidgetData] = usePersistentState< | ||
| WidgetData | undefined | ||
| >(undefined, { type: 'UIComponentWidgetData', version: 1 }); | ||
|
|
||
| const id = useMemo( | ||
| () => __dhId ?? widgetDescriptor?.id ?? nanoid(), | ||
| [__dhId, widgetDescriptor] | ||
| ); | ||
|
|
||
| const handleDataChange = useCallback( | ||
| (data: WidgetDataUpdate) => { | ||
| setWidgetData(oldData => ({ ...oldData, ...data })); | ||
| }, | ||
| [setWidgetData] | ||
| ); | ||
|
|
||
| const descriptor = uri ?? widgetDescriptor; | ||
| if (descriptor == null) { | ||
| throw new Error('No widget descriptor'); | ||
| } | ||
|
|
||
| const renderEmptyDocument = useCallback( | ||
| () => ( | ||
| // Single-panel or first-time-load case. Returning a fragment causes | ||
| // `getRootChildren` to wrap it in a `DefaultPanelContent`, which renders | ||
| // a `LoadingOverlay` while the widget status is `loading`. | ||
| // eslint-disable-next-line react/jsx-no-useless-fragment | ||
| <></> | ||
| ), | ||
| // We only want to update this callback when the descriptor changes, not | ||
| // every time the widgetData (panelIds) changes. | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [descriptor] | ||
| ); | ||
|
|
||
| return ( | ||
| <WidgetHandler | ||
| widgetDescriptor={descriptor} | ||
| initialData={widgetData} | ||
| onDataChange={handleDataChange} | ||
| renderEmptyDocument={renderEmptyDocument} | ||
| id={id} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default UIComponent; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { dh } from '@deephaven/jsapi-types'; | ||
| import { type WidgetComponentProps } from '@deephaven/plugin'; | ||
| import UIComponent from './UIComponent'; | ||
| import PortalPanel from './layout/PortalPanel'; | ||
|
|
||
| type UIWidgetProps = WidgetComponentProps<dh.Widget>; | ||
|
|
||
| export function UIWidget(props: UIWidgetProps): JSX.Element | null { | ||
| const { metadata: widgetDescriptor } = props; | ||
| if (widgetDescriptor?.type === PortalPanel.displayName) { | ||
| // PortalPanel was used by the legacy DashboardPlugin to render elements. We just ignore them here. | ||
| return null; | ||
| } | ||
|
|
||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| return <UIComponent {...props} />; | ||
| } | ||
|
|
||
| export default UIWidget; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { type WidgetPlugin, PluginType } from '@deephaven/plugin'; | ||
| import { vsGraph } from '@deephaven/icons'; | ||
| import type { dh } from '@deephaven/jsapi-types'; | ||
| import { DASHBOARD_ELEMENT, WIDGET_ELEMENT } from './widget/WidgetUtils'; | ||
| import PortalPanel from './layout/PortalPanel'; | ||
| import UIWidget from './UIWidget'; | ||
|
|
||
| export const UIWidgetPlugin: WidgetPlugin<dh.Widget> = { | ||
| name: '@deephaven/js-plugin-ui', | ||
| type: PluginType.WIDGET_PLUGIN, | ||
| supportedTypes: [WIDGET_ELEMENT, DASHBOARD_ELEMENT, PortalPanel.displayName], | ||
| component: UIWidget, | ||
| icon: vsGraph, | ||
| }; | ||
|
|
||
| export default UIWidgetPlugin; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added stack caveat, I assume that's what would happen.