From c985e1274097860dcbf4690ac8412c9f84831209 Mon Sep 17 00:00:00 2001 From: Mike Bender Date: Fri, 20 Sep 2024 13:20:22 -0400 Subject: [PATCH] fix: Widget panel fixes (#2227) - Allow JSX.Element to be passed into a context action title - We already supported it, but we just didn't allow the type - Reset isDisconnected flag when the model is initialized - On reconnect, the model was reloading but it was staying in a "disconnected" state --- .../src/context-actions/ContextActionUtils.ts | 2 +- .../dashboard-core-plugins/src/panels/ChartPanel.tsx | 7 ++++++- .../src/panels/IrisGridPanel.tsx | 7 ++++++- packages/dashboard-core-plugins/src/panels/Panel.tsx | 5 +++-- .../src/panels/PanelContextMenu.tsx | 11 ++++++----- .../dashboard-core-plugins/src/panels/WidgetPanel.tsx | 4 ++-- .../src/panels/WidgetPanelTooltip.scss | 2 +- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/packages/components/src/context-actions/ContextActionUtils.ts b/packages/components/src/context-actions/ContextActionUtils.ts index 1e802bfe3..f71671f20 100644 --- a/packages/components/src/context-actions/ContextActionUtils.ts +++ b/packages/components/src/context-actions/ContextActionUtils.ts @@ -10,7 +10,7 @@ export type ResolvableContextAction = export type MenuItem = ContextAction | Promise; export interface ContextAction { - title?: string; + title?: string | JSX.Element; description?: string; action?: (event: Event) => void; actions?: ResolvableContextAction[]; diff --git a/packages/dashboard-core-plugins/src/panels/ChartPanel.tsx b/packages/dashboard-core-plugins/src/panels/ChartPanel.tsx index fe89e881c..e71f79c46 100644 --- a/packages/dashboard-core-plugins/src/panels/ChartPanel.tsx +++ b/packages/dashboard-core-plugins/src/panels/ChartPanel.tsx @@ -348,7 +348,12 @@ export class ChartPanel extends Component { pending: Pending; initModel(): void { - this.setState({ isLoading: true, isLoaded: false, error: undefined }); + this.setState({ + isLoading: true, + isLoaded: false, + error: undefined, + isDisconnected: false, + }); const { makeModel } = this.props; diff --git a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx index e4efb20dd..d697f4710 100644 --- a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx +++ b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx @@ -563,7 +563,12 @@ export class IrisGridPanel extends PureComponent< ); initModel(): void { - this.setState({ isModelReady: false, isLoading: true, error: null }); + this.setState({ + isModelReady: false, + isLoading: true, + error: null, + isDisconnected: false, + }); const { makeModel } = this.props; if (this.modelPromise != null) { this.modelPromise.cancel(); diff --git a/packages/dashboard-core-plugins/src/panels/Panel.tsx b/packages/dashboard-core-plugins/src/panels/Panel.tsx index beb753535..86ec51328 100644 --- a/packages/dashboard-core-plugins/src/panels/Panel.tsx +++ b/packages/dashboard-core-plugins/src/panels/Panel.tsx @@ -13,6 +13,7 @@ import { ContextActions, createXComponent, LoadingOverlay, + type ResolvableContextAction, Tooltip, } from '@deephaven/components'; import { @@ -64,7 +65,7 @@ export type CorePanelProps = { onTabBlur?: (...args: unknown[]) => void; onTabFocus?: (...args: unknown[]) => void; renderTabTooltip?: () => ReactNode; - additionalActions?: ContextAction[]; + additionalActions?: ResolvableContextAction[]; errorMessage?: string; isLoading?: boolean; isLoaded?: boolean; @@ -297,7 +298,7 @@ class Panel extends PureComponent { getAdditionalActions = memoize( ( - actions: readonly ContextAction[], + actions: readonly ResolvableContextAction[], isClonable: boolean, isRenamable: boolean ) => { diff --git a/packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx b/packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx index 11da9d351..97d2f4cf8 100644 --- a/packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx +++ b/packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx @@ -1,5 +1,8 @@ import React, { PureComponent, type ReactElement } from 'react'; -import { type ContextAction, ContextActions } from '@deephaven/components'; +import { + ContextActions, + type ResolvableContextAction, +} from '@deephaven/components'; import type { Container, EventEmitter, Tab } from '@deephaven/golden-layout'; import { type CustomizableWorkspace, @@ -15,7 +18,7 @@ import { } from '@deephaven/dashboard'; interface PanelContextMenuProps { - additionalActions: ContextAction[]; + additionalActions: ResolvableContextAction[]; glContainer: Container; glEventHub: EventEmitter; workspace: CustomizableWorkspace; @@ -136,9 +139,7 @@ class PanelContextMenu extends PureComponent< render(): ReactElement { const { additionalActions, glContainer } = this.props; - const contextActions: (ContextAction | (() => ContextAction))[] = [ - ...additionalActions, - ]; + const contextActions = [...additionalActions]; contextActions.push(() => ({ title: 'Re-open closed panel', diff --git a/packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx b/packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx index 1841b5f39..b8832b038 100644 --- a/packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx +++ b/packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx @@ -2,9 +2,9 @@ import React, { PureComponent, type ReactElement } from 'react'; import classNames from 'classnames'; import memoize from 'memoize-one'; import { - type ContextAction, ContextActions, createXComponent, + type ResolvableContextAction, } from '@deephaven/components'; import type { dh } from '@deephaven/jsapi-types'; import { copyToClipboard, EMPTY_ARRAY } from '@deephaven/utils'; @@ -97,7 +97,7 @@ class WidgetPanel extends PureComponent { getCachedActions = memoize( ( descriptor: WidgetPanelDescriptor, - propsAdditionalActions: readonly ContextAction[] = EMPTY_ARRAY + propsAdditionalActions: readonly ResolvableContextAction[] = EMPTY_ARRAY ) => [ ...propsAdditionalActions, { diff --git a/packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.scss b/packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.scss index e8f3bd291..cfbd454bf 100644 --- a/packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.scss +++ b/packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.scss @@ -16,7 +16,7 @@ $tooltip-container-width: 300px; .tab-tooltip-name-wrapper { display: flex; flex-wrap: nowrap; - align-items: first baseline; + align-items: center; gap: $spacer-1; }