diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index c0a0dd57ab06..e1955010a05b 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -143,6 +143,7 @@ export class MenuId { static readonly TimelineTitleContext = new MenuId('TimelineTitleContext'); static readonly AccountsContext = new MenuId('AccountsContext'); static readonly PanelTitle = new MenuId('PanelTitle'); + static readonly AuxiliaryBarTitle = new MenuId('AuxiliaryBarTitle'); static readonly TerminalInstanceContext = new MenuId('TerminalInstanceContext'); static readonly TerminalEditorInstanceContext = new MenuId('TerminalEditorInstanceContext'); static readonly TerminalNewDropdownContext = new MenuId('TerminalNewDropdownContext'); diff --git a/src/vs/workbench/browser/parts/panel/panelActions.ts b/src/vs/workbench/browser/parts/panel/panelActions.ts index 7724818163ea..93715f458966 100644 --- a/src/vs/workbench/browser/parts/panel/panelActions.ts +++ b/src/vs/workbench/browser/parts/panel/panelActions.ts @@ -13,7 +13,7 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions, CATEGORIES import { IWorkbenchLayoutService, PanelAlignment, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService'; import { ActivityAction, ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositeBarActions'; import { IActivity } from 'vs/workbench/common/activity'; -import { PanelAlignmentContext, PanelMaximizedContext, PanelPositionContext, PanelVisibleContext } from 'vs/workbench/common/contextkeys'; +import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelPositionContext, PanelVisibleContext } from 'vs/workbench/common/contextkeys'; import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey'; import { Codicon } from 'vs/base/common/codicons'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; @@ -391,6 +391,28 @@ registerAction2(class extends Action2 { } }); +registerAction2(class extends Action2 { + constructor() { + super({ + id: 'workbench.action.closeAuxiliaryBar', + title: { value: localize('closeSidePanel', "Close Side Panel"), original: 'Close Side Panel' }, + category: CATEGORIES.View, + icon: closeIcon, + menu: [{ + id: MenuId.CommandPalette, + when: AuxiliaryBarVisibleContext, + }, { + id: MenuId.AuxiliaryBarTitle, + group: 'navigation', + order: 2 + }] + }); + } + run(accessor: ServicesAccessor) { + accessor.get(IWorkbenchLayoutService).setPartHidden(true, Parts.AUXILIARYBAR_PART); + } +}); + MenuRegistry.appendMenuItems([ { id: MenuId.MenubarAppearanceMenu, diff --git a/src/vs/workbench/browser/parts/panel/panelPart.ts b/src/vs/workbench/browser/parts/panel/panelPart.ts index a54e908fceec..e671cd4b1448 100644 --- a/src/vs/workbench/browser/parts/panel/panelPart.ts +++ b/src/vs/workbench/browser/parts/panel/panelPart.ts @@ -109,6 +109,9 @@ export abstract class BasePanelPart extends CompositePart impleme private compositeBar: CompositeBar; private readonly compositeActions = new Map(); + private globalToolBar: ToolBar | undefined; + private globalActions: CompositeMenuActions; + private readonly panelDisposables: Map = new Map(); private blockOpeningPanel = false; @@ -201,6 +204,10 @@ export abstract class BasePanelPart extends CompositePart impleme this.registerListeners(); this.onDidRegisterPanels([...this.getPaneComposites()]); + + // Global Panel Actions + this.globalActions = this._register(this.instantiationService.createInstance(CompositeMenuActions, partId === Parts.PANEL_PART ? MenuId.PanelTitle : MenuId.AuxiliaryBarTitle, undefined, undefined)); + this._register(this.globalActions.onDidChange(() => this.updateGlobalToolbarActions())); } protected abstract getActivityHoverOptions(): IActivityHoverOptions; @@ -520,6 +527,24 @@ export abstract class BasePanelPart extends CompositePart impleme })); } + override createTitleArea(parent: HTMLElement): HTMLElement { + const element = super.createTitleArea(parent); + const globalTitleActionsContainer = element.appendChild($('.global-actions')); + + // Global Actions Toolbar + this.globalToolBar = this._register(new ToolBar(globalTitleActionsContainer, this.contextMenuService, { + actionViewItemProvider: action => this.actionViewItemProvider(action), + orientation: ActionsOrientation.HORIZONTAL, + getKeyBinding: action => this.keybindingService.lookupKeybinding(action.id), + anchorAlignmentProvider: () => this.getTitleAreaDropDownAnchorAlignment(), + toggleMenuTitle: localize('moreActions', "More Actions...") + })); + + this.updateGlobalToolbarActions(); + + return element; + } + override updateStyles(): void { super.updateStyles(); @@ -685,6 +710,15 @@ export abstract class BasePanelPart extends CompositePart impleme return viewContainer && this.viewDescriptorService.getViewContainerLocation(viewContainer) === this.viewContainerLocation ? viewContainer : undefined; } + private updateGlobalToolbarActions(): void { + const primaryActions = this.globalActions.getPrimaryActions(); + const secondaryActions = this.globalActions.getSecondaryActions(); + + if (this.globalToolBar) { + this.globalToolBar.setActions(prepareActions(primaryActions), prepareActions(secondaryActions)); + } + } + private getCompositeActions(compositeId: string): { activityAction: PanelActivityAction; pinnedAction: ToggleCompositePinnedAction } { let compositeActions = this.compositeActions.get(compositeId); if (!compositeActions) { @@ -732,7 +766,7 @@ export abstract class BasePanelPart extends CompositePart impleme return 0; } - return this.toolBar.getItemsWidth(); + return this.toolBar.getItemsWidth() + (this.globalToolBar?.getItemsWidth() ?? 0); } private onDidStorageValueChange(e: IStorageValueChangeEvent): void { @@ -866,9 +900,6 @@ export class PanelPart extends BasePanelPart { static readonly pinnedPanelsKey = 'workbench.panel.pinnedPanels'; static readonly placeholdeViewContainersKey = 'workbench.panel.placeholderPanels'; - private globalToolBar: ToolBar | undefined; - private globalActions: CompositeMenuActions; - constructor( @INotificationService notificationService: INotificationService, @IStorageService storageService: IStorageService, @@ -908,10 +939,6 @@ export class PanelPart extends BasePanelPart { hasTitle: true }, ); - - // Global Panel Actions - this.globalActions = this._register(this.instantiationService.createInstance(CompositeMenuActions, MenuId.PanelTitle, undefined, undefined)); - this._register(this.globalActions.onDidChange(() => this.updateGlobalToolbarActions())); } override updateStyles(): void { @@ -947,28 +974,6 @@ export class PanelPart extends BasePanelPart { ]); } - override createTitleArea(parent: HTMLElement): HTMLElement { - const element = super.createTitleArea(parent); - const globalTitleActionsContainer = element.appendChild($('.global-actions')); - - // Global Actions Toolbar - this.globalToolBar = this._register(new ToolBar(globalTitleActionsContainer, this.contextMenuService, { - actionViewItemProvider: action => this.actionViewItemProvider(action), - orientation: ActionsOrientation.HORIZONTAL, - getKeyBinding: action => this.keybindingService.lookupKeybinding(action.id), - anchorAlignmentProvider: () => this.getTitleAreaDropDownAnchorAlignment(), - toggleMenuTitle: localize('moreActions', "More Actions...") - })); - - this.updateGlobalToolbarActions(); - - return element; - } - - override getToolbarWidth(): number { - return super.getToolbarWidth() + (this.globalToolBar?.getItemsWidth() ?? 0); - } - override layout(width: number, height: number, top: number, left: number): void { let dimensions: Dimension; if (this.layoutService.getPanelPosition() === Position.RIGHT) { @@ -981,15 +986,6 @@ export class PanelPart extends BasePanelPart { super.layout(dimensions.width, dimensions.height, top, left); } - private updateGlobalToolbarActions(): void { - const primaryActions = this.globalActions.getPrimaryActions(); - const secondaryActions = this.globalActions.getSecondaryActions(); - - if (this.globalToolBar) { - this.globalToolBar.setActions(prepareActions(primaryActions), prepareActions(secondaryActions)); - } - } - toJSON(): object { return { type: Parts.PANEL_PART