Skip to content

Commit c985e12

Browse files
authored
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
1 parent 2744f97 commit c985e12

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

packages/components/src/context-actions/ContextActionUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type ResolvableContextAction =
1010
export type MenuItem = ContextAction | Promise<ContextAction[]>;
1111

1212
export interface ContextAction {
13-
title?: string;
13+
title?: string | JSX.Element;
1414
description?: string;
1515
action?: (event: Event) => void;
1616
actions?: ResolvableContextAction[];

packages/dashboard-core-plugins/src/panels/ChartPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,12 @@ export class ChartPanel extends Component<ChartPanelProps, ChartPanelState> {
348348
pending: Pending;
349349

350350
initModel(): void {
351-
this.setState({ isLoading: true, isLoaded: false, error: undefined });
351+
this.setState({
352+
isLoading: true,
353+
isLoaded: false,
354+
error: undefined,
355+
isDisconnected: false,
356+
});
352357

353358
const { makeModel } = this.props;
354359

packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,12 @@ export class IrisGridPanel extends PureComponent<
563563
);
564564

565565
initModel(): void {
566-
this.setState({ isModelReady: false, isLoading: true, error: null });
566+
this.setState({
567+
isModelReady: false,
568+
isLoading: true,
569+
error: null,
570+
isDisconnected: false,
571+
});
567572
const { makeModel } = this.props;
568573
if (this.modelPromise != null) {
569574
this.modelPromise.cancel();

packages/dashboard-core-plugins/src/panels/Panel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
ContextActions,
1414
createXComponent,
1515
LoadingOverlay,
16+
type ResolvableContextAction,
1617
Tooltip,
1718
} from '@deephaven/components';
1819
import {
@@ -64,7 +65,7 @@ export type CorePanelProps = {
6465
onTabBlur?: (...args: unknown[]) => void;
6566
onTabFocus?: (...args: unknown[]) => void;
6667
renderTabTooltip?: () => ReactNode;
67-
additionalActions?: ContextAction[];
68+
additionalActions?: ResolvableContextAction[];
6869
errorMessage?: string;
6970
isLoading?: boolean;
7071
isLoaded?: boolean;
@@ -297,7 +298,7 @@ class Panel extends PureComponent<CorePanelProps, PanelState> {
297298

298299
getAdditionalActions = memoize(
299300
(
300-
actions: readonly ContextAction[],
301+
actions: readonly ResolvableContextAction[],
301302
isClonable: boolean,
302303
isRenamable: boolean
303304
) => {

packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React, { PureComponent, type ReactElement } from 'react';
2-
import { type ContextAction, ContextActions } from '@deephaven/components';
2+
import {
3+
ContextActions,
4+
type ResolvableContextAction,
5+
} from '@deephaven/components';
36
import type { Container, EventEmitter, Tab } from '@deephaven/golden-layout';
47
import {
58
type CustomizableWorkspace,
@@ -15,7 +18,7 @@ import {
1518
} from '@deephaven/dashboard';
1619

1720
interface PanelContextMenuProps {
18-
additionalActions: ContextAction[];
21+
additionalActions: ResolvableContextAction[];
1922
glContainer: Container;
2023
glEventHub: EventEmitter;
2124
workspace: CustomizableWorkspace;
@@ -136,9 +139,7 @@ class PanelContextMenu extends PureComponent<
136139
render(): ReactElement {
137140
const { additionalActions, glContainer } = this.props;
138141

139-
const contextActions: (ContextAction | (() => ContextAction))[] = [
140-
...additionalActions,
141-
];
142+
const contextActions = [...additionalActions];
142143

143144
contextActions.push(() => ({
144145
title: 'Re-open closed panel',

packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React, { PureComponent, type ReactElement } from 'react';
22
import classNames from 'classnames';
33
import memoize from 'memoize-one';
44
import {
5-
type ContextAction,
65
ContextActions,
76
createXComponent,
7+
type ResolvableContextAction,
88
} from '@deephaven/components';
99
import type { dh } from '@deephaven/jsapi-types';
1010
import { copyToClipboard, EMPTY_ARRAY } from '@deephaven/utils';
@@ -97,7 +97,7 @@ class WidgetPanel extends PureComponent<WidgetPanelProps, WidgetPanelState> {
9797
getCachedActions = memoize(
9898
(
9999
descriptor: WidgetPanelDescriptor,
100-
propsAdditionalActions: readonly ContextAction[] = EMPTY_ARRAY
100+
propsAdditionalActions: readonly ResolvableContextAction[] = EMPTY_ARRAY
101101
) => [
102102
...propsAdditionalActions,
103103
{

packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $tooltip-container-width: 300px;
1616
.tab-tooltip-name-wrapper {
1717
display: flex;
1818
flex-wrap: nowrap;
19-
align-items: first baseline;
19+
align-items: center;
2020
gap: $spacer-1;
2121
}
2222

0 commit comments

Comments
 (0)