Skip to content

Commit

Permalink
feat: Add 'New Terminal (Select a Container)' action to Terminal and …
Browse files Browse the repository at this point in the history
…terminal's context menu

Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
  • Loading branch information
RomanNikitenko committed Apr 3, 2023
1 parent 41ffb1c commit 710a43b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**********************************************************************
* Copyright (c) 2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
***********************************************************************/
/* eslint-disable header/header */

import { localize } from 'vs/nls';
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { TerminalMenuBarGroup } from 'vs/workbench/contrib/terminal/browser/terminalMenus';

// see enum ContextMenuGroup in the terminalMenus
const CONTEXT_MENU_GROUP_CREATE = '1_create';
const NEW_TERMINAL_IN_CONTAINER_COMMAND_ID = 'che-terminal.new';
const NEW_TERMINAL_IN_CONTAINER_TITLE = localize('newTerminal.selectContainer.title', 'New Terminal (Select a Container)');

export function setupCheTerminalMenus(): void {
MenuRegistry.appendMenuItems(
[
{
id: MenuId.MenubarTerminalMenu,
item: {
group: TerminalMenuBarGroup.Create,
command: {
id: NEW_TERMINAL_IN_CONTAINER_COMMAND_ID,
title: NEW_TERMINAL_IN_CONTAINER_TITLE
},
order: 1.5
}
}
]
);

MenuRegistry.appendMenuItems(
[
{
id: MenuId.TerminalInstanceContext,
item: {
command: {
id: NEW_TERMINAL_IN_CONTAINER_COMMAND_ID,
title: NEW_TERMINAL_IN_CONTAINER_TITLE
},
group: CONTEXT_MENU_GROUP_CREATE
}
}
]
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { RemoteTerminalBackendContribution } from 'vs/workbench/contrib/terminal
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { TerminalMainContribution } from 'vs/workbench/contrib/terminal/browser/terminalMainContribution';
import { Schemas } from 'vs/base/common/network';
import { setupCheTerminalMenus } from 'vs/workbench/contrib/terminal/browser/che/terminalMenus';

// Register services
registerSingleton(ITerminalService, TerminalService, InstantiationType.Delayed);
Expand Down Expand Up @@ -282,5 +283,6 @@ registerSendSequenceKeybinding('\u001f', {
setupTerminalCommands();

setupTerminalMenus();
setupCheTerminalMenus();

registerColors();

0 comments on commit 710a43b

Please sign in to comment.