From 43172be747d9a8d080a11ff8f268bd68694d6f99 Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Thu, 6 Jul 2023 07:13:54 +0000 Subject: [PATCH] revert back to grid, reference too much of issue without hooks Signed-off-by: abbyhu2000 --- .../components/dashboard_editor.tsx | 9 --- .../embeddable/grid/dashboard_grid.tsx | 41 ++++++++----- .../embeddable/grid/dashboard_grid_item.tsx | 58 ------------------- 3 files changed, 28 insertions(+), 80 deletions(-) delete mode 100644 src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid_item.tsx diff --git a/src/plugins/dashboard/public/application/components/dashboard_editor.tsx b/src/plugins/dashboard/public/application/components/dashboard_editor.tsx index d2b480e50fc7..075d8b99a0e1 100644 --- a/src/plugins/dashboard/public/application/components/dashboard_editor.tsx +++ b/src/plugins/dashboard/public/application/components/dashboard_editor.tsx @@ -39,15 +39,6 @@ export const DashboardEditor = () => { dashboard ); - // const { dashboardContainer } = useDashboardContainer( - // services, - // isChromeVisible, - // eventEmitter, - // dashboard, - // savedDashboardInstance, - // appState - // ); - const { isEmbeddableRendered, currentAppState } = useEditorUpdates( eventEmitter, dashboard, diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx index 84196aefcc45..98c1d163a16f 100644 --- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx @@ -47,7 +47,6 @@ import { DashboardPanelState } from '../types'; import { withOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public'; import { DashboardContainerInput } from '../dashboard_container'; import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container'; -import { DashboardGridItem } from './dashboard_grid_item'; let lastValidGridSize = 0; @@ -263,18 +262,34 @@ class DashboardGridUi extends React.Component { } }); - return _.map(panelsInOrder, ({ explicitInput, type }) => ( - - )); + return _.map(panelsInOrder, (panel) => { + const expandPanel = + expandedPanelId !== undefined && expandedPanelId === panel.explicitInput.id; + const hidePanel = expandedPanelId !== undefined && expandedPanelId !== panel.explicitInput.id; + const classes = classNames({ + // eslint-disable-next-line @typescript-eslint/naming-convention + 'dshDashboardGrid__item--expanded': expandPanel, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'dshDashboardGrid__item--hidden': hidePanel, + }); + return ( +
{ + this.gridItems[panel.explicitInput.id] = reactGridItem; + }} + > + +
+ ); + }); } public render() { diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid_item.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid_item.tsx deleted file mode 100644 index 9ef467e9cc9f..000000000000 --- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid_item.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -import { FC } from 'react'; -import classNames from 'classnames'; -import React from 'react'; -import { EmbeddableChildPanel } from '../../../embeddable_plugin'; - -export const DashboardGridItem: FC = (props: any) => { - const { - expandedPanelId, - focusedPanelIndex, - id, - type, - style, - gridItems, - container, - PanelComponent, - children, - className, - } = props; - const expandPanel = expandedPanelId !== undefined && expandedPanelId === id; - const hidePanel = expandedPanelId !== undefined && expandedPanelId !== id; - const classes = classNames({ - // eslint-disable-next-line @typescript-eslint/naming-convention - 'dshDashboardGrid__item--expanded': expandPanel, - // eslint-disable-next-line @typescript-eslint/naming-convention - 'dshDashboardGrid__item--hidden': hidePanel, - }); - const panelClassName = [classes, className].join(' '); - return ( -
{ - gridItems[id] = reactGridItem; - }} - > - - {children} -
- ); -};