提交 596887a3 编写于 作者: J Joao Moreno

show updated license terms after 1.0.0

fixes #3704
上级 f19bbe27
......@@ -108,6 +108,7 @@ export interface IEnvironment {
};
releaseNotesUrl: string;
licenseUrl: string;
productDownloadUrl: string;
welcomePage: string;
......
......@@ -117,6 +117,7 @@ export interface IWindowConfiguration extends env.ICommandLineArguments {
};
welcomePage: string;
releaseNotesUrl: string;
licenseUrl: string;
productDownloadUrl: string;
enableTelemetry: boolean;
userEnv: env.IProcessEnvironment;
......
......@@ -675,6 +675,7 @@ export class WindowsManager {
configuration.welcomePage = env.product.welcomePage;
configuration.productDownloadUrl = env.product.downloadUrl;
configuration.releaseNotesUrl = env.product.releaseNotesUrl;
configuration.licenseUrl = env.product.licenseUrl;
configuration.updateFeedUrl = UpdateManager.feedUrl;
configuration.updateChannel = UpdateManager.channel;
configuration.recentPaths = this.getRecentlyOpenedPaths(workspacePath, filesToOpen);
......
......@@ -7,6 +7,7 @@
import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/platform';
import { TPromise } from 'vs/base/common/winjs.base';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
......@@ -15,10 +16,23 @@ import { IMessageService } from 'vs/platform/message/common/message';
import Severity from 'vs/base/common/severity';
import { ShowReleaseNotesAction } from 'vs/workbench/electron-browser/update';
import { Action } from 'vs/base/common/actions';
import { shell } from 'electron';
import * as semver from 'semver';
export class ReleaseNotesContribution implements IWorkbenchContribution {
const CloseAction = new Action('close', nls.localize('close', "Close"), '', true, () => null);
const ShowLicenseAction = (licenseUrl: string) => new Action(
'update.showLicense',
nls.localize('license', "Read License"),
null,
true,
() => { shell.openExternal(licenseUrl); return TPromise.as(null); }
);
export class UpdateContribution implements IWorkbenchContribution {
private static KEY = 'releaseNotes/lastVersion';
getId() { return 'vs.update'; }
constructor(
@IStorageService storageService: IStorageService,
......@@ -26,20 +40,15 @@ export class ReleaseNotesContribution implements IWorkbenchContribution {
@IMessageService messageService: IMessageService
) {
const env = contextService.getConfiguration().env;
if (!env.releaseNotesUrl) {
return;
}
const lastVersion = storageService.get(ReleaseNotesContribution.KEY, StorageScope.GLOBAL, '');
const lastVersion = storageService.get(UpdateContribution.KEY, StorageScope.GLOBAL, '');
// was there an update?
if (lastVersion && env.version !== lastVersion) {
if (env.releaseNotesUrl && lastVersion && env.version !== lastVersion) {
setTimeout(() => {
messageService.show(Severity.Info, {
message: nls.localize('releaseNotes', "Welcome to {0} v{1}! Would you like to read the Release Notes?", env.appName, env.version),
actions: [
new Action('close', nls.localize('close', "Close"), '', true, () => null),
CloseAction,
ShowReleaseNotesAction(env.releaseNotesUrl, true)
]
});
......@@ -47,13 +56,23 @@ export class ReleaseNotesContribution implements IWorkbenchContribution {
}, 0);
}
storageService.store(ReleaseNotesContribution.KEY, env.version, StorageScope.GLOBAL);
}
// should we show the new license?
if (env.licenseUrl && lastVersion && semver.satisfies(lastVersion, '<1.0.0') && semver.satisfies(env.version, '>=1.0.0')) {
setTimeout(() => {
messageService.show(Severity.Info, {
message: nls.localize('licenseChanged', "Our license terms have changed, please go through them.", env.appName, env.version),
actions: [
CloseAction,
ShowLicenseAction(env.licenseUrl)
]
});
}, 0);
}
getId() {
return 'vs.releaseNotes';
storageService.store(UpdateContribution.KEY, env.version, StorageScope.GLOBAL);
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(ReleaseNotesContribution);
\ No newline at end of file
.registerWorkbenchContribution(UpdateContribution);
\ No newline at end of file
......@@ -81,7 +81,7 @@ define([
'vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.contribution',
'vs/workbench/parts/releaseNotes/electron-browser/releaseNotes.contribution',
'vs/workbench/parts/update/electron-browser/update.contribution',
'vs/workbench/electron-browser/darwin/cli.contribution',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册