-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: Multiple dashboards #1714
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
900a604
WIP kludge
mattrunyon 36257f9
WIP: Redux mostly working
mattrunyon ace73bb
Cleanup
mattrunyon cb2b321
More cleanup
mattrunyon 559df83
Some fixes
mattrunyon 46b204e
Address review comments
mattrunyon 14aa6f1
Fix spread props
mattrunyon 8f8a0b1
Fix console focus issue after opening dashboard
mattrunyon 06272d6
Address review comments. Add todos ticket numbers
mattrunyon 017e6b4
Merge remote-tracking branch 'upstream/main' into app-dashboards
mattrunyon 6d32ba8
Fix unit tests
mattrunyon baad0c8
Fix more test failures
mattrunyon 6fadd77
Merge branch 'main' into app-dashboards
mattrunyon 7c4cfb4
Change plugin data map to object
mattrunyon 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
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React, { useCallback } from 'react'; | ||
import classNames from 'classnames'; | ||
import { | ||
DashboardUtils, | ||
DEFAULT_DASHBOARD_ID, | ||
DehydratedDashboardPanelProps, | ||
LazyDashboard, | ||
} from '@deephaven/dashboard'; | ||
import { useConnection } from '@deephaven/jsapi-components'; | ||
import { VariableDefinition } from '@deephaven/jsapi-types'; | ||
import LayoutManager, { ItemConfigType } from '@deephaven/golden-layout'; | ||
import { LoadingOverlay } from '@deephaven/components'; | ||
import EmptyDashboard from './EmptyDashboard'; | ||
|
||
interface AppDashboardsProps { | ||
dashboards: { | ||
id: string; | ||
layoutConfig: ItemConfigType[]; | ||
}[]; | ||
activeDashboard: string; | ||
onGoldenLayoutChange: (goldenLayout: LayoutManager) => void; | ||
plugins: JSX.Element[]; | ||
onAutoFillClick: (event: React.MouseEvent) => void; | ||
} | ||
|
||
export function AppDashboards({ | ||
dashboards, | ||
activeDashboard, | ||
onGoldenLayoutChange, | ||
plugins, | ||
onAutoFillClick, | ||
}: AppDashboardsProps): JSX.Element { | ||
const connection = useConnection(); | ||
|
||
const hydratePanel = useCallback( | ||
(hydrateProps: DehydratedDashboardPanelProps, id: string) => { | ||
const { metadata } = hydrateProps; | ||
if ( | ||
metadata?.type != null && | ||
(metadata?.id != null || metadata?.name != null) | ||
) { | ||
// Looks like a widget, hydrate it as such | ||
const widget: VariableDefinition = | ||
metadata.id != null | ||
? { | ||
type: metadata.type, | ||
id: metadata.id, | ||
} | ||
: { | ||
type: metadata.type, | ||
name: metadata.name, | ||
title: metadata.name, | ||
}; | ||
return { | ||
fetch: async () => connection?.getObject(widget), | ||
...hydrateProps, | ||
localDashboardId: id, | ||
}; | ||
} | ||
return DashboardUtils.hydrate(hydrateProps, id); | ||
}, | ||
[connection] | ||
); | ||
|
||
return ( | ||
<div className="tab-content"> | ||
{dashboards.map(d => ( | ||
<div | ||
key={d.id} | ||
className={classNames('tab-pane', { | ||
active: d.id === activeDashboard, | ||
})} | ||
> | ||
<LazyDashboard | ||
id={d.id} | ||
isActive={d.id === activeDashboard} | ||
emptyDashboard={ | ||
d.id === DEFAULT_DASHBOARD_ID ? ( | ||
<EmptyDashboard onAutoFillClick={onAutoFillClick} /> | ||
) : ( | ||
<LoadingOverlay /> | ||
) | ||
} | ||
layoutConfig={d.layoutConfig} | ||
onGoldenLayoutChange={onGoldenLayoutChange} | ||
hydrate={hydratePanel} | ||
plugins={plugins} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default AppDashboards; |
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.
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.
How will this work from Enterprise? We need to be able to pass in the hydration function and pull the query from the metadata for Enterprise.
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.
I don't think this hydration specifically will affect Enterprise. This is just moving the hydration function from
AppMainContainer
toAppDashboards
sinceAppMainContainer
doesn't need to know anything about this once the dashboards component is split outEnterprise has its own hydration which would be part of the
Dashboard
alreadyAs far as Enterprise changes go, it will need to add
dashboardPluginData
and also listen to the event for creating a dashboard like DHC does. There might be something w/ the plugin and plugin data that we need to modify to work w/ enterprise PQs since right now the plugin is responsible for fetching its widgetThere 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.
I've thought about extending
WidgetPlugin
in some manner so that it doesn't have to mount a panel. Right now it's kind of hacky IMO because the dashboard widget from dh.ui is loaded as part of a dashboard plugin. Instead it could be a widget plugin that mounts, but doesn't render a panel.Or we need some sort of context/hook that lets the plugin get its own fetch function or create one with just the widget name and type. In DHE the hook could wrap any other info like PQ data into the fetch function it provides
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.
A plugin that mounts but doesn't have a panel sounds kinda neat. Need to give it more thought.