From 85dda6d7f5537fe18582df442319727bfbce9286 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Fri, 6 Mar 2020 10:47:58 +0100 Subject: [PATCH] Allow welcome content in custom views Fixes #92143 --- src/vs/workbench/browser/parts/views/customView.ts | 11 +++++++++++ src/vs/workbench/common/views.ts | 2 ++ .../welcome/common/viewsWelcomeExtensionPoint.ts | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/browser/parts/views/customView.ts b/src/vs/workbench/browser/parts/views/customView.ts index 3e31d2a53ae8d..e538874807c7a 100644 --- a/src/vs/workbench/browser/parts/views/customView.ts +++ b/src/vs/workbench/browser/parts/views/customView.ts @@ -67,6 +67,7 @@ export class CustomTreeViewPane extends ViewPane { this._register(this.treeView.onDidChangeTitle((newTitle) => this.updateTitle(newTitle))); this._register(toDisposable(() => this.treeView.setVisibility(false))); this._register(this.onDidChangeBodyVisibility(() => this.updateTreeVisibility())); + this._register(this.treeView.onDidChangeWelcomeState(() => this._onDidChangeViewWelcomeState.fire())); this.updateTreeVisibility(); } @@ -83,6 +84,10 @@ export class CustomTreeViewPane extends ViewPane { } } + shouldShowWelcome(): boolean { + return (this.treeView.dataProvider === undefined) && (this.treeView.message === undefined); + } + layoutBody(height: number, width: number): void { this.treeView.layout(height, width); } @@ -151,6 +156,9 @@ export class CustomTreeView extends Disposable implements ITreeView { private readonly _onDidChangeActions: Emitter = this._register(new Emitter()); readonly onDidChangeActions: Event = this._onDidChangeActions.event; + private readonly _onDidChangeWelcomeState: Emitter = this._register(new Emitter()); + readonly onDidChangeWelcomeState: Event = this._onDidChangeWelcomeState.event; + private readonly _onDidChangeTitle: Emitter = this._register(new Emitter()); readonly onDidChangeTitle: Event = this._onDidChangeTitle.event; @@ -223,6 +231,8 @@ export class CustomTreeView extends Disposable implements ITreeView { this._dataProvider = undefined; this.updateMessage(); } + + this._onDidChangeWelcomeState.fire(); } private _message: string | undefined; @@ -233,6 +243,7 @@ export class CustomTreeView extends Disposable implements ITreeView { set message(message: string | undefined) { this._message = message; this.updateMessage(); + this._onDidChangeWelcomeState.fire(); } get title(): string { diff --git a/src/vs/workbench/common/views.ts b/src/vs/workbench/common/views.ts index a85e346bd987e..1cc7f5b050f71 100644 --- a/src/vs/workbench/common/views.ts +++ b/src/vs/workbench/common/views.ts @@ -488,6 +488,8 @@ export interface ITreeView extends IDisposable { readonly onDidChangeTitle: Event; + readonly onDidChangeWelcomeState: Event; + refresh(treeItems?: ITreeItem[]): Promise; setVisibility(visible: boolean): void; diff --git a/src/vs/workbench/contrib/welcome/common/viewsWelcomeExtensionPoint.ts b/src/vs/workbench/contrib/welcome/common/viewsWelcomeExtensionPoint.ts index 9a1fdbe078e57..a16e6d6b37b85 100644 --- a/src/vs/workbench/contrib/welcome/common/viewsWelcomeExtensionPoint.ts +++ b/src/vs/workbench/contrib/welcome/common/viewsWelcomeExtensionPoint.ts @@ -40,7 +40,6 @@ const viewsWelcomeExtensionPointSchema = Object.freeze