Skip to content

Commit

Permalink
fix: Search filtering now works in PANELS (#177)
Browse files Browse the repository at this point in the history
I fixed a bug where I was setting description instead of label that was
breaking built in search / filter in the "PANELS" treeview. Also added
search actions to the titlebar of CONNECTIONS + PANELS trees

### Testing
```python
from deephaven import empty_table

for i in range(100):
    print(f"Making {i}")
    globals()[f"t{i}"] = empty_table(10).update(['X = i', 'Y = 10 * i'])
```

- Hover the title of the PANELS tree
- Click the search icon (magnifying glass)
- Type the name of a variable to filter on
- Should scroll to the variable. Clicking the filter button in the
search box should actually filter the results

resolves #49
  • Loading branch information
bmingles authored Nov 18, 2024
1 parent 5d844b0 commit b095482
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 18 deletions.
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
"command": "vscode-deephaven.createDHEAuthenticatedClient",
"title": "Create DHE Authenticated Client"
},
{
"command": "vscode-deephaven.searchConnections",
"title": "Search Connections",
"icon": "$(search)"
},
{
"command": "vscode-deephaven.searchPanels",
"title": "Search Panels",
"icon": "$(search)"
},
{
"command": "vscode-deephaven.startServer",
"title": "Deephaven: Start Server",
Expand Down Expand Up @@ -703,6 +713,14 @@
"command": "vscode-deephaven.refreshVariablePanels",
"when": "false"
},
{
"command": "vscode-deephaven.searchConnections",
"when": "false"
},
{
"command": "vscode-deephaven.searchPanels",
"when": "false"
},
{
"command": "vscode-deephaven.createCoreAuthenticatedClient",
"when": "false"
Expand Down Expand Up @@ -746,6 +764,16 @@
"command": "vscode-deephaven.refreshServerConnectionTree",
"group": "navigation",
"when": "view == vscode-deephaven.serverConnectionTree"
},
{
"command": "vscode-deephaven.searchConnections",
"group": "navigation",
"when": "view == vscode-deephaven.serverConnectionTree"
},
{
"command": "vscode-deephaven.searchPanels",
"group": "navigation",
"when": "view == vscode-deephaven.serverConnectionPanelTree"
}
],
"view/item/context": [
Expand Down
2 changes: 2 additions & 0 deletions src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const REFRESH_SERVER_CONNECTION_TREE_CMD = cmd(
export const REFRESH_VARIABLE_PANELS_CMD = cmd('refreshVariablePanels');
export const RUN_CODE_COMMAND = cmd('runCode');
export const RUN_SELECTION_COMMAND = cmd('runSelection');
export const SEARCH_CONNECTIONS_CMD = cmd('searchConnections');
export const SEARCH_PANELS_CMD = cmd('searchPanels');
export const SELECT_CONNECTION_COMMAND = cmd('selectConnection');
export const START_SERVER_CMD = cmd('startServer');
export const STOP_SERVER_CMD = cmd('stopServer');
2 changes: 2 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const VIEW_ID = {
serverConnectionPanelTree: `${EXTENSION_ID}.serverConnectionPanelTree`,
} as const;

export type ViewID = (typeof VIEW_ID)[keyof typeof VIEW_ID];

export const ICON_ID = {
blank: 'blank',
connected: 'vm-connect',
Expand Down
8 changes: 5 additions & 3 deletions src/controllers/ControllerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export abstract class ControllerBase implements Disposable {
/**
* Register a command and add it's subscription to the disposables list.
*/
registerCommand = (
...args: Parameters<typeof vscode.commands.registerCommand>
registerCommand = <TThis = any>(
command: string,
callback: (this: TThis, ...args: any[]) => any,
thisArg?: TThis
): void => {
const cmd = vscode.commands.registerCommand(...args);
const cmd = vscode.commands.registerCommand(command, callback, thisArg);
this.disposables.push(cmd);
};

Expand Down
33 changes: 30 additions & 3 deletions src/controllers/ExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import {
REFRESH_SERVER_TREE_CMD,
RUN_CODE_COMMAND,
RUN_SELECTION_COMMAND,
SEARCH_CONNECTIONS_CMD,
SEARCH_PANELS_CMD,
SELECT_CONNECTION_COMMAND,
START_SERVER_CMD,
STOP_SERVER_CMD,
VIEW_ID,
type ViewID,
} from '../common';
import {
assertDefined,
Expand Down Expand Up @@ -500,6 +503,20 @@ export class ExtensionController implements Disposable {
this.onRefreshServerStatus
);

/** Search connections */
this.registerCommand(
SEARCH_CONNECTIONS_CMD,
this.onSearchTree,
VIEW_ID.serverConnectionTree
);

/** Search variable panels */
this.registerCommand(
SEARCH_PANELS_CMD,
this.onSearchTree,
VIEW_ID.serverConnectionPanelTree
);

/** Start a server */
this.registerCommand(START_SERVER_CMD, this.onStartServer);

Expand Down Expand Up @@ -776,6 +793,14 @@ export class ExtensionController implements Disposable {
this.onRunCode(uri, arg, true);
};

/**
* Open search input for tree panel.
*/
onSearchTree = async function (this: ViewID): Promise<void> {
vscode.commands.executeCommand(`${this}.focus`);
vscode.commands.executeCommand('list.find');
};

/**
* Start a server.
*/
Expand All @@ -794,10 +819,12 @@ export class ExtensionController implements Disposable {
/**
* Register a command and add it's subscription to the context.
*/
registerCommand = (
...args: Parameters<typeof vscode.commands.registerCommand>
registerCommand = <TThis = any>(
command: string,
callback: (this: TThis, ...args: any[]) => any,
thisArg?: TThis
): void => {
const cmd = vscode.commands.registerCommand(...args);
const cmd = vscode.commands.registerCommand(command, callback, thisArg);
this._context.subscriptions.push(cmd);
};
}
22 changes: 11 additions & 11 deletions src/util/__snapshots__/treeViewUtils.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "graph",
},
"label": "some title",
}
`;

Expand All @@ -86,11 +86,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-table",
},
"label": "some title",
}
`;

Expand All @@ -109,11 +109,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "preview",
},
"label": "some title",
}
`;

Expand All @@ -132,11 +132,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-table",
},
"label": "some title",
}
`;

Expand All @@ -155,11 +155,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-table",
},
"label": "some title",
}
`;

Expand All @@ -178,11 +178,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-table",
},
"label": "some title",
}
`;

Expand All @@ -201,11 +201,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-table",
},
"label": "some title",
}
`;

Expand All @@ -224,11 +224,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "preview",
},
"label": "some title",
}
`;

Expand All @@ -247,11 +247,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "graph",
},
"label": "some title",
}
`;

Expand All @@ -270,11 +270,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "preview",
},
"label": "some title",
}
`;

Expand All @@ -293,11 +293,11 @@ exports[`getPanelVariableTreeItem > should return panel variable tree item: type
"command": "vscode-deephaven.openVariablePanels",
"title": "Open Panel",
},
"description": "some title",
"iconPath": {
"color": undefined,
"id": "dh-pandas",
},
"label": "some title",
}
`;

Expand Down
2 changes: 1 addition & 1 deletion src/util/treeViewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function getPanelVariableTreeItem([url, variable]: [
const iconPath = getVariableIconPath(variable.type);

return {
description: variable.title,
label: variable.title,
iconPath,
command: {
title: 'Open Panel',
Expand Down

0 comments on commit b095482

Please sign in to comment.