Skip to content

Commit

Permalink
fix: Widget panel fixes (#2227)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mofojed committed Sep 20, 2024
1 parent 2744f97 commit c985e12
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ResolvableContextAction =
export type MenuItem = ContextAction | Promise<ContextAction[]>;

export interface ContextAction {
title?: string;
title?: string | JSX.Element;
description?: string;
action?: (event: Event) => void;
actions?: ResolvableContextAction[];
Expand Down
7 changes: 6 additions & 1 deletion packages/dashboard-core-plugins/src/panels/ChartPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,12 @@ export class ChartPanel extends Component<ChartPanelProps, ChartPanelState> {
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;

Expand Down
7 changes: 6 additions & 1 deletion packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions packages/dashboard-core-plugins/src/panels/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ContextActions,
createXComponent,
LoadingOverlay,
type ResolvableContextAction,
Tooltip,
} from '@deephaven/components';
import {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -297,7 +298,7 @@ class Panel extends PureComponent<CorePanelProps, PanelState> {

getAdditionalActions = memoize(
(
actions: readonly ContextAction[],
actions: readonly ResolvableContextAction[],
isClonable: boolean,
isRenamable: boolean
) => {
Expand Down
11 changes: 6 additions & 5 deletions packages/dashboard-core-plugins/src/panels/PanelContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,7 +18,7 @@ import {
} from '@deephaven/dashboard';

interface PanelContextMenuProps {
additionalActions: ContextAction[];
additionalActions: ResolvableContextAction[];
glContainer: Container;
glEventHub: EventEmitter;
workspace: CustomizableWorkspace;
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard-core-plugins/src/panels/WidgetPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -97,7 +97,7 @@ class WidgetPanel extends PureComponent<WidgetPanelProps, WidgetPanelState> {
getCachedActions = memoize(
(
descriptor: WidgetPanelDescriptor,
propsAdditionalActions: readonly ContextAction[] = EMPTY_ARRAY
propsAdditionalActions: readonly ResolvableContextAction[] = EMPTY_ARRAY
) => [
...propsAdditionalActions,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c985e12

Please sign in to comment.