提交 4b9f2a09 编写于 作者: B Benjamin Pasero

Merge pull request #2166 from SofianHn/master

Remove static welcome page and move welcome experience to the website
......@@ -3,5 +3,6 @@
"nameLong": "Code [OSS Build]",
"win32MutexName": "vscodeoss",
"licenseUrl": "https://github.com/Microsoft/vscode/blob/master/LICENSE.txt",
"darwinBundleIdentifier": "com.visualstudio.code.oss"
"darwinBundleIdentifier": "com.visualstudio.code.oss",
"welcomePage": "http://go.microsoft.com/fwlink/?LinkId=723048"
}
\ No newline at end of file
......@@ -576,10 +576,9 @@ export class VSCodeMenu {
});
arrays.coalesce([
env.product.welcomePage ? this.createMenuItem(nls.localize('miShowWelcome', "&&Show Welcome"), 'workbench.action.markdown.showWelcome') : null,
env.product.documentationUrl ? new MenuItem({ label: mnemonicLabel(nls.localize('miDocumentation', "&&Documentation")), click: () => openUrl(env.product.documentationUrl, 'openDocumentationUrl') }) : null,
env.product.releaseNotesUrl ? new MenuItem({ label: mnemonicLabel(nls.localize('miReleaseNotes', "&&Release Notes")), click: () => openUrl(env.product.releaseNotesUrl, 'openReleaseNotesUrl') }) : null,,
(env.product.welcomePage || env.product.documentationUrl || env.product.releaseNotesUrl) ? __separator__() : null,
(env.product.documentationUrl || env.product.releaseNotesUrl) ? __separator__() : null,
env.product.twitterUrl ? new MenuItem({ label: mnemonicLabel(nls.localize('miTwitter', "&&Join us on Twitter")), click: () => openUrl(env.product.twitterUrl, 'openTwitterUrl') }) : null,
env.product.requestFeatureUrl ? new MenuItem({ label: mnemonicLabel(nls.localize('miUserVoice', "&&Request Features")), click: () => openUrl(env.product.requestFeatureUrl, 'openUserVoiceUrl') }) : null,
env.product.reportIssueUrl ? new MenuItem({ label: mnemonicLabel(nls.localize('miReportIssues', "Report &&Issues")), click: () => openUrl(env.product.reportIssueUrl, 'openReportIssues') }) : null,
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {IWorkbenchContribution} from 'vs/workbench/common/contributions';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
/**
* This extensions handles the first launch expereince for new users
*/
export abstract class AbstractGettingStarted implements IWorkbenchContribution {
protected static hideWelcomeSettingskey = 'workbench.hide.welcome';
protected welcomePageURL: string;
protected appName: string;
constructor(
@IStorageService private storageService: IStorageService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ITelemetryService private telemetryService: ITelemetryService
) {
const env = contextService.getConfiguration().env;
this.appName = env.appName;
if (env.welcomePage) {
this.welcomePageURL = env.welcomePage;
this.handleWelcome();
}
}
private handleWelcome(): void {
let firstStartup = !this.storageService.get(AbstractGettingStarted.hideWelcomeSettingskey);
if (firstStartup && this.welcomePageURL) {
this.telemetryService.getTelemetryInfo().then(info=>{
let url = this.getUrl(info);
this.openExternal(url);
this.storageService.store(AbstractGettingStarted.hideWelcomeSettingskey, true);
});
}
}
private getUrl(telemetryInfo: ITelemetryInfo): string {
return `${this.welcomePageURL}&&from=${this.appName}&&id=${telemetryInfo.machineId}`;
}
protected openExternal(url: string) {
throw new Error('implement me');
}
public getId(): string {
return 'vs.gettingstarted';
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {Registry} from 'vs/platform/platform';
import {ElectronGettingStarted} from 'vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted';
import {IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions} from 'vs/workbench/common/contributions';
(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(
ElectronGettingStarted
);
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {IWorkbenchContribution} from 'vs/workbench/common/contributions';
import {AbstractGettingStarted} from 'vs/workbench/parts/gettingStarted/common/abstractGettingStarted';
import { shell } from 'electron';
export class ElectronGettingStarted extends AbstractGettingStarted implements IWorkbenchContribution {
protected openExternal(url: string) {
shell.openExternal(url);
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import {AbstractGettingStarted} from 'vs/workbench/parts/gettingStarted/common/abstractGettingStarted';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {create} from 'vs/platform/instantiation/common/instantiationService';
import {Promise} from 'vs/base/common/winjs.base';
class TestGettingStarted extends AbstractGettingStarted {
public lastUrl: string;
protected openExternal(url: string) {
this.lastUrl = url;
}
}
suite('Workbench - GettingStarted', () => {
let instantiation: IInstantiationService = null;
let welcomePageEnvConfig: string = null;
let hideWelcomeSettingsValue: string = null;
let machineId: string = null;
let appName: string = null;
suiteSetup(() => {
instantiation = create({
contextService: {
getConfiguration: () => {
return {
env: {
welcomePage: welcomePageEnvConfig,
appName: appName
}
}
}
},
telemetryService: {
getTelemetryInfo: () => Promise.as({ machineId: machineId })
},
storageService: {
get: () => hideWelcomeSettingsValue,
store: (value) => hideWelcomeSettingsValue = value
}
});
});
suiteTeardown(() => {
instantiation = null;
});
setup(() => {
welcomePageEnvConfig = null;
hideWelcomeSettingsValue = null;
appName = null;
});
test('disabled by default', function() {
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === undefined, 'no page is opened when welcomePage is not configured');
});
test('base case', function() {
welcomePageEnvConfig = 'base url';
appName = 'some app';
machineId = '123';
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === `${welcomePageEnvConfig}&&from=${appName}&&id=${machineId}`, 'a page is opened when welcomePage is configured && first run');
assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
});
test('dont show after initial run', function() {
welcomePageEnvConfig = 'url';
hideWelcomeSettingsValue = 'true';
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === undefined, 'no page is opened after initial run');
assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
});
});
\ No newline at end of file
......@@ -14,7 +14,7 @@ import {FileEditorInputActionContributor} from 'vs/workbench/parts/files/browser
import {asFileResource} from 'vs/workbench/parts/files/common/files';
import strings = require('vs/base/common/strings');
import {IEditorInputActionContext, IEditorInputAction} from 'vs/workbench/browser/parts/editor/baseEditor';
import {ShowWelcomeAction, OpenPreviewToSideAction, GlobalTogglePreviewMarkdownAction, PreviewMarkdownEditorInputAction, PreviewMarkdownAction} from 'vs/workbench/parts/markdown/browser/markdownActions';
import {OpenPreviewToSideAction, GlobalTogglePreviewMarkdownAction, PreviewMarkdownEditorInputAction, PreviewMarkdownAction} from 'vs/workbench/parts/markdown/browser/markdownActions';
import {MARKDOWN_MIME, MARKDOWN_FILES} from 'vs/workbench/parts/markdown/common/markdown';
import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
......@@ -81,4 +81,3 @@ let category = nls.localize('markdown', "Markdown");
let workbenchActionsRegistry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(GlobalTogglePreviewMarkdownAction, GlobalTogglePreviewMarkdownAction.ID, GlobalTogglePreviewMarkdownAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_V }), category);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviewToSideAction, OpenPreviewToSideAction.ID, OpenPreviewToSideAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_V) }), category);
\ No newline at end of file
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowWelcomeAction, ShowWelcomeAction.ID, ShowWelcomeAction.LABEL));
\ No newline at end of file
......@@ -156,49 +156,3 @@ export class PreviewMarkdownEditorInputAction extends EditorInputAction {
return this.editorService.openEditor(markdownInput, null, sideBySide);
}
}
\ No newline at end of file
export class ShowWelcomeAction extends Action {
public static ID = 'workbench.action.markdown.showWelcome';
public static LABEL = nls.localize('showWelcome', "Show Welcome");
private preserveFocus: boolean;
private welcomePageResource: URI;
constructor(
id: string,
label: string,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IPartService private partService: IPartService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
super(id, label);
this.preserveFocus = false;
const env = contextService.getConfiguration().env;
if (env.welcomePage) {
this.welcomePageResource = URI.file(paths.join(env.appRoot, env.welcomePage));
}
this.enabled = !!this.welcomePageResource;
}
public setPreserveFocus(preserveFocus: boolean) {
this.preserveFocus = preserveFocus;
}
public run(): Promise {
return this.partService.joinCreation().then(() => {
let editorCount = this.editorService.getVisibleEditors().length;
let markdownInput = this.instantiationService.createInstance(MarkdownEditorInput, this.welcomePageResource, nls.localize('welcome', "Welcome"), nls.localize('vscode', "Getting Started"));
let options = new EditorOptions();
options.preserveFocus = this.preserveFocus;
return this.editorService.openEditor(markdownInput, options, editorCount !== 0 && editorCount !== 3);
});
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ import themes = require('vs/platform/theme/common/themes');
import {IWorkbenchContribution} from 'vs/workbench/common/contributions';
import {IFrameEditor} from 'vs/workbench/browser/parts/editor/iframeEditor';
import {MarkdownEditorInput} from 'vs/workbench/parts/markdown/common/markdownEditorInput';
import {ShowWelcomeAction} from 'vs/workbench/parts/markdown/browser/markdownActions';
import {EditorEvent, EventType as WorkbenchEventType} from 'vs/workbench/common/events';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
......@@ -36,7 +35,6 @@ interface ILanguageConfiguration {
// This extension tracks markdown files for changes to update markdown editors and inputs accordingly.
export class MarkdownFileTracker implements IWorkbenchContribution {
private static hideWelcomeSettingskey = 'workbench.hide.welcome';
private static RELOAD_MARKDOWN_DELAY = 300; // delay before reloading markdown preview after user typing
private fileChangeListener: () => void;
......@@ -64,7 +62,6 @@ export class MarkdownFileTracker implements IWorkbenchContribution {
this.configureMode(this.storageService.get(Preferences.THEME, StorageScope.GLOBAL));
this.registerListeners();
this.handleWelcome();
}
private registerListeners(): void {
......@@ -126,21 +123,6 @@ export class MarkdownFileTracker implements IWorkbenchContribution {
}
}
private handleWelcome(): void {
let firstStartup = !this.storageService.get(MarkdownFileTracker.hideWelcomeSettingskey);
let emptyWorkbench = !this.contextService.getWorkspace() && (!this.contextService.getOptions().filesToOpen || this.contextService.getOptions().filesToOpen.length === 0) && (!this.contextService.getOptions().filesToCreate || this.contextService.getOptions().filesToCreate.length === 0);
if (firstStartup && emptyWorkbench) {
this.storageService.store(MarkdownFileTracker.hideWelcomeSettingskey, true); // only once
let action = this.instantiationService.createInstance(ShowWelcomeAction, ShowWelcomeAction.ID, ShowWelcomeAction.LABEL);
if (action.enabled) {
action.setPreserveFocus(true);
action.run().done(() => action.dispose(), errors.onUnexpectedError);
}
}
}
private configureMode(theme: string): void {
if (theme) {
let baseTheme = themes.getBaseThemeId(theme);
......
......@@ -74,6 +74,8 @@ define([
'vs/workbench/parts/feedback/electron-browser/feedback.contribution',
'vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.contribution',
'vs/workbench/electron-browser/main.contribution',
'vs/workbench/electron-browser/main'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册