Skip to content

Commit

Permalink
[navigator] don't apply collapse all item to all widgets
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov authored and jbicker committed Mar 22, 2019
1 parent 06d69ec commit 8c9ecd8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
};
updateFocusContextKeys();
this.shell.activeChanged.connect(updateFocusContextKeys);

}

async initializeLayout(app: FrontendApplication): Promise<void> {
Expand All @@ -137,12 +136,19 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
isVisible: () => true
});
registry.registerCommand(FileNavigatorCommands.COLLAPSE_ALL, {
execute: () => this.collapseFileNavigatorTree(),
isEnabled: () => this.workspaceService.opened,
isVisible: () => this.workspaceService.opened
execute: widget => this.withWidget(widget, () => this.collapseFileNavigatorTree()),
isEnabled: widget => this.withWidget(widget, () => this.workspaceService.opened),
isVisible: wodget => this.withWidget(wodget, () => this.workspaceService.opened)
});
}

protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (navigator: FileNavigatorWidget) => T): T | false {
if (widget instanceof FileNavigatorWidget && widget.id === FILE_NAVIGATOR_ID) {
return cb(widget);
}
return false;
}

registerMenus(registry: MenuModelRegistry): void {
super.registerMenus(registry);
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_MENU, {
Expand Down

0 comments on commit 8c9ecd8

Please sign in to comment.