Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceControl - scm/inputBox menu proposal #195475

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class MenuId {
static readonly SCMResourceFolderContext = new MenuId('SCMResourceFolderContext');
static readonly SCMResourceGroupContext = new MenuId('SCMResourceGroupContext');
static readonly SCMSourceControl = new MenuId('SCMSourceControl');
static readonly SCMInputBox = new MenuId('SCMInputBox');
static readonly SCMTitle = new MenuId('SCMTitle');
static readonly SearchContext = new MenuId('SearchContext');
static readonly SearchActionMenu = new MenuId('SearchActionContext');
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/contrib/scm/browser/media/scm.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@
border-radius: 2px;
}

.scm-view .scm-input .actions {
position: absolute;
top: 6px;
right: 20px;
border: 1px solid var(--vscode-toolbar-hoverBackground);
border-radius: 5px;
}

.scm-view .scm-editor-container .monaco-editor {
border-radius: 2px;
}
Expand Down
10 changes: 10 additions & 0 deletions src/vs/workbench/contrib/scm/browser/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
return this._repositoryMenu;
}

private _inputBoxMenu: IMenu | undefined;
get inputBoxMenu(): IMenu {
if (!this._inputBoxMenu) {
this._inputBoxMenu = this.menuService.createMenu(MenuId.SCMInputBox, this.contextKeyService);
this.disposables.add(this._inputBoxMenu);
}

return this._inputBoxMenu;
}

private readonly disposables = new DisposableStore();

constructor(
Expand Down
17 changes: 15 additions & 2 deletions src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class SCMTreeDragAndDrop implements ITreeDragAndDrop<TreeElement> {
interface InputTemplate {
readonly inputWidget: SCMInputWidget;
inputWidgetHeight: number;
actionBar: ActionBar;
readonly elementDisposables: DisposableStore;
readonly templateDisposable: IDisposable;
}
Expand All @@ -246,7 +247,9 @@ class InputRenderer implements ICompressibleTreeRenderer<ISCMInput, FuzzyScore,
private outerLayout: ISCMLayout,
private overflowWidgetsDomNode: HTMLElement,
private updateHeight: (input: ISCMInput, height: number) => void,
private actionViewItemProvider: IActionViewItemProvider,
@IInstantiationService private instantiationService: IInstantiationService,
@ISCMViewService private scmViewService: ISCMViewService
) { }

renderTemplate(container: HTMLElement): InputTemplate {
Expand All @@ -261,7 +264,10 @@ class InputRenderer implements ICompressibleTreeRenderer<ISCMInput, FuzzyScore,
const inputWidget = this.instantiationService.createInstance(SCMInputWidget, inputElement, this.overflowWidgetsDomNode);
templateDisposable.add(inputWidget);

return { inputWidget, inputWidgetHeight: InputRenderer.DEFAULT_HEIGHT, elementDisposables: new DisposableStore(), templateDisposable };
const actionsContainer = append(inputElement, $('.actions'));
const actionBar = new ActionBar(actionsContainer, { actionViewItemProvider: this.actionViewItemProvider });

return { inputWidget, inputWidgetHeight: InputRenderer.DEFAULT_HEIGHT, actionBar, elementDisposables: new DisposableStore(), templateDisposable };
}

renderElement(node: ITreeNode<ISCMInput, FuzzyScore>, index: number, templateData: InputTemplate): void {
Expand Down Expand Up @@ -314,6 +320,13 @@ class InputRenderer implements ICompressibleTreeRenderer<ISCMInput, FuzzyScore,
const layoutEditor = () => templateData.inputWidget.layout();
templateData.elementDisposables.add(this.outerLayout.onDidChange(layoutEditor));
layoutEditor();

// Action bar
templateData.actionBar.clear();
templateData.actionBar.context = input.repository.provider;

const menus = this.scmViewService.menus.getRepositoryMenus(input.repository.provider);
templateData.elementDisposables.add(connectPrimaryMenuToInlineActionBar(menus.inputBoxMenu, templateData.actionBar));
}

renderCompressedElements(): void {
Expand Down Expand Up @@ -2348,7 +2361,7 @@ export class SCMViewPane extends ViewPane {
this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.providerCountBadge'), this.disposables)(updateProviderCountVisibility));
updateProviderCountVisibility();

this.inputRenderer = this.instantiationService.createInstance(InputRenderer, this.layoutCache, overflowWidgetsDomNode, (input, height) => this.tree.updateElementHeight(input, height));
this.inputRenderer = this.instantiationService.createInstance(InputRenderer, this.layoutCache, overflowWidgetsDomNode, (input, height) => this.tree.updateElementHeight(input, height), getActionViewItemProvider(this.instantiationService));
const delegate = new ListDelegate(this.inputRenderer);

this.actionButtonRenderer = this.instantiationService.createInstance(ActionButtonRenderer);
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/scm/common/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export interface ISCMTitleMenu {
export interface ISCMRepositoryMenus {
readonly titleMenu: ISCMTitleMenu;
readonly repositoryMenu: IMenu;
readonly inputBoxMenu: IMenu;
getResourceGroupMenu(group: ISCMResourceGroup): IMenu;
getResourceMenu(resource: ISCMResource): IMenu;
getResourceFolderMenu(group: ISCMResourceGroup): IMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ const apiMenus: IAPIMenu[] = [
id: MenuId.SCMSourceControl,
description: localize('menus.scmSourceControl', "The Source Control menu")
},
{
key: 'scm/inputBox',
id: MenuId.SCMInputBox,
description: localize('menus.scmInputBox', "The Source Control input box menu"),
proposed: 'contribSourceControlInputBoxMenu'
},
{
key: 'scm/resourceState/context',
id: MenuId.SCMResourceContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const allApiProposals = Object.freeze({
contribNotebookStaticPreloads: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribNotebookStaticPreloads.d.ts',
contribRemoteHelp: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribRemoteHelp.d.ts',
contribShareMenu: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribShareMenu.d.ts',
contribSourceControlInputBoxMenu: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribSourceControlInputBoxMenu.d.ts',
contribStatusBarItems: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribStatusBarItems.d.ts',
contribViewsRemote: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribViewsRemote.d.ts',
contribViewsWelcome: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribViewsWelcome.d.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// empty placeholder declaration for the `scm/inputBox` menu contribution point
// https://github.com/microsoft/vscode/issues/195474