-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Move Panel into @deephaven/dashboard #2304
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { PureComponent, type ReactElement } from 'react'; | ||
import { createXComponent } from '@deephaven/components'; | ||
import { type BasePanelProps, Panel } from '@deephaven/dashboard'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we should either have |
||
import type { dh } from '@deephaven/jsapi-types'; | ||
import { ConsoleEvent, InputFilterEvent } from '../events'; | ||
|
||
export type CorePanelProps = BasePanelProps & { | ||
onClearAllFilters?: (...args: unknown[]) => void; | ||
onSessionClose?: (session: dh.IdeSession) => void; | ||
onSessionOpen?: ( | ||
session: dh.IdeSession, | ||
{ language, sessionId }: { language: string; sessionId: string } | ||
) => void; | ||
}; | ||
|
||
/** | ||
* Generic panel component that emits mount/unmount/focus events. | ||
* Also wires up some triggers for common events: | ||
* Focus, Resize, Show, Session open/close, client disconnect/reconnect. | ||
*/ | ||
class CorePanel extends PureComponent<CorePanelProps> { | ||
constructor(props: CorePanelProps) { | ||
super(props); | ||
|
||
this.handleClearAllFilters = this.handleClearAllFilters.bind(this); | ||
this.handleSessionClosed = this.handleSessionClosed.bind(this); | ||
this.handleSessionOpened = this.handleSessionOpened.bind(this); | ||
} | ||
|
||
componentDidMount(): void { | ||
const { glEventHub } = this.props; | ||
|
||
glEventHub.on(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed); | ||
glEventHub.on(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened); | ||
glEventHub.on( | ||
InputFilterEvent.CLEAR_ALL_FILTERS, | ||
this.handleClearAllFilters | ||
); | ||
} | ||
|
||
componentWillUnmount(): void { | ||
const { glEventHub } = this.props; | ||
|
||
glEventHub.off(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed); | ||
glEventHub.off(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened); | ||
glEventHub.off( | ||
InputFilterEvent.CLEAR_ALL_FILTERS, | ||
this.handleClearAllFilters | ||
); | ||
} | ||
|
||
handleClearAllFilters(...args: unknown[]): void { | ||
const { onClearAllFilters } = this.props; | ||
onClearAllFilters?.(...args); | ||
} | ||
|
||
handleSessionClosed(session: dh.IdeSession): void { | ||
const { onSessionClose } = this.props; | ||
onSessionClose?.(session); | ||
} | ||
|
||
handleSessionOpened( | ||
session: dh.IdeSession, | ||
params: { language: string; sessionId: string } | ||
): void { | ||
const { onSessionOpen } = this.props; | ||
onSessionOpen?.(session, params); | ||
} | ||
|
||
render(): ReactElement { | ||
const { children, ...otherProps } = this.props; | ||
|
||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <Panel {...otherProps}>{children}</Panel>; | ||
} | ||
} | ||
|
||
const XCorePanel = createXComponent(CorePanel); | ||
|
||
export default XCorePanel; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ export { default as MarkdownPanel } from './MarkdownPanel'; | |
export { default as NotebookPanel } from './NotebookPanel'; | ||
export { default as PandasPanel } from './PandasPanel'; | ||
export * from './PandasPanel'; | ||
export { default as Panel } from './Panel'; | ||
export { default as CorePanel } from './CorePanel'; | ||
// Deprecated - use CorePanel instead | ||
export { default as Panel } from './CorePanel'; | ||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about importing and renaming for the deprecated export w/ a deprecated tag.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deephaven.ui doesn't use the |
||
export * from './WidgetPanelTypes'; | ||
export { default as WidgetPanel, type WidgetPanelProps } from './WidgetPanel'; | ||
export { default as WidgetPanelTooltip } from './WidgetPanelTooltip'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,6 @@ import { | |
type ResolvableContextAction, | ||
Tooltip, | ||
} from '@deephaven/components'; | ||
import { | ||
LayoutUtils, | ||
type PanelComponent, | ||
PanelEvent, | ||
} from '@deephaven/dashboard'; | ||
import type { | ||
Container, | ||
EventEmitter, | ||
|
@@ -29,15 +24,17 @@ import type { | |
} from '@deephaven/golden-layout'; | ||
import { assertNotNull, EMPTY_ARRAY } from '@deephaven/utils'; | ||
import Log from '@deephaven/log'; | ||
import type { dh } from '@deephaven/jsapi-types'; | ||
import { ConsoleEvent, InputFilterEvent, TabEvent } from '../events'; | ||
import LayoutUtils from './layout/LayoutUtils'; | ||
import { type PanelComponent } from './DashboardPlugin'; | ||
import PanelEvent from './PanelEvent'; | ||
import PanelContextMenu from './PanelContextMenu'; | ||
import RenameDialog from './RenameDialog'; | ||
import TabEvent from './TabEvent'; | ||
import './Panel.scss'; | ||
|
||
const log = Log.module('Panel'); | ||
|
||
export type CorePanelProps = { | ||
export type BasePanelProps = { | ||
/** | ||
* Reference to the component panel. | ||
* Will wait until it is set before emitting mount/unmount events. | ||
|
@@ -52,14 +49,8 @@ export type CorePanelProps = { | |
onBlur?: FocusEventHandler<HTMLDivElement>; | ||
onTab?: (tab: Tab) => void; | ||
onTabClicked?: (e: MouseEvent) => void; | ||
onClearAllFilters?: (...args: unknown[]) => void; | ||
onHide?: (...args: unknown[]) => void; | ||
onResize?: (...args: unknown[]) => void; | ||
onSessionClose?: (session: dh.IdeSession) => void; | ||
onSessionOpen?: ( | ||
session: dh.IdeSession, | ||
{ language, sessionId }: { language: string; sessionId: string } | ||
) => void; | ||
onBeforeShow?: (...args: unknown[]) => void; | ||
onShow?: (...args: unknown[]) => void; | ||
onTabBlur?: (...args: unknown[]) => void; | ||
|
@@ -83,18 +74,15 @@ interface PanelState { | |
* Also wires up some triggers for common events: | ||
* Focus, Resize, Show, Session open/close, client disconnect/reconnect. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove session open/close. And client disconnect/reconnect? |
||
*/ | ||
class Panel extends PureComponent<CorePanelProps, PanelState> { | ||
constructor(props: CorePanelProps) { | ||
class Panel extends PureComponent<BasePanelProps, PanelState> { | ||
constructor(props: BasePanelProps) { | ||
super(props); | ||
|
||
this.handleClearAllFilters = this.handleClearAllFilters.bind(this); | ||
this.handleCopyPanel = this.handleCopyPanel.bind(this); | ||
this.handleFocus = this.handleFocus.bind(this); | ||
this.handleBlur = this.handleBlur.bind(this); | ||
this.handleHide = this.handleHide.bind(this); | ||
this.handleResize = this.handleResize.bind(this); | ||
this.handleSessionClosed = this.handleSessionClosed.bind(this); | ||
this.handleSessionOpened = this.handleSessionOpened.bind(this); | ||
this.handleBeforeShow = this.handleBeforeShow.bind(this); | ||
this.handleShow = this.handleShow.bind(this); | ||
this.handleTabBlur = this.handleTabBlur.bind(this); | ||
|
@@ -124,14 +112,8 @@ class Panel extends PureComponent<CorePanelProps, PanelState> { | |
glContainer.on('hide', this.handleHide); | ||
glContainer.on('tab', this.handleTab); | ||
glContainer.on('tabClicked', this.handleTabClicked); | ||
glEventHub.on(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed); | ||
glEventHub.on(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened); | ||
glEventHub.on(TabEvent.focus, this.handleTabFocus); | ||
glEventHub.on(TabEvent.blur, this.handleTabBlur); | ||
glEventHub.on( | ||
InputFilterEvent.CLEAR_ALL_FILTERS, | ||
this.handleClearAllFilters | ||
); | ||
|
||
glEventHub.emit(PanelEvent.MOUNT, componentPanel ?? this); | ||
|
||
|
@@ -150,14 +132,8 @@ class Panel extends PureComponent<CorePanelProps, PanelState> { | |
glContainer.off('hide', this.handleHide); | ||
glContainer.off('tab', this.handleTab); | ||
glContainer.off('tabClicked', this.handleTabClicked); | ||
glEventHub.off(ConsoleEvent.SESSION_CLOSED, this.handleSessionClosed); | ||
glEventHub.off(ConsoleEvent.SESSION_OPENED, this.handleSessionOpened); | ||
glEventHub.off(TabEvent.focus, this.handleTabFocus); | ||
glEventHub.off(TabEvent.blur, this.handleTabBlur); | ||
glEventHub.off( | ||
InputFilterEvent.CLEAR_ALL_FILTERS, | ||
this.handleClearAllFilters | ||
); | ||
|
||
glEventHub.emit(PanelEvent.UNMOUNT, componentPanel ?? this); | ||
} | ||
|
@@ -183,11 +159,6 @@ class Panel extends PureComponent<CorePanelProps, PanelState> { | |
onTabClicked?.(e); | ||
} | ||
|
||
handleClearAllFilters(...args: unknown[]): void { | ||
const { onClearAllFilters } = this.props; | ||
onClearAllFilters?.(...args); | ||
} | ||
|
||
handleFocus(event: FocusEvent<HTMLDivElement>): void { | ||
const { componentPanel, glEventHub } = this.props; | ||
glEventHub.emit(PanelEvent.FOCUS, componentPanel ?? this); | ||
|
@@ -211,19 +182,6 @@ class Panel extends PureComponent<CorePanelProps, PanelState> { | |
onResize?.(...args); | ||
} | ||
|
||
handleSessionClosed(session: dh.IdeSession): void { | ||
const { onSessionClose } = this.props; | ||
onSessionClose?.(session); | ||
} | ||
|
||
handleSessionOpened( | ||
session: dh.IdeSession, | ||
params: { language: string; sessionId: string } | ||
): void { | ||
const { onSessionOpen } = this.props; | ||
onSessionOpen?.(session, params); | ||
} | ||
|
||
handleBeforeShow(...args: unknown[]): void { | ||
const { onBeforeShow } = this.props; | ||
onBeforeShow?.(...args); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do something like this so the deprecation actually shows up in vscode
This will give the deprecation strikethrough in VSCode