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

fix: plugin doesn't show welcome view (#12458) #12466

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ export class HostedPluginSupport {
}
await this.startPlugins(contributionsByHost, toDisconnect);

// check data provider after plugin start to show welcome view
this.viewRegistry.checkViewDataProvider();

this.deferredDidStart.resolve();

this.restoreWebviews();
Expand Down
29 changes: 22 additions & 7 deletions packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,14 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
}
}

registerViewDataProvider(viewId: string, provider: ViewDataProvider): Disposable {
registerViewDataProvider(viewId: string, provider?: ViewDataProvider): Disposable {
if (this.viewDataProviders.has(viewId)) {
console.error(`data provider for '${viewId}' view is already registered`);
return Disposable.NULL;
}
this.viewDataProviders.set(viewId, provider);
if (provider) {
this.viewDataProviders.set(viewId, provider);
}
const toDispose = new DisposableCollection(Disposable.create(() => {
this.viewDataProviders.delete(viewId);
this.viewDataState.delete(viewId);
Expand Down Expand Up @@ -780,19 +782,32 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
return toDispose;
}

checkViewDataProvider(): void {
for (const viewId of this.viewsWelcome.keys()) {
if (!this.viewDataProviders.has(viewId)) {
this.registerViewDataProvider(viewId);
}
}
}

protected async createViewDataWidget(viewId: string, webviewId?: string): Promise<Widget | undefined> {
const view = this.views.get(viewId);
if (view?.[1]?.type === PluginViewType.Webview) {
const webviewWidget = this.widgetManager.getWidget(WebviewWidget.FACTORY_ID, <WebviewWidgetIdentifier>{ id: webviewId });
return webviewWidget;
}
const provider = this.viewDataProviders.get(viewId);
if (!view || !provider) {
if (!view) {
return undefined;
}
const [, viewInfo] = view;
const state = this.viewDataState.get(viewId);
const widget = await provider({ state, viewInfo });
let widget;
const provider = this.viewDataProviders.get(viewId);
if (!provider) {
widget = await this.widgetManager.getOrCreateWidget<TreeViewWidget>(PLUGIN_VIEW_DATA_FACTORY_ID, { id: viewId });
} else {
const [, viewInfo] = view;
const state = this.viewDataState.get(viewId);
widget = await provider({ state, viewInfo });
}
widget.handleViewWelcomeContentChange(this.getViewWelcomes(viewId));
if (StatefulWidget.is(widget)) {
this.storeViewDataStateOnDispose(viewId, widget);
Expand Down