-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline mode #54831
Closed
Closed
Offline mode #54831
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
56a85df
First draft for offline mode
ramya-rao-a 892c555
Fix imports
ramya-rao-a f1c8435
Fix tests
ramya-rao-a e5bdf92
Merge remote-tracking branch 'origin/master' into offline-mode
ramya-rao-a ee86939
Refactoring
ramya-rao-a d03d190
Merge remote-tracking branch 'origin/master' into offline-mode
ramya-rao-a ad1c8c1
dont fetch experiments in offline mode
ramya-rao-a f490af7
changelog opens release notes in browser in offline mode
ramya-rao-a 7fef11f
Use MenuRegistry to register menu items
ramya-rao-a 35d20ed
Check for updates in offline mode from context menu
ramya-rao-a b6dd980
Refactoring
ramya-rao-a ea5d929
Disclaimer
ramya-rao-a 2a6d5f7
Register cmd pallet commands using MenuRegistry
ramya-rao-a 1fcbb6c
Release notes in offline mode
ramya-rao-a 10fa520
logUploader and others in offline mode
ramya-rao-a 7cae07e
Prevent future attempt at requestservice when in offline mode
ramya-rao-a 67b0554
Since release notes action fallsback to browser, changlog doesnt need…
ramya-rao-a cfdfa40
Release notes refactor
ramya-rao-a 5004eb2
Merge remote-tracking branch 'origin/master' into offline-mode
ramya-rao-a 36d74df
Offline mode tests
ramya-rao-a 23f3391
Merge remote-tracking branch 'origin/master' into offline-mode
ramya-rao-a 7d83013
Other tests
ramya-rao-a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { localize } from 'vs/nls'; | ||
import { Action } from 'vs/base/common/actions'; | ||
import { TPromise } from 'vs/base/common/winjs.base'; | ||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; | ||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; | ||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; | ||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; | ||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; | ||
import { CommandsRegistry } from 'vs/platform/commands/common/commands'; | ||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; | ||
|
||
export const offlineModeSetting = 'workbench.enableOfflineMode'; | ||
export const unSupportedInOfflineModeMsg = localize('offlineModeUnsupportedFeature', "This feature is not supported in offline mode"); | ||
|
||
export class EnableOfflineMode extends Action { | ||
static readonly ID = 'workbench.action.enableOfflineMode'; | ||
static LABEL = localize('enableOfflineMode', 'Enable Offline Mode'); | ||
|
||
private readonly disclaimerStorageKey = 'workbench.offlineMode.disclaimer.dontShowAgain'; | ||
|
||
constructor( | ||
id: string = EnableOfflineMode.ID, | ||
label: string = EnableOfflineMode.LABEL, | ||
@IConfigurationService private configurationService: IConfigurationService, | ||
@IStorageService private storageService: IStorageService, | ||
@INotificationService private notificationService: INotificationService | ||
) { | ||
super(id, label); | ||
this.updateEnabled(); | ||
this.configurationService.onDidChangeConfiguration(e => { | ||
if (e.affectsConfiguration(offlineModeSetting)) { | ||
this.updateEnabled(); | ||
} | ||
}); | ||
} | ||
|
||
private updateEnabled() { | ||
this.enabled = this.configurationService.getValue(offlineModeSetting) !== true; | ||
} | ||
|
||
run(): TPromise<any> { | ||
if (this.storageService.getBoolean(this.disclaimerStorageKey, StorageScope.GLOBAL, false) === false) { | ||
this.notificationService.prompt(Severity.Info, localize('offlineModeDisclaimer', "VS Code cannot stop extensions from making network requests in offline mode. If extensions make such requests, please log an issue against them."), [ | ||
{ | ||
label: localize('DontShowAgain', "Don't Show Again"), | ||
run: () => { | ||
this.storageService.store(this.disclaimerStorageKey, true); | ||
} | ||
} | ||
]); | ||
} | ||
return this.configurationService.updateValue(offlineModeSetting, true); | ||
} | ||
} | ||
|
||
export class DisableOfflineMode extends Action { | ||
static readonly ID = 'workbench.action.disableOfflineMode'; | ||
static LABEL = localize('disableOfflineMode', 'Disable Offline Mode'); | ||
|
||
constructor( | ||
id: string = DisableOfflineMode.ID, | ||
label: string = DisableOfflineMode.LABEL, | ||
@IConfigurationService private configurationService: IConfigurationService | ||
) { | ||
super(id, label); | ||
this.updateEnabled(); | ||
this.configurationService.onDidChangeConfiguration(e => { | ||
if (e.affectsConfiguration(offlineModeSetting)) { | ||
this.updateEnabled(); | ||
} | ||
}); | ||
} | ||
|
||
private updateEnabled() { | ||
this.enabled = this.configurationService.getValue(offlineModeSetting) === true; | ||
} | ||
|
||
run(): TPromise<any> { | ||
return this.configurationService.updateValue(offlineModeSetting, false); | ||
} | ||
} | ||
|
||
export class NotifyUnsupportedFeatureInOfflineMode extends Action { | ||
static readonly ID = 'workbench.action.notifyUnsupportedFeatureInOfflineMode'; | ||
|
||
constructor( | ||
id: string = NotifyUnsupportedFeatureInOfflineMode.ID, | ||
label: string = '', | ||
@IConfigurationService private configurationService: IConfigurationService, | ||
@INotificationService private notificationService: INotificationService | ||
) { | ||
super(id, label); | ||
} | ||
|
||
run(): TPromise<any> { | ||
this.notificationService.prompt(Severity.Info, unSupportedInOfflineModeMsg, [ | ||
{ | ||
label: DisableOfflineMode.LABEL, | ||
run: () => { | ||
return this.configurationService.updateValue(offlineModeSetting, false); | ||
} | ||
} | ||
]); | ||
return TPromise.as(null); | ||
} | ||
} | ||
|
||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, { | ||
group: '5_offline', | ||
command: { | ||
id: EnableOfflineMode.ID, | ||
title: localize({ key: 'miEnableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Enable &&Offline Mode") | ||
}, | ||
order: 1, | ||
when: ContextKeyExpr.not('config.' + offlineModeSetting) | ||
}); | ||
|
||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, { | ||
group: '5_offline', | ||
command: { | ||
id: DisableOfflineMode.ID, | ||
title: localize({ key: 'miDisableOfflineMode', comment: ['&& denotes a mnemonic'] }, "Disable &&Offline Mode") | ||
}, | ||
order: 1, | ||
when: ContextKeyExpr.has('config.' + offlineModeSetting) | ||
}); | ||
|
||
CommandsRegistry.registerCommand(EnableOfflineMode.ID, serviceAccesor => { | ||
serviceAccesor.get(IInstantiationService).createInstance(EnableOfflineMode, EnableOfflineMode.ID, EnableOfflineMode.LABEL).run(); | ||
}); | ||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { | ||
command: { | ||
id: EnableOfflineMode.ID, | ||
title: 'Preferences: Enable Offline Mode' | ||
}, | ||
when: ContextKeyExpr.not('config.' + offlineModeSetting) | ||
}); | ||
|
||
CommandsRegistry.registerCommand(DisableOfflineMode.ID, serviceAccesor => { | ||
serviceAccesor.get(IInstantiationService).createInstance(DisableOfflineMode, DisableOfflineMode.ID, DisableOfflineMode.LABEL).run(); | ||
}); | ||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { | ||
command: { | ||
id: DisableOfflineMode.ID, | ||
title: 'Preferences: Disable Offline Mode' | ||
}, | ||
when: ContextKeyExpr.has('config.' + offlineModeSetting) | ||
}); | ||
|
||
CommandsRegistry.registerCommand(NotifyUnsupportedFeatureInOfflineMode.ID, serviceAccesor => { | ||
serviceAccesor.get(IInstantiationService).createInstance(NotifyUnsupportedFeatureInOfflineMode, NotifyUnsupportedFeatureInOfflineMode.ID, '').run(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,6 +489,12 @@ configurationRegistry.registerConfiguration({ | |
'description': nls.localize('settingsTocVisible', "Controls whether the settings editor Table of Contents is visible."), | ||
'default': true, | ||
'scope': ConfigurationScope.WINDOW | ||
}, | ||
'workbench.enableOfflineMode': { | ||
'type': 'boolean', | ||
'description': nls.localize('settingsOfflineMode', "Enables offline mode where no requests are made over the network by VS Code."), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this wording should be changed to say that no requests are made to Microsoft, as we do still make requests to SCM providers, and there's nothing we can do to stop extensions (so far as I know) |
||
'default': false, | ||
'scope': ConfigurationScope.WINDOW | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way for extensions to check if the user is in offline mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjbvz Yes, they can look at the value for the
workbench.enableOfflineMode
setting. I havent yet gone through built-in extensions to ensure they are able to comply with the offline mode. That will be another PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so that will added to
vscode.d.ts
? Or read the setting value directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the setting value directly