mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Add experimental setting to enable this dialog
This commit is contained in:
parent
a72e45d069
commit
257e0b1eac
|
@ -24,8 +24,11 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
|||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { GettingStartedDetailsRenderer } from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedDetailsRenderer';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { localize } from 'vs/nls';
|
||||
import { applicationConfigurationNodeBase } from 'vs/workbench/common/configuration';
|
||||
|
||||
const configurationKey = 'welcome.experimental.dialog';
|
||||
const configurationKey = 'workbench.welcome.experimental.dialog';
|
||||
|
||||
class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
|
@ -49,7 +52,7 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
|
|||
) {
|
||||
super();
|
||||
|
||||
if (!storageService.isNew(StorageScope.PROFILE)) {
|
||||
if (!storageService.isNew(StorageScope.APPLICATION)) {
|
||||
return; // do not show if this is not the first session
|
||||
}
|
||||
|
||||
|
@ -97,3 +100,17 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
|
|||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
.registerWorkbenchContribution(WelcomeDialogContribution, LifecyclePhase.Restored);
|
||||
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
configurationRegistry.registerConfiguration({
|
||||
...applicationConfigurationNodeBase,
|
||||
properties: {
|
||||
'workbench.welcome.experimental.dialog': {
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
tags: ['experimental'],
|
||||
description: localize('workbench.welcome.dialog', "When enabled, a welcome widget is shown in the edior")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -74,12 +74,12 @@ export class WelcomeWidget extends Disposable implements IOverlayWidget {
|
|||
}
|
||||
}
|
||||
|
||||
render(title: string, message: string, buttonText: string, buttonAction: string, media: { altText: string; path: string }): void {
|
||||
public async render(title: string, message: string, buttonText: string, buttonAction: string, media: { altText: string; path: string }) {
|
||||
if (!this._editor._getViewModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.buildWidgetContent(title, message, buttonText, buttonAction, media);
|
||||
await this.buildWidgetContent(title, message, buttonText, buttonAction, media);
|
||||
this._editor.addOverlayWidget(this);
|
||||
this._revealTemporarily();
|
||||
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', {
|
||||
|
@ -88,7 +88,7 @@ export class WelcomeWidget extends Disposable implements IOverlayWidget {
|
|||
});
|
||||
}
|
||||
|
||||
buildWidgetContent(title: string, message: string, buttonText: string, buttonAction: string, media: { altText: string; path: string }): void {
|
||||
private async buildWidgetContent(title: string, message: string, buttonText: string, buttonAction: string, media: { altText: string; path: string }) {
|
||||
|
||||
const actionBar = this._register(new ActionBar(this.element, {}));
|
||||
|
||||
|
@ -98,7 +98,7 @@ export class WelcomeWidget extends Disposable implements IOverlayWidget {
|
|||
actionBar.push(action, { icon: true, label: false });
|
||||
|
||||
if (media) {
|
||||
this.buildSVGMediaComponent(media.path);
|
||||
await this.buildSVGMediaComponent(media.path);
|
||||
}
|
||||
|
||||
const renderBody = (message: string): MarkdownString => {
|
||||
|
@ -158,7 +158,7 @@ export class WelcomeWidget extends Disposable implements IOverlayWidget {
|
|||
return container;
|
||||
}
|
||||
|
||||
private buildSVGMediaComponent(path: string) {
|
||||
private async buildSVGMediaComponent(path: string) {
|
||||
|
||||
const mediaContainer = this.messageContainer.appendChild($('.dialog-image-container'));
|
||||
mediaContainer.id = generateUuid();
|
||||
|
@ -166,9 +166,8 @@ export class WelcomeWidget extends Disposable implements IOverlayWidget {
|
|||
const webview = this._register(this.webviewService.createWebviewElement({ title: undefined, options: {}, contentOptions: {}, extension: undefined }));
|
||||
webview.mountTo(mediaContainer);
|
||||
|
||||
this.detailsRenderer.renderSVG(FileAccess.asFileUri(`${WelcomeWidget.WELCOME_MEDIA_PATH}${path}`)).then(body => {
|
||||
webview.setHtml(body);
|
||||
});
|
||||
const body = await this.detailsRenderer.renderSVG(FileAccess.asFileUri(`${WelcomeWidget.WELCOME_MEDIA_PATH}${path}`));
|
||||
webview.setHtml(body);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
|
|
Loading…
Reference in a new issue