Skip to content

Commit

Permalink
#30249 Add Hide Side Bar action
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jul 12, 2017
1 parent f5902b5 commit de02dda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/vs/workbench/browser/parts/compositePart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import errors = require('vs/base/common/errors');
import * as DOM from 'vs/base/browser/dom';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { CONTEXT as ToolBarContext, ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { IActionItem, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActionItem, ActionsOrientation, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import { IActionBarRegistry, Extensions, prepareActions } from 'vs/workbench/browser/actions';
import { Action, IAction } from 'vs/base/common/actions';
Expand All @@ -39,6 +39,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
import { ToggleSidebarVisibilityAction } from 'vs/workbench/browser/actions/toggleSidebarVisibility';

export interface ICompositeTitleLabel {

Expand Down Expand Up @@ -478,6 +479,10 @@ export abstract class CompositePart<T extends Composite> extends Part {

private onContextMenu(event: StandardMouseEvent): void {
const contextMenuActions = this.activeComposite ? this.activeComposite.getContextMenuActions() : [];
if (contextMenuActions.length) {
contextMenuActions.push(new Separator());
}
contextMenuActions.push(this.createHideSideBarAction());
if (contextMenuActions.length) {
let anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
this.contextMenuService.showContextMenu({
Expand All @@ -490,6 +495,15 @@ export abstract class CompositePart<T extends Composite> extends Part {
}
}

private createHideSideBarAction(): IAction {
return <IAction>{
id: ToggleSidebarVisibilityAction.ID,
label: nls.localize('compositePart.hideSideBarLabel', "Hide Side Bar"),
enabled: true,
run: () => this.partService.setSideBarHidden(true)
};
}

private actionItemProvider(action: Action): IActionItem {
let actionItem: IActionItem;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/views/browser/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ export class ComposedViewsViewlet extends Viewlet {
getAnchor: () => anchor,
getActions: () => TPromise.as([<IAction>{
id: `${view.id}.removeView`,
label: nls.localize('removeView', "Remove from {0} View", this.getTitle()),
label: nls.localize('removeView', "Remove from Side Bar"),
enabled: true,
run: () => this.toggleViewVisibility(view.id)
}]),
Expand Down

0 comments on commit de02dda

Please sign in to comment.