Skip to content

Commit fd0b236

Browse files
committed
Clean up based on review
1 parent 878a9ed commit fd0b236

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

packages/console/src/Console.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ interface ConsoleProps {
5656
/** Additional children to show in the objects menu */
5757
statusBarChildren: ReactNode;
5858

59-
/** Hide the objects menu in the status bar. Defaults to false. */
60-
hideObjectsMenu?: boolean;
59+
/** Show the objects menu in the status bar. Defaults to true. */
60+
showObjectsMenu?: boolean;
6161

6262
settings: Partial<Settings>;
6363
focusCommandHistory: () => void;
@@ -148,6 +148,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
148148
unzip: null,
149149
supportsType: defaultSupportsType,
150150
iconForType: defaultIconForType,
151+
showObjectsMenu: true,
151152
};
152153

153154
static LOG_THROTTLE = 500;
@@ -996,7 +997,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
996997
unzip,
997998
supportsType,
998999
iconForType,
999-
hideObjectsMenu,
1000+
showObjectsMenu,
10001001
} = this.props;
10011002
const {
10021003
consoleHeight,
@@ -1025,7 +1026,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
10251026
overflowActions={this.handleOverflowActions}
10261027
>
10271028
{statusBarChildren}
1028-
{hideObjectsMenu !== true && (
1029+
{showObjectsMenu === true && (
10291030
<ConsoleObjectsMenu
10301031
openObject={openObject}
10311032
objects={consoleMenuObjects}

packages/console/src/ConsoleObjectsMenu.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@deephaven/components';
99
import { vsGraph, vsTriangleDown } from '@deephaven/icons';
1010
import type { dh as DhType } from '@deephaven/jsapi-types';
11+
import { EMPTY_FUNCTION } from '@deephaven/utils';
1112
import { ObjectIcon } from './common';
1213

1314
interface ConsoleObjectsMenuProps {
@@ -40,7 +41,7 @@ function ConsoleObjectsMenu({
4041
};
4142
const filteredObjects = filterText
4243
? objects.filter(
43-
({ title }: { title?: string }) =>
44+
({ title }) =>
4445
title != null &&
4546
title.toLowerCase().includes(filterText.toLowerCase())
4647
)
@@ -60,9 +61,7 @@ function ConsoleObjectsMenu({
6061
aria-label="Objects"
6162
kind="ghost"
6263
disabled={objects.length === 0}
63-
onClick={() => {
64-
// no-op: click is handled in `DropdownMenu`
65-
}}
64+
onClick={EMPTY_FUNCTION}
6665
tooltip={objects.length === 0 ? 'No objects available' : 'Objects'}
6766
icon={
6867
<div className="fa-md fa-layers">
@@ -78,7 +77,9 @@ function ConsoleObjectsMenu({
7877
<DropdownMenu
7978
actions={actions}
8079
onMenuOpened={() => searchRef.current?.focus()}
81-
onMenuClosed={() => setFilterText('')}
80+
onMenuClosed={() => {
81+
searchRef.current?.focus();
82+
}}
8283
options={{ initialKeyboardIndex: 1 }}
8384
popperOptions={{ placement: 'bottom-end' }}
8485
/>

packages/console/src/ConsoleStatusBar.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
Tooltip,
1717
} from '@deephaven/components';
1818
import './ConsoleStatusBar.scss';
19+
import { EMPTY_FUNCTION } from '@deephaven/utils';
1920

2021
const POPPER_OPTIONS: PopperOptions = { placement: 'bottom-end' };
2122

@@ -32,19 +33,19 @@ function ConsoleStatusBar({
3233
session,
3334
overflowActions,
3435
}: ConsoleStatusBarProps): ReactElement {
35-
const [isCommandRunning, setIsCommandRunning] = useState(false);
36+
const [pendingCommandCount, setPendingCommandCount] = useState(0);
3637

3738
const handleCommandStarted = useCallback(async (event: CustomEvent) => {
38-
setIsCommandRunning(true);
39+
setPendingCommandCount(count => count + 1);
3940

40-
const { result } = event.detail;
4141
try {
42+
const { result } = event.detail;
4243
await result;
4344
} catch (error) {
4445
// No-op, fall through
4546
}
4647

47-
setIsCommandRunning(false);
48+
setPendingCommandCount(count => count - 1);
4849
}, []);
4950

5051
useEffect(
@@ -66,7 +67,7 @@ function ConsoleStatusBar({
6667

6768
let statusIconClass = null;
6869
let tooltipText = null;
69-
if (isCommandRunning) {
70+
if (pendingCommandCount > 0) {
7071
// Connected, Pending
7172
statusIconClass = 'console-status-icon-pending';
7273
tooltipText = 'Worker is busy';
@@ -93,9 +94,7 @@ function ConsoleStatusBar({
9394
icon={vsKebabVertical}
9495
tooltip="More Actions..."
9596
aria-label="More Actions..."
96-
onClick={() => {
97-
// no-op: click is handled in `DropdownMenu`
98-
}}
97+
onClick={EMPTY_FUNCTION}
9998
>
10099
<DropdownMenu
101100
actions={overflowActions}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export class ConsolePanel extends PureComponent<
440440
/>
441441
</>
442442
}
443-
hideObjectsMenu
443+
showObjectsMenu={false}
444444
scope={sessionId}
445445
timeZone={timeZone}
446446
objectMap={objectMap}

0 commit comments

Comments
 (0)