Skip to content

Commit

Permalink
feat: Refactor console objects menu (#2013)
Browse files Browse the repository at this point in the history
- Split ConsoleMenu up so objects is it's own component
ConsoleObjectsMenu
- Convert to functional component
- Display all widgets in the menu
- Add a flag to hide the menu, which we set for DHC, but will not be set
in DHE so current behaviour is not broken there
- Fixes #1884

---------

Co-authored-by: Matthew Runyon <matthewrunyon@deephaven.io>
  • Loading branch information
mofojed and mattrunyon committed Aug 14, 2024
1 parent 5f9cf7f commit 8251180
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 410 deletions.
4 changes: 4 additions & 0 deletions packages/components/src/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class SearchInput extends PureComponent<SearchInputProps> {
this.inputField.current?.focus();
}

select(): void {
this.inputField.current?.select();
}

inputField: React.RefObject<HTMLInputElement>;

searchChangeSelection: React.RefObject<HTMLDivElement>;
Expand Down
22 changes: 17 additions & 5 deletions packages/console/src/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
CommandHistoryStorage,
CommandHistoryStorageItem,
} from './command-history';
import ConsoleObjectsMenu from './ConsoleObjectsMenu';

const log = Log.module('Console');

Expand All @@ -51,7 +52,13 @@ const DEFAULT_SETTINGS: Settings = {

interface ConsoleProps {
dh: typeof DhType;

/** Additional children to show in the status bar */
statusBarChildren: ReactNode;

/** Show the objects menu in the status bar. Defaults to true. */
showObjectsMenu?: boolean;

settings: Partial<Settings>;
focusCommandHistory: () => void;

Expand Down Expand Up @@ -141,6 +148,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
unzip: null,
supportsType: defaultSupportsType,
iconForType: defaultIconForType,
showObjectsMenu: true,
};

static LOG_THROTTLE = 500;
Expand Down Expand Up @@ -905,9 +913,8 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
}

getObjects = memoize(
(objectMap: Map<string, DhType.ide.VariableDefinition>) => [
...objectMap.values(),
]
(objectMap: Map<string, DhType.ide.VariableDefinition>) =>
Array.from(objectMap.values())
);

getContextActions = memoize(
Expand Down Expand Up @@ -990,6 +997,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
unzip,
supportsType,
iconForType,
showObjectsMenu,
} = this.props;
const {
consoleHeight,
Expand All @@ -1016,10 +1024,14 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
dh={dh}
session={session}
overflowActions={this.handleOverflowActions}
openObject={openObject}
objects={consoleMenuObjects}
>
{statusBarChildren}
{showObjectsMenu === true && (
<ConsoleObjectsMenu
openObject={openObject}
objects={consoleMenuObjects}
/>
)}
</ConsoleStatusBar>
<div
className="console-csv-container"
Expand Down
271 changes: 0 additions & 271 deletions packages/console/src/ConsoleMenu.tsx

This file was deleted.

Loading

0 comments on commit 8251180

Please sign in to comment.