From 7124cd944c1901f055eedeeff56285a3ddeb0768 Mon Sep 17 00:00:00 2001 From: Roman Nikitenko Date: Wed, 23 Feb 2022 14:56:18 +0200 Subject: [PATCH] chore: Remove the ability to open a terminal in a tooling container Signed-off-by: Roman Nikitenko --- .../exec-terminal-contribution.ts | 36 ++---------- .../contribution/terminal-quick-open.ts | 56 +++++++------------ 2 files changed, 24 insertions(+), 68 deletions(-) diff --git a/extensions/eclipse-che-theia-terminal/src/browser/contribution/exec-terminal-contribution.ts b/extensions/eclipse-che-theia-terminal/src/browser/contribution/exec-terminal-contribution.ts index a6ca07ec3..67a8b6ec8 100644 --- a/extensions/eclipse-che-theia-terminal/src/browser/contribution/exec-terminal-contribution.ts +++ b/extensions/eclipse-che-theia-terminal/src/browser/contribution/exec-terminal-contribution.ts @@ -36,20 +36,11 @@ import { filterDevContainers } from './terminal-command-filter'; import { isOSX } from '@theia/core/lib/common/os'; /** - * The command should display all containers at a terminal creation, - * {@link NewTerminal} should be used to display only developer containers + * The command creates a terminal in the given container. + * Only developer containers are displayed as quick-pick items if no container is passed for the command execution. */ export const NewTerminalInSpecificContainer = { id: 'terminal-in-specific-container:new', - label: 'New Terminal in specific container', -}; - -/** - * The command should display only developer containers at a terminal creation, - * {@link NewTerminalInSpecificContainer} should be used to display all containers - */ -export const NewTerminal = { - id: 'che-terminal:new', label: 'New Terminal', }; @@ -87,18 +78,6 @@ export class ExecTerminalFrontendContribution extends TerminalFrontendContributi const serverUrl = await this.termApiEndPointProvider(); if (serverUrl) { registry.registerCommand(NewTerminalInSpecificContainer, { - execute: (containerNameToExecute: string) => { - if (containerNameToExecute) { - this.openTerminalByContainerName(containerNameToExecute); - } else { - this.terminalQuickOpen.displayAllContainers(containerName => { - this.openTerminalByContainerName(containerName); - }); - } - }, - }); - - registry.registerCommand(NewTerminal, { execute: (containerNameToExecute: string) => { if (containerNameToExecute) { this.openTerminalByContainerName(containerNameToExecute); @@ -321,8 +300,8 @@ export class ExecTerminalFrontendContribution extends TerminalFrontendContributi if (serverUrl) { menus.registerSubmenu(TerminalMenus.TERMINAL, 'Terminal'); menus.registerMenuAction(TerminalMenus.TERMINAL_NEW, { - commandId: NewTerminal.id, - label: NewTerminal.label, + commandId: NewTerminalInSpecificContainer.id, + label: NewTerminalInSpecificContainer.label, }); } else { super.registerMenus(menus); @@ -348,14 +327,9 @@ export class ExecTerminalFrontendContribution extends TerminalFrontendContributi async registerKeybindings(registry: KeybindingRegistry): Promise { const serverUrl = await this.termApiEndPointProvider(); if (serverUrl) { - registry.registerKeybinding({ - command: NewTerminal.id, - keybinding: isOSX ? 'ctrl+shift+`' : 'ctrl+`', - }); - registry.registerKeybinding({ command: NewTerminalInSpecificContainer.id, - keybinding: 'shift+alt+`', + keybinding: isOSX ? 'ctrl+shift+`' : 'ctrl+`', }); registry.registerKeybinding({ diff --git a/extensions/eclipse-che-theia-terminal/src/browser/contribution/terminal-quick-open.ts b/extensions/eclipse-che-theia-terminal/src/browser/contribution/terminal-quick-open.ts index e7e64e01b..23f0a1e92 100644 --- a/extensions/eclipse-che-theia-terminal/src/browser/contribution/terminal-quick-open.ts +++ b/extensions/eclipse-che-theia-terminal/src/browser/contribution/terminal-quick-open.ts @@ -29,44 +29,8 @@ export class TerminalQuickOpenService { @inject(KeybindingRegistry) protected readonly keybindingRegistry: KeybindingRegistry; - /** @deprecated use {@link displayContainers} or {@link displayAllContainers} instead */ + /** @deprecated use {@link displayContainers} instead */ async displayListMachines(doOpen: OpenTerminalHandler): Promise { - return this.displayAllContainers(doOpen); - } - - async displayContainers( - containers: Container[], - doOpen: OpenTerminalHandler, - showAllItem: boolean = true - ): Promise { - if (containers.length < 1) { - return; - } - - const items: QuickPickItem[] = containers.map( - container => - ({ - label: container.name, - execute: () => { - setTimeout(() => doOpen(container.name), 0); - }, - } as QuickPickItem) - ); - - if (showAllItem) { - items.push({ type: 'separator', label: '' }); - items.push({ - label: 'Show All Containers...', - execute: () => { - setTimeout(() => this.displayAllContainers(doOpen), 0); - }, - } as QuickPickItem); - } - - this.quickInputService.showQuickPick(items, { placeholder: 'Select a container to create a new terminal' }); - } - - async displayAllContainers(doOpen: OpenTerminalHandler): Promise { const items = []; const containers = await this.workspaceService.getContainerList(); @@ -107,4 +71,22 @@ export class TerminalQuickOpenService { this.quickInputService.showQuickPick(items, { placeholder: 'Select container to create a new terminal' }); } + + async displayContainers(containers: Container[], doOpen: OpenTerminalHandler): Promise { + if (containers.length < 1) { + return; + } + + const items: QuickPickItem[] = containers.map( + container => + ({ + label: container.name, + execute: () => { + setTimeout(() => doOpen(container.name), 0); + }, + } as QuickPickItem) + ); + + this.quickInputService.showQuickPick(items, { placeholder: 'Select a container to create a new terminal' }); + } }