Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
chore: Remove the ability to open a terminal in a tooling container
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <[email protected]>
  • Loading branch information
RomanNikitenko committed Feb 23, 2022
1 parent 489918f commit 7124cd9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -348,14 +327,9 @@ export class ExecTerminalFrontendContribution extends TerminalFrontendContributi
async registerKeybindings(registry: KeybindingRegistry): Promise<void> {
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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
return this.displayAllContainers(doOpen);
}

async displayContainers(
containers: Container[],
doOpen: OpenTerminalHandler,
showAllItem: boolean = true
): Promise<void> {
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<void> {
const items = [];

const containers = await this.workspaceService.getContainerList();
Expand Down Expand Up @@ -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<void> {
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' });
}
}

0 comments on commit 7124cd9

Please sign in to comment.