From 78c02c70f5490e8074e981d182bf6a6068e69d9d Mon Sep 17 00:00:00 2001 From: Grzegorz Zdunek Date: Fri, 18 Mar 2022 10:48:51 +0100 Subject: [PATCH] take `localClusterUri` into account in `QuickInput` --- .../src/ui/QuickInput/useQuickInput.ts | 2 +- .../src/ui/services/quickInput/quickPickers.ts | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/teleterm/src/ui/QuickInput/useQuickInput.ts b/packages/teleterm/src/ui/QuickInput/useQuickInput.ts index 5a3319678b..b7fd10b118 100644 --- a/packages/teleterm/src/ui/QuickInput/useQuickInput.ts +++ b/packages/teleterm/src/ui/QuickInput/useQuickInput.ts @@ -36,7 +36,7 @@ export default function useQuickInput() { const [activeSuggestion, setActiveSuggestion] = React.useState(0); const autocompleteResult = React.useMemo( () => quickInputService.getAutocompleteResult(inputValue), - [inputValue] + [inputValue, workspacesService.getActiveWorkspace()?.localClusterUri] ); const hasSuggestions = autocompleteResult.kind === 'autocomplete.partial-match'; diff --git a/packages/teleterm/src/ui/services/quickInput/quickPickers.ts b/packages/teleterm/src/ui/services/quickInput/quickPickers.ts index d2b9925488..76a4a5e3d5 100644 --- a/packages/teleterm/src/ui/services/quickInput/quickPickers.ts +++ b/packages/teleterm/src/ui/services/quickInput/quickPickers.ts @@ -268,10 +268,13 @@ export class QuickSshLoginPicker implements QuickInputPicker { ) {} private filterSshLogins(input: string): SuggestionSshLogin[] { - // TODO(ravicious): Use local cluster URI. // TODO(ravicious): Handle the `--cluster` tsh ssh flag. - const rootClusterUri = this.workspacesService.getRootClusterUri(); - const cluster = this.clustersService.findCluster(rootClusterUri); + const localClusterUri = + this.workspacesService.getActiveWorkspace()?.localClusterUri; + if (!localClusterUri) { + return []; + } + const cluster = this.clustersService.findCluster(localClusterUri); const allLogins = cluster?.loggedInUser?.sshLoginsList || []; let matchingLogins: typeof allLogins; @@ -315,10 +318,13 @@ export class QuickServerPicker implements QuickInputPicker { ) {} private filterServers(input: string): SuggestionServer[] { - // TODO(ravicious): Use local cluster URI. // TODO(ravicious): Handle the `--cluster` tsh ssh flag. - const rootClusterUri = this.workspacesService.getRootClusterUri(); - const servers = this.clustersService.searchServers(rootClusterUri, { + const localClusterUri = + this.workspacesService.getActiveWorkspace()?.localClusterUri; + if (!localClusterUri) { + return []; + } + const servers = this.clustersService.searchServers(localClusterUri, { search: input, });