Skip to content

Commit 31d0ebb

Browse files
authored
refactor: Move Panel into @deephaven/dashboard (#2304)
- Move Panel into @deephaven/dashboard, removing functionality depending on core plugins and keeping in CorePanel in the dashboard-core-plugins package - Renamed Panel to BasePanel - kept an alias of Panel to make it non-breaking - Should be no breaking changes, as dashboard-core-plugins re-exports the components that were removed - Allows plugins (such as deephaven.ui) to simply use the `Panel` component without having to depend on other core plugins - Tests pass, ran a smoke test with latest version of deephaven.ui to ensure functionality still worked - Tested from Enterprise as well against the latest G+, was able to open table panels and deephaven.ui panels without any changes to Enterprise code.
1 parent 9de971f commit 31d0ebb

23 files changed

Lines changed: 133 additions & 73 deletions

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dashboard-core-plugins/src/events/TabEventMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type ValueOf } from '@deephaven/utils';
2-
import type TabEvent from './TabEvent';
2+
import { type TabEvent } from '@deephaven/dashboard';
33

44
export type TabEventType = ValueOf<typeof TabEvent>;
55

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import { TabEvent as DashboardTabEvent } from '@deephaven/dashboard';
2+
13
export { default as ChartEvent } from './ChartEvent';
24
export { default as ConsoleEvent } from './ConsoleEvent';
35
export { default as InputFilterEvent } from './InputFilterEvent';
46
export { default as IrisGridEvent } from './IrisGridEvent';
57
export { default as MarkdownEvent } from './MarkdownEvent';
68
export { default as NotebookEvent } from './NotebookEvent';
79
export { default as PandasEvent } from './PandasEvent';
8-
export { default as TabEvent } from './TabEvent';
10+
11+
/**
12+
* @deprecated Use TabEvent from @deephaven/dashboard
13+
*/
14+
export const TabEvent = DashboardTabEvent;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { assertNotNull, Pending } from '@deephaven/utils';
1515
import type { dh } from '@deephaven/jsapi-types';
1616
import { ConsoleEvent, NotebookEvent } from '../events';
1717
import './CommandHistoryPanel.scss';
18-
import Panel from './Panel';
18+
import Panel from './CorePanel';
1919
import { getDashboardSessionWrapper } from '../redux';
2020

2121
const log = Log.module('CommandHistoryPanel');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
} from '@deephaven/plugin';
3939
import type { JSZipObject } from 'jszip';
4040
import { ConsoleEvent } from '../events';
41-
import Panel from './Panel';
41+
import Panel from './CorePanel';
4242
import { getDashboardSessionWrapper } from '../redux';
4343
import './ConsolePanel.scss';
4444

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React, { PureComponent, type ReactElement } from 'react';
2+
import { createXComponent } from '@deephaven/components';
3+
import { type BasePanelProps, BasePanel } from '@deephaven/dashboard';
4+
import type { dh } from '@deephaven/jsapi-types';
5+
import { ConsoleEvent, InputFilterEvent } from '../events';
6+
7+
export type CorePanelProps = BasePanelProps & {
8+
onClearAllFilters?: (...args: unknown[]) => void;
9+
onSessionClose?: (session: dh.IdeSession) => void;
10+
onSessionOpen?: (
11+
session: dh.IdeSession,
12+
{ language, sessionId }: { language: string; sessionId: string }
13+
) => void;
14+
};
15+
16+
/**
17+
* Extends the base panel component to handle Session events and input filter events.
18+
*/
19+
class CorePanel extends PureComponent<CorePanelProps> {
20+
constructor(props: CorePanelProps) {
21+
super(props);
22+
23+
this.handleClearAllFilters = this.handleClearAllFilters.bind(this);
24+
this.handleSessionClosed = this.handleSessionClosed.bind(this);
25+
this.handleSessionOpened = this.handleSessionOpened.bind(this);
26+
}
27+
28+
componentDidMount(): void {
29+
const { glEventHub } = this.props;
30+
31+
glEventHub.on(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed);
32+
glEventHub.on(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened);
33+
glEventHub.on(
34+
InputFilterEvent.CLEAR_ALL_FILTERS,
35+
this.handleClearAllFilters
36+
);
37+
}
38+
39+
componentWillUnmount(): void {
40+
const { glEventHub } = this.props;
41+
42+
glEventHub.off(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed);
43+
glEventHub.off(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened);
44+
glEventHub.off(
45+
InputFilterEvent.CLEAR_ALL_FILTERS,
46+
this.handleClearAllFilters
47+
);
48+
}
49+
50+
handleClearAllFilters(...args: unknown[]): void {
51+
const { onClearAllFilters } = this.props;
52+
onClearAllFilters?.(...args);
53+
}
54+
55+
handleSessionClosed(session: dh.IdeSession): void {
56+
const { onSessionClose } = this.props;
57+
onSessionClose?.(session);
58+
}
59+
60+
handleSessionOpened(
61+
session: dh.IdeSession,
62+
params: { language: string; sessionId: string }
63+
): void {
64+
const { onSessionOpen } = this.props;
65+
onSessionOpen?.(session, params);
66+
}
67+
68+
render(): ReactElement {
69+
const { children, ...otherProps } = this.props;
70+
71+
// eslint-disable-next-line react/jsx-props-no-spreading
72+
return <BasePanel {...otherProps}>{children}</BasePanel>;
73+
}
74+
}
75+
76+
const XCorePanel = createXComponent(CorePanel);
77+
78+
export default XCorePanel;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import FileExplorer, {
1212
import React, { type ReactNode } from 'react';
1313
import { connect, type ConnectedProps } from 'react-redux';
1414
import type { dh } from '@deephaven/jsapi-types';
15-
import Panel from './Panel';
15+
import Panel from './CorePanel';
1616
import { NotebookEvent } from '../events';
1717
import './FileExplorerPanel.scss';
1818
import { getDashboardSessionWrapper } from '../redux';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
getTableMapForDashboard,
2323
setDashboardFilterSets as setDashboardFilterSetsAction,
2424
} from '../redux';
25-
import Panel from './Panel';
25+
import Panel from './CorePanel';
2626
import FilterSetManager, {
2727
type ChangeHandlerArgs,
2828
type FilterSet,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Container, EventEmitter } from '@deephaven/golden-layout';
55
import { type RootState } from '@deephaven/redux';
66
import { LayoutUtils } from '@deephaven/dashboard';
77
import { assertNotNull } from '@deephaven/utils';
8-
import Panel from './Panel';
8+
import Panel from './CorePanel';
99
import InputFilter, {
1010
type InputFilterColumn,
1111
} from '../controls/input-filter/InputFilter';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { type DashboardPanelProps } from '@deephaven/dashboard';
88
import Log from '@deephaven/log';
99
import { type RootState } from '@deephaven/redux';
1010
import './LogPanel.scss';
11-
import Panel from './Panel';
11+
import Panel from './CorePanel';
1212
import { getDashboardSessionWrapper } from '../redux';
1313

1414
const log = Log.module('LogPanel');

0 commit comments

Comments
 (0)