Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrunyon committed Mar 30, 2023
1 parent a3dc182 commit a1d4f6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions packages/dashboard-core-plugins/src/panels/NotebookPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Wrapper for the Notebook for use in a golden layout container
import React, { Component, MouseEvent, ReactElement } from 'react';
import React, { Component, ReactElement } from 'react';
import ReactDOM from 'react-dom';
import memoize from 'memoize-one';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -178,7 +178,7 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
this.handleLinkClick = this.handleLinkClick.bind(this);
this.handleLoadSuccess = this.handleLoadSuccess.bind(this);
this.handleLoadError = this.handleLoadError.bind(this);
this.handlePanelTabClick = this.handlePanelTabClick.bind(this);
this.handleTabClick = this.handleTabClick.bind(this);
this.handleRenameFile = this.handleRenameFile.bind(this);
this.handleResize = this.handleResize.bind(this);
this.handleRunCommand = this.handleRunCommand.bind(this);
Expand Down Expand Up @@ -287,7 +287,6 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
if (tab != null) this.initTab(tab);
this.initNotebookContent();
glEventHub.on(NotebookEvent.RENAME_FILE, this.handleRenameFile);
glContainer.on('tabClicked', this.handlePanelTabClick);
}

componentDidUpdate(
Expand Down Expand Up @@ -316,11 +315,10 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
this.debouncedSavePanelState.flush();
this.pending.cancel();

const { glContainer, glEventHub } = this.props;
const { glEventHub } = this.props;

const { fileMetadata, isPreview } = this.state;
glEventHub.off(NotebookEvent.RENAME_FILE, this.handleRenameFile);
glContainer.off('tabClicked', this.handlePanelTabClick);
glEventHub.emit(NotebookEvent.UNREGISTER_FILE, fileMetadata, isPreview);
}

Expand Down Expand Up @@ -733,7 +731,7 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
/**
* @param event The click event from clicking on the link
*/
handleLinkClick(event: MouseEvent<HTMLAnchorElement>) {
handleLinkClick(event: React.MouseEvent<HTMLAnchorElement>) {
const { notebooksUrl, session, sessionLanguage } = this.props;
const { href } = event.currentTarget;
if (!href || !href.startsWith(notebooksUrl)) {
Expand Down Expand Up @@ -957,8 +955,8 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
});
}

handlePanelTabClick(e: MouseEvent): void {
log.debug('handlePanelTabClick');
handleTabClick(e: MouseEvent): void {
log.debug('handle NotebookPanel tab click');
this.focus();
if (e.detail === 2) {
this.removePreviewStatus();
Expand Down Expand Up @@ -1173,6 +1171,7 @@ class NotebookPanel extends Component<NotebookPanelProps, NotebookPanelState> {
onTab={this.handleTab}
onResize={this.handleResize}
onShow={this.handleShow}
onTabClicked={this.handleTabClick}
onTabFocus={this.handleTabFocus}
onTabBlur={this.handleTabBlur}
onSessionOpen={this.handleSessionOpened}
Expand Down
6 changes: 3 additions & 3 deletions packages/dashboard-core-plugins/src/panels/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface PanelProps {
onFocus: FocusEventHandler<HTMLDivElement>;
onBlur: FocusEventHandler<HTMLDivElement>;
onTab: (tab: Tab) => void;
onTabClicked: (...args: unknown[]) => void;
onTabClicked: (e: MouseEvent) => void;
onClearAllFilters: (...args: unknown[]) => void;
onHide: (...args: unknown[]) => void;
onResize: (...args: unknown[]) => void;
Expand Down Expand Up @@ -180,9 +180,9 @@ class Panel extends PureComponent<PanelProps, PanelState> {
onTab(tab);
}

handleTabClicked(...args: unknown[]): void {
handleTabClicked(e: MouseEvent): void {
const { onTabClicked } = this.props;
onTabClicked(...args);
onTabClicked(e);
}

handleClearAllFilters(...args: unknown[]): void {
Expand Down

0 comments on commit a1d4f6a

Please sign in to comment.