) => {
- if (viewMode !== ViewMode.EDIT) return;
-
- const updatedPanels: { [key: string]: DashboardPanelState } = newLayout.reduce(
- (updatedPanelsAcc, panelLayout) => {
- updatedPanelsAcc[panelLayout.i] = {
- ...panels[panelLayout.i],
- gridData: pick(panelLayout, ['x', 'y', 'w', 'h', 'i']),
- };
- return updatedPanelsAcc;
- },
- {} as { [key: string]: DashboardPanelState }
- );
- if (!getPanelLayoutsAreEqual(panels, updatedPanels)) {
- dashboard.dispatch.setPanels(updatedPanels);
- }
- },
- [dashboard, panels, viewMode]
- );
const classes = classNames({
'dshLayout-withoutMargins': !useMargins,
'dshLayout--viewing': viewMode === ViewMode.VIEW,
'dshLayout--editing': viewMode !== ViewMode.VIEW,
- 'dshLayout--noAnimation': !animatePanelTransforms || delayedIsPanelExpanded,
'dshLayout-isMaximizedPanel': expandedPanelId !== undefined,
});
- const { layouts, breakpoints, columns } = useDashboardGridSettings(panelsInOrder);
-
- // in print mode, dashboard layout is not controlled by React Grid Layout
- if (viewMode === ViewMode.PRINT) {
- return <>{panelComponents}>;
- }
+ const panelProps = {
+ showBadges: true,
+ showBorder: useMargins,
+ showNotifications: true,
+ showShadow: false,
+ };
return (
-
- {panelComponents}
-
+
+ {
+ const layoutPanels = Object.values(panels).reduce((acc, panel) => {
+ const gridData: GridPanelData = {
+ id: panel.explicitInput.id,
+ row: panel.gridData.y,
+ column: panel.gridData.x,
+ width: panel.gridData.w,
+ height: panel.gridData.h,
+ };
+ acc[panel.explicitInput.id] = gridData;
+ return acc;
+ }, {} as { [key: string]: GridPanelData });
+ const initialLayout: GridLayoutData = [
+ {
+ title: 'DEFAULT DASHBOARD',
+ isCollapsed: false,
+ panels: layoutPanels,
+ },
+ ];
+ return {
+ initialLayout,
+ gridSettings: {
+ gutterSize: DASHBOARD_MARGIN_SIZE,
+ rowHeight: DASHBOARD_GRID_HEIGHT,
+ columnCount: DASHBOARD_GRID_COLUMN_COUNT,
+ },
+ };
+ }}
+ renderPanelContents={(embeddableId) => {
+ const type = panels[embeddableId].type;
+ return (
+ dashboard}
+ key={`${type}_${embeddableId}`}
+ onApiAvailable={(api) => dashboard.registerChildApi(api)}
+ />
+ );
+ }}
+ >
+
);
};