Skip to content

Commit

Permalink
Initial welcome widget commit (#183446)
Browse files Browse the repository at this point in the history
* Initial welcome widget commit

* Update i18n.resource.json for welcomeDialog

* Clean up code
  • Loading branch information
bhavyaus authored and meganrogge committed May 26, 2023
1 parent ca7c4c6 commit 0b99b35
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 138 deletions.
4 changes: 4 additions & 0 deletions build/lib/i18n.resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@
"name": "vs/workbench/contrib/welcomeWalkthrough",
"project": "vscode-workbench"
},
{
"name": "vs/workbench/contrib/welcomeDialog",
"project": "vscode-workbench"
},
{
"name": "vs/workbench/contrib/outline",
"project": "vscode-workbench"
Expand Down
20 changes: 15 additions & 5 deletions src/vs/workbench/browser/web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export interface IWorkbenchConstructionOptions {
readonly initialColorTheme?: IInitialColorTheme;

/**
* Welcome view dialog on first launch. Can be dismissed by the user.
* Welcome dialog. Can be dismissed by the user.
*/
readonly welcomeDialog?: IWelcomeDialog;

Expand Down Expand Up @@ -639,14 +639,24 @@ export interface IWelcomeDialog {
buttonText: string;

/**
* Message text and icon for the welcome dialog.
* Button command to execute from the welcome dialog.
*/
messages: { message: string; icon: string }[];
buttonCommand: string;

/**
* Optional action to appear as links at the bottom of the welcome dialog.
* Message text for the welcome dialog.
*/
action?: IWelcomeLinkAction;
message: string;

/**
* Context key expression to control the visibility of the welcome dialog.
*/
when: string;

/**
* Media to include in the welcome dialog.
*/
media: { altText: string; path: string };
}

export interface IDefaultView {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-dialog-box {
border-radius: 6px;
}

.welcome-widget {
height: min-content;
border-radius: 6px;
}

.dialog-message-detail-title{
height: 22px;
padding-bottom: 4px;
font-size: large;
}

.monaco-dialog-box .monaco-action-bar .actions-container {
justify-content: flex-end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,40 @@

import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { IWelcomeDialogService as IWelcomeDialogService } from 'vs/workbench/contrib/welcomeDialog/browser/welcomeDialogService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Disposable } from 'vs/base/common/lifecycle';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { WelcomeWidget } from 'vs/workbench/contrib/welcomeDialog/browser/welcomeWidget';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

const configurationKey = 'welcome.experimental.dialog';

class WelcomeDialogContribution {
class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution {

private static readonly WELCOME_DIALOG_DISMISSED_KEY = 'workbench.dialog.welcome.dismissed';
private contextKeysToWatch = new Set<string>();

constructor(
@IWelcomeDialogService welcomeDialogService: IWelcomeDialogService,
@IStorageService storageService: IStorageService,
@IBrowserWorkbenchEnvironmentService environmentService: IBrowserWorkbenchEnvironmentService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService configurationService: IConfigurationService,
@IContextKeyService readonly contextService: IContextKeyService,
@ICodeEditorService readonly codeEditorService: ICodeEditorService,
@IInstantiationService readonly instantiationService: IInstantiationService,
@ICommandService readonly commandService: ICommandService,
@ITelemetryService readonly telemetryService: ITelemetryService
) {
super();

if (!storageService.isNew(StorageScope.PROFILE)) {
return; // do not show if this is not the first session
}

const setting = configurationService.inspect<boolean>(configurationKey);
if (!setting.value) {
return;
Expand All @@ -33,19 +49,23 @@ class WelcomeDialogContribution {
return;
}

if (storageService.getBoolean(WelcomeDialogContribution.WELCOME_DIALOG_DISMISSED_KEY + '#' + welcomeDialog.id, StorageScope.PROFILE, false)) {
return;
}
this.contextKeysToWatch.add(welcomeDialog.when);

welcomeDialogService.show({
title: welcomeDialog.title,
buttonText: welcomeDialog.buttonText,
messages: welcomeDialog.messages,
action: welcomeDialog.action,
onClose: () => {
storageService.store(WelcomeDialogContribution.WELCOME_DIALOG_DISMISSED_KEY + '#' + welcomeDialog.id, true, StorageScope.PROFILE, StorageTarget.USER);
this._register(this.contextService.onDidChangeContext(e => {
if (e.affectsSome(this.contextKeysToWatch) &&
Array.from(this.contextKeysToWatch).every(value => this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(value)))) {
const codeEditor = this.codeEditorService.getActiveCodeEditor();
if (codeEditor?.hasModel()) {
const welcomeWidget = new WelcomeWidget(codeEditor, instantiationService, commandService, telemetryService);
welcomeWidget.render(welcomeDialog.title,
welcomeDialog.message,
welcomeDialog.buttonText,
welcomeDialog.buttonCommand,
welcomeDialog.media);
this.contextKeysToWatch.delete(welcomeDialog.when);
}
}
});
}));
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit 0b99b35

Please sign in to comment.