Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsidor Nikolic <inikolic@microsoft.com>2017-05-29 17:19:40 +0300
committerGitHub <noreply@github.com>2017-05-29 17:19:40 +0300
commit9b7daa878b985fc38b7e5d40f458432c16d8dd79 (patch)
tree87e2b5b70be2aa6341f7a2cba38261714c2f47df /src/vs/workbench/parts
parent84e2178de0aafc0cacc767204de7baf64161db44 (diff)
parent862088c2b1b0ba7ebfba1d71fc90f16bd7e94523 (diff)
Merge pull request #27453 from Microsoft/joao/light-update
Joao/light update
Diffstat (limited to 'src/vs/workbench/parts')
-rw-r--r--src/vs/workbench/parts/update/electron-browser/media/update.contribution.css9
-rw-r--r--src/vs/workbench/parts/update/electron-browser/media/update.svg1
-rw-r--r--src/vs/workbench/parts/update/electron-browser/update.contribution.ts16
-rw-r--r--src/vs/workbench/parts/update/electron-browser/update.ts100
4 files changed, 112 insertions, 14 deletions
diff --git a/src/vs/workbench/parts/update/electron-browser/media/update.contribution.css b/src/vs/workbench/parts/update/electron-browser/media/update.contribution.css
new file mode 100644
index 00000000000..a12923fce44
--- /dev/null
+++ b/src/vs/workbench/parts/update/electron-browser/media/update.contribution.css
@@ -0,0 +1,9 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+.update-activity {
+ -webkit-mask: url('update.svg') no-repeat 50% 50%;
+ -webkit-mask-size: 22px;
+} \ No newline at end of file
diff --git a/src/vs/workbench/parts/update/electron-browser/media/update.svg b/src/vs/workbench/parts/update/electron-browser/media/update.svg
new file mode 100644
index 00000000000..3dec2ba50fd
--- /dev/null
+++ b/src/vs/workbench/parts/update/electron-browser/media/update.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#424242"><path d="M12.714 9.603c-.07.207-.15.407-.246.601l1.017 2.139c-.335.424-.718.807-1.142 1.143l-2.14-1.018c-.193.097-.394.176-.601.247l-.795 2.235c-.265.03-.534.05-.807.05-.272 0-.541-.02-.806-.05l-.795-2.235c-.207-.071-.408-.15-.602-.247l-2.14 1.017c-.424-.336-.807-.719-1.143-1.143l1.017-2.139c-.094-.193-.175-.393-.245-.6l-2.236-.796c-.03-.265-.05-.534-.05-.807s.02-.542.05-.807l2.236-.795c.07-.207.15-.407.246-.601l-1.016-2.139c.336-.423.719-.807 1.143-1.142l2.14 1.017c.193-.096.394-.176.602-.247l.793-2.236c.265-.03.534-.05.806-.05.273 0 .542.02.808.05l.795 2.236c.207.07.407.15.601.246l2.14-1.017c.424.335.807.719 1.142 1.142l-1.017 2.139c.096.194.176.394.246.601l2.236.795c.029.266.049.535.049.808s-.02.542-.05.807l-2.236.796zm-4.714-4.603c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><circle cx="8" cy="8" r="1.5"/></g></svg> \ No newline at end of file
diff --git a/src/vs/workbench/parts/update/electron-browser/update.contribution.ts b/src/vs/workbench/parts/update/electron-browser/update.contribution.ts
index 52f121006f5..26cc50dfe8e 100644
--- a/src/vs/workbench/parts/update/electron-browser/update.contribution.ts
+++ b/src/vs/workbench/parts/update/electron-browser/update.contribution.ts
@@ -6,20 +6,31 @@
'use strict';
import * as nls from 'vs/nls';
+import 'vs/css!./media/update.contribution';
import { Registry } from 'vs/platform/platform';
+import product from 'vs/platform/node/product';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
-import { ShowCurrentReleaseNotesAction, UpdateContribution } from 'vs/workbench/parts/update/electron-browser/update';
import { ReleaseNotesEditor } from 'vs/workbench/parts/update/electron-browser/releaseNotesEditor';
import { ReleaseNotesInput } from 'vs/workbench/parts/update/electron-browser/releaseNotesInput';
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
+import { IGlobalActivityRegistry, GlobalActivityExtensions } from 'vs/workbench/browser/activity';
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
+import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, LightUpdateContribution } from './update';
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
- .registerWorkbenchContribution(UpdateContribution);
+ .registerWorkbenchContribution(ProductContribution);
+
+if (product.quality === 'insider') {
+ Registry.as<IGlobalActivityRegistry>(GlobalActivityExtensions)
+ .registerActivity(LightUpdateContribution);
+} else {
+ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
+ .registerWorkbenchContribution(UpdateContribution);
+}
// Editor
const editorDescriptor = new EditorDescriptor(
@@ -35,7 +46,6 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors)
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(ShowCurrentReleaseNotesAction, ShowCurrentReleaseNotesAction.ID, ShowCurrentReleaseNotesAction.LABEL), 'Open Release Notes');
-
// Configuration: Update
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
diff --git a/src/vs/workbench/parts/update/electron-browser/update.ts b/src/vs/workbench/parts/update/electron-browser/update.ts
index 644f7bd40df..4b8eff773df 100644
--- a/src/vs/workbench/parts/update/electron-browser/update.ts
+++ b/src/vs/workbench/parts/update/electron-browser/update.ts
@@ -8,24 +8,28 @@
import nls = require('vs/nls');
import severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
-import { Action } from 'vs/base/common/actions';
+import { IAction, Action } from 'vs/base/common/actions';
+import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IMessageService, CloseAction, Severity } from 'vs/platform/message/common/message';
import pkg from 'vs/platform/node/package';
import product from 'vs/platform/node/product';
import URI from 'vs/base/common/uri';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
+import { IActivityBarService, TextBadge } from 'vs/workbench/services/activity/common/activityBarService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ReleaseNotesInput } from 'vs/workbench/parts/update/electron-browser/releaseNotesInput';
+import { IGlobalActivity } from 'vs/workbench/browser/activity';
import { IRequestService } from 'vs/platform/request/node/request';
import { asText } from 'vs/base/node/request';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO';
import { IOpenerService } from 'vs/platform/opener/common/opener';
+import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
-import { IUpdateService } from 'vs/platform/update/common/update';
+import { IUpdateService, State as UpdateState } from 'vs/platform/update/common/update';
import * as semver from 'semver';
-import { OS } from 'vs/base/common/platform';
+import { OS, isLinux, isWindows } from 'vs/base/common/platform';
class ApplyUpdateAction extends Action {
constructor( @IUpdateService private updateService: IUpdateService) {
@@ -189,24 +193,22 @@ const LinkAction = (id: string, message: string, licenseUrl: string) => new Acti
() => { window.open(licenseUrl); return TPromise.as(null); }
);
-export class UpdateContribution implements IWorkbenchContribution {
+export class ProductContribution implements IWorkbenchContribution {
private static KEY = 'releaseNotes/lastVersion';
- getId() { return 'vs.update'; }
+ getId() { return 'vs.product'; }
constructor(
@IStorageService storageService: IStorageService,
@IInstantiationService instantiationService: IInstantiationService,
@IMessageService messageService: IMessageService,
- @IUpdateService updateService: IUpdateService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
) {
- const lastVersion = storageService.get(UpdateContribution.KEY, StorageScope.GLOBAL, '');
+ const lastVersion = storageService.get(ProductContribution.KEY, StorageScope.GLOBAL, '');
- // was there an update?
+ // was there an update? if so, open release notes
if (product.releaseNotesUrl && lastVersion && pkg.version !== lastVersion) {
- instantiationService.invokeFunction(loadReleaseNotes, pkg.version)
- .then(
+ instantiationService.invokeFunction(loadReleaseNotes, pkg.version).then(
text => editorService.openEditor(instantiationService.createInstance(ReleaseNotesInput, pkg.version, text), { pinned: true }),
() => {
messageService.show(Severity.Info, {
@@ -230,8 +232,19 @@ export class UpdateContribution implements IWorkbenchContribution {
});
}
- storageService.store(UpdateContribution.KEY, pkg.version, StorageScope.GLOBAL);
+ storageService.store(ProductContribution.KEY, pkg.version, StorageScope.GLOBAL);
+ }
+}
+export class UpdateContribution implements IWorkbenchContribution {
+
+ getId() { return 'vs.update'; }
+
+ constructor(
+ @IInstantiationService instantiationService: IInstantiationService,
+ @IMessageService messageService: IMessageService,
+ @IUpdateService updateService: IUpdateService
+ ) {
updateService.onUpdateReady(update => {
const applyUpdateAction = instantiationService.createInstance(ApplyUpdateAction);
const releaseNotesAction = instantiationService.createInstance(ShowReleaseNotesAction, false, update.version);
@@ -262,4 +275,69 @@ export class UpdateContribution implements IWorkbenchContribution {
updateService.onError(err => messageService.show(severity.Error, err));
}
+}
+
+export class LightUpdateContribution implements IGlobalActivity {
+
+ get id() { return 'vs.update'; }
+ get name() { return ''; }
+ get cssClass() { return 'update-activity'; }
+
+ constructor(
+ @IStorageService storageService: IStorageService,
+ @ICommandService private commandService: ICommandService,
+ @IInstantiationService instantiationService: IInstantiationService,
+ @IMessageService messageService: IMessageService,
+ @IUpdateService private updateService: IUpdateService,
+ @IWorkbenchEditorService editorService: IWorkbenchEditorService,
+ @IActivityBarService activityBarService: IActivityBarService
+ ) {
+ this.updateService.onUpdateReady(() => {
+ const badge = new TextBadge('\u21e9', () => nls.localize('updateIsReady', "New update available."));
+ activityBarService.showGlobalActivity(this.id, badge);
+ });
+
+ this.updateService.onError(err => messageService.show(severity.Error, err));
+ }
+
+ getActions(): IAction[] {
+ return [
+ new Action('showCommandPalette', nls.localize('commandPalette', "Command Palette..."), undefined, true, () => this.commandService.executeCommand('workbench.action.showCommands')),
+ new Separator(),
+ new Action('openKeybindings', nls.localize('settings', "Settings"), null, true, () => this.commandService.executeCommand('workbench.action.openGlobalSettings')),
+ new Action('openSettings', nls.localize('keyboardShortcuts', "Keyboard Shortcuts"), null, true, () => this.commandService.executeCommand('workbench.action.openGlobalKeybindings')),
+ new Separator(),
+ this.getUpdateAction()
+ ];
+ }
+
+ private getUpdateAction(): IAction {
+ switch (this.updateService.state) {
+ case UpdateState.Uninitialized:
+ return new Action('update.notavailable', nls.localize('not available', "Updates Not Available"), undefined, false);
+
+ case UpdateState.CheckingForUpdate:
+ return new Action('update.checking', nls.localize('checkingForUpdates', "Checking For Updates..."), undefined, false);
+
+ case UpdateState.UpdateAvailable:
+ if (isLinux) {
+ return new Action('update.linux.available', nls.localize('DownloadUpdate', "Download Available Update"), undefined, true, () =>
+ this.updateService.quitAndInstall());
+ }
+
+ const updateAvailableLabel = isWindows
+ ? nls.localize('DownloadingUpdate', "Downloading Update...")
+ : nls.localize('InstallingUpdate', "Installing Update...");
+
+ return new Action('update.available', updateAvailableLabel, undefined, false);
+
+ case UpdateState.UpdateDownloaded:
+ return new Action('update.restart', nls.localize('restartToUpdate', "Restart To Update..."), undefined, true, () =>
+ this.updateService.quitAndInstall());
+
+ default:
+ return new Action('update.check', nls.localize('checkForUpdates', "Check For Updates..."), undefined, this.updateService.state === UpdateState.Idle, () =>
+ this.updateService.checkForUpdates(true));
+ }
+ }
} \ No newline at end of file