Merge from vscode 31e03b8ffbb218a87e3941f2b63a249f061fe0e4 (#4986)

This commit is contained in:
Anthony Dresser
2019-04-10 16:29:23 -07:00
committed by GitHub
parent 18c54f41bd
commit 8315dacda4
320 changed files with 5540 additions and 3822 deletions

View File

@@ -16,9 +16,9 @@ import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
// {{SQL CARBON EDIT}}
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewlet, AutoUpdateConfigurationKey, IExtensionContainer, EXTENSIONS_CONFIG, ExtensionsPolicy, ExtensionsPolicyKey } from 'vs/workbench/contrib/extensions/common/extensions';
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
import { IExtensionEnablementService, IExtensionTipsService, EnablementState, ExtensionsLabel, IExtensionRecommendation, IGalleryExtension, IExtensionsConfigContent, IExtensionGalleryService, INSTALL_ERROR_MALICIOUS, INSTALL_ERROR_INCOMPATIBLE, IGalleryExtensionVersion, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionEnablementService, IExtensionTipsService, EnablementState, ExtensionsLabel, IExtensionRecommendation, IGalleryExtension, IExtensionsConfigContent, IExtensionGalleryService, INSTALL_ERROR_MALICIOUS, INSTALL_ERROR_INCOMPATIBLE, IGalleryExtensionVersion, ILocalExtension, IExtensionManagementServerService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionType, ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ExtensionType, ExtensionIdentifier, IExtensionDescription, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ShowViewletAction } from 'vs/workbench/browser/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
@@ -56,6 +56,11 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la
import { alert } from 'vs/base/browser/ui/aria/aria';
import { coalesce } from 'vs/base/common/arrays';
import { IWorkbenchThemeService, COLOR_THEME_SETTING, ICON_THEME_SETTING, IFileIconTheme, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ILabelService } from 'vs/platform/label/common/label';
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import { isUIExtension } from 'vs/workbench/services/extensions/node/extensionsUtil';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
// {{SQL CARBON EDIT}}
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
@@ -145,16 +150,29 @@ export class InstallAction extends ExtensionAction {
private static readonly Class = 'extension-action prominent install';
private static readonly InstallingClass = 'extension-action install installing';
private disposables: IDisposable[] = [];
private _manifest: IExtensionManifest | null;
set manifest(manifest: IExtensionManifest) {
this._manifest = manifest;
this.updateLabel();
}
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@INotificationService private readonly notificationService: INotificationService,
@IOpenerService private readonly openerService: IOpenerService,
@IExtensionService private readonly runtimeExtensionService: IExtensionService,
@IWorkbenchThemeService private readonly workbenchThemeService: IWorkbenchThemeService
@IWorkbenchThemeService private readonly workbenchThemeService: IWorkbenchThemeService,
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@ILabelService private readonly labelService: ILabelService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
) {
super(`extensions.install`, InstallAction.INSTALL_LABEL, InstallAction.Class, false);
this.update();
this.labelService.onDidChangeFormatters(() => this.updateLabel(), this, this.disposables);
}
update(): void {
@@ -166,15 +184,28 @@ export class InstallAction extends ExtensionAction {
}
this.enabled = this.extensionsWorkbenchService.canInstall(this.extension) && this.extension.state === ExtensionState.Uninstalled;
this.class = this.extension.state === ExtensionState.Installing ? InstallAction.InstallingClass : InstallAction.Class;
this.updateLabel();
}
private updateLabel(): void {
if (this.extension.state === ExtensionState.Installing) {
this.label = InstallAction.INSTALLING_LABEL;
this.class = InstallAction.InstallingClass;
this.tooltip = InstallAction.INSTALLING_LABEL;
} else {
this.label = InstallAction.INSTALL_LABEL;
this.class = InstallAction.Class;
this.tooltip = InstallAction.INSTALL_LABEL;
if (this._manifest && this.workbenchEnvironmentService.configuration.remoteAuthority) {
if (isUIExtension(this._manifest, this.configurationService)) {
this.label = `${InstallAction.INSTALL_LABEL} (${this.extensionManagementServerService.localExtensionManagementServer.label})`;
this.tooltip = `${InstallAction.INSTALL_LABEL} (${this.extensionManagementServerService.localExtensionManagementServer.label})`;
} else {
const host = this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.workbenchEnvironmentService.configuration.remoteAuthority) || localize('remote', "Remote");
this.label = `${InstallAction.INSTALL_LABEL} (${host})`;
this.tooltip = `${InstallAction.INSTALL_LABEL} (${host})`;
}
} else {
this.label = InstallAction.INSTALL_LABEL;
this.tooltip = InstallAction.INSTALL_LABEL;
}
}
}
@@ -185,7 +216,8 @@ export class InstallAction extends ExtensionAction {
const extension = await this.install(this.extension);
// {{SQL CARBON EDIT}}
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName));
// Add extension object check since ADS third party extensions will be directed to a download page
// and the extension object will be undefined.
if (extension && extension.local) {
@@ -246,6 +278,93 @@ export class InstallAction extends ExtensionAction {
}
return null;
}
dispose(): void {
this.disposables = dispose(this.disposables);
super.dispose();
}
}
export class RemoteInstallAction extends ExtensionAction {
private static INSTALL_LABEL = localize('install', "Install");
private static INSTALLING_LABEL = localize('installing', "Installing");
private static readonly Class = 'extension-action prominent install';
private static readonly InstallingClass = 'extension-action install installing';
updateWhenCounterExtensionChanges: boolean = true;
private disposables: IDisposable[] = [];
private installing: boolean = false;
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@ILabelService private readonly labelService: ILabelService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IConfigurationService private readonly configurationService: IConfigurationService,
) {
super(`extensions.remoteinstall`, RemoteInstallAction.INSTALL_LABEL, RemoteInstallAction.Class, false);
this.labelService.onDidChangeFormatters(() => this.updateLabel(), this, this.disposables);
this.updateLabel();
this.update();
}
private updateLabel(): void {
if (this.installing) {
this.label = RemoteInstallAction.INSTALLING_LABEL;
return;
}
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
if (remoteAuthority) {
const host = this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.environmentService.configuration.remoteAuthority) || localize('remote', "Remote");
this.label = `${RemoteInstallAction.INSTALL_LABEL} (${host})`;
return;
}
}
update(): void {
this.enabled = false;
this.class = RemoteInstallAction.Class;
if (this.installing) {
this.enabled = true;
this.class = RemoteInstallAction.InstallingClass;
this.updateLabel();
return;
}
if (this.environmentService.configuration.remoteAuthority
// Installed User Extension
&& this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed
// Local Workspace Extension
&& this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && !isUIExtension(this.extension.local.manifest, this.configurationService)
// Extension does not exist in remote
&& !this.extensionsWorkbenchService.local.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.remoteExtensionManagementServer)
&& this.extensionsWorkbenchService.canInstall(this.extension)
) {
this.enabled = true;
this.updateLabel();
return;
}
}
async run(): Promise<void> {
if (this.extensionManagementServerService.remoteExtensionManagementServer && !this.installing) {
this.installing = true;
this.update();
this.extensionsWorkbenchService.open(this.extension);
alert(localize('installExtensionStart', "Installing extension {0} started. An editor is now open with more details on this extension", this.extension.displayName));
if (this.extension.gallery) {
await this.extensionManagementServerService.remoteExtensionManagementServer.extensionManagementService.installFromGallery(this.extension.gallery);
this.installing = false;
this.update();
}
}
}
dispose(): void {
this.disposables = dispose(this.disposables);
super.dispose();
}
}
export class UninstallAction extends ExtensionAction {
@@ -281,19 +400,12 @@ export class UninstallAction extends ExtensionAction {
this.label = UninstallAction.UninstallLabel;
this.class = UninstallAction.UninstallClass;
const installedExtensions = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier));
if (!installedExtensions.length) {
this.enabled = false;
return;
}
if (state !== ExtensionState.Installed) {
this.enabled = false;
return;
}
if (installedExtensions[0].type !== ExtensionType.User) {
if (this.extension.type !== ExtensionType.User) {
this.enabled = false;
return;
}
@@ -330,6 +442,8 @@ export class CombinedInstallAction extends ExtensionAction {
this.update();
}
set manifest(manifiest: IExtensionManifest) { this.installAction.manifest = manifiest; this.update(); }
update(): void {
this.installAction.extension = this.extension;
this.uninstallAction.extension = this.extension;
@@ -901,36 +1015,32 @@ export class CheckForUpdatesAction extends Action {
}
private checkUpdatesAndNotify(): void {
this.extensionsWorkbenchService.queryLocal().then(
extensions => {
const outdatedExtensions = extensions.filter(ext => ext.outdated === true);
if (!outdatedExtensions.length) {
this.notificationService.info(localize('noUpdatesAvailable', "All Extensions are up to date."));
return;
}
const outdated = this.extensionsWorkbenchService.outdated;
if (!outdated.length) {
this.notificationService.info(localize('noUpdatesAvailable', "All Extensions are up to date."));
return;
}
let msgAvailableExtensions = outdatedExtensions.length === 1 ? localize('singleUpdateAvailable', "An extension update is available.") : localize('updatesAvailable', "{0} extension updates are available.", outdatedExtensions.length);
let msgAvailableExtensions = outdated.length === 1 ? localize('singleUpdateAvailable', "An extension update is available.") : localize('updatesAvailable', "{0} extension updates are available.", outdated.length);
const disabledExtensionsCount = outdatedExtensions.filter(ext => ext.enablementState === EnablementState.Disabled || ext.enablementState === EnablementState.WorkspaceDisabled).length;
if (disabledExtensionsCount) {
if (outdatedExtensions.length === 1) {
msgAvailableExtensions = localize('singleDisabledUpdateAvailable', "An update to an extension which is disabled is available.");
} else if (disabledExtensionsCount === 1) {
msgAvailableExtensions = localize('updatesAvailableOneDisabled', "{0} extension updates are available. One of them is for a disabled extension.", outdatedExtensions.length);
} else if (disabledExtensionsCount === outdatedExtensions.length) {
msgAvailableExtensions = localize('updatesAvailableAllDisabled', "{0} extension updates are available. All of them are for disabled extensions.", outdatedExtensions.length);
} else {
msgAvailableExtensions = localize('updatesAvailableIncludingDisabled', "{0} extension updates are available. {1} of them are for disabled extensions.", outdatedExtensions.length, disabledExtensionsCount);
}
}
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => viewlet.search(''));
this.notificationService.info(msgAvailableExtensions);
const disabledExtensionsCount = outdated.filter(ext => ext.enablementState === EnablementState.Disabled || ext.enablementState === EnablementState.WorkspaceDisabled).length;
if (disabledExtensionsCount) {
if (outdated.length === 1) {
msgAvailableExtensions = localize('singleDisabledUpdateAvailable', "An update to an extension which is disabled is available.");
} else if (disabledExtensionsCount === 1) {
msgAvailableExtensions = localize('updatesAvailableOneDisabled', "{0} extension updates are available. One of them is for a disabled extension.", outdated.length);
} else if (disabledExtensionsCount === outdated.length) {
msgAvailableExtensions = localize('updatesAvailableAllDisabled', "{0} extension updates are available. All of them are for disabled extensions.", outdated.length);
} else {
msgAvailableExtensions = localize('updatesAvailableIncludingDisabled', "{0} extension updates are available. {1} of them are for disabled extensions.", outdated.length, disabledExtensionsCount);
}
);
}
this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => viewlet.search(''));
this.notificationService.info(msgAvailableExtensions);
}
run(): Promise<any> {
@@ -1009,16 +1119,12 @@ export class UpdateAllAction extends Action {
this.update();
}
private get outdated(): IExtension[] {
return this.extensionsWorkbenchService.local.filter(e => e.outdated && e.state !== ExtensionState.Installing);
}
private update(): void {
this.enabled = this.outdated.length > 0;
this.enabled = this.extensionsWorkbenchService.outdated.length > 0;
}
run(): Promise<any> {
return Promise.all(this.outdated.map(e => this.install(e)));
return Promise.all(this.extensionsWorkbenchService.outdated.map(e => this.install(e)));
}
private install(extension: IExtension): Promise<any> {
@@ -1044,16 +1150,18 @@ export class ReloadAction extends ExtensionAction {
private static readonly EnabledClass = 'extension-action reload';
private static readonly DisabledClass = `${ReloadAction.EnabledClass} disabled`;
updateWhenCounterExtensionChanges: boolean = true;
private disposables: IDisposable[] = [];
private _runningExtensions: IExtensionDescription[] = [];
private get runningExtensions(): IExtensionDescription[] { return this._runningExtensions; }
private set runningExtensions(runningExtensions: IExtensionDescription[]) { this._runningExtensions = runningExtensions; this.update(); }
private _runningExtensions: IExtensionDescription[] | null = null;
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IWindowService private readonly windowService: IWindowService,
@IExtensionService private readonly extensionService: IExtensionService,
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
super('extensions.reload', localize('reloadAction', "Reload"), ReloadAction.DisabledClass, false);
this.extensionService.onDidChangeExtensions(this.updateRunningExtensions, this, this.disposables);
@@ -1061,81 +1169,90 @@ export class ReloadAction extends ExtensionAction {
}
private updateRunningExtensions(): void {
this.extensionService.getExtensions().then(runningExtensions => this.runningExtensions = runningExtensions);
this.extensionService.getExtensions().then(runningExtensions => { this._runningExtensions = runningExtensions; this.update(); });
}
update(): void {
this.enabled = false;
this.tooltip = '';
if (!this.extension) {
if (!this.extension || !this._runningExtensions) {
return;
}
const state = this.extension.state;
if (state === ExtensionState.Installing || state === ExtensionState.Uninstalling) {
return;
}
const installed = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier))[0];
const local = this.extension.local || (installed && installed.local);
if (local && local.manifest && local.manifest.contributes && local.manifest.contributes.localizations && local.manifest.contributes.localizations.length > 0) {
if (this.extension.local && this.extension.local.manifest && this.extension.local.manifest.contributes && this.extension.local.manifest.contributes.localizations && this.extension.local.manifest.contributes.localizations.length > 0) {
return;
}
this.computeReloadState(installed);
this.computeReloadState();
this.class = this.enabled ? ReloadAction.EnabledClass : ReloadAction.DisabledClass;
}
private computeReloadState(installed: IExtension): void {
private computeReloadState(): void {
if (!this._runningExtensions) {
return;
}
const isUninstalled = this.extension.state === ExtensionState.Uninstalled;
const isDisabled = this.extension.local ? !this.extensionEnablementService.isEnabled(this.extension.local) : false;
const isEnabled = this.extension.local ? this.extensionEnablementService.isEnabled(this.extension.local) : false;
const runningExtension = this.runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier))[0];
const runningExtension = this._runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier))[0];
if (installed && installed.local) {
if (isUninstalled) {
if (runningExtension) {
const isDifferentVersionRunning = this.extension.version !== runningExtension.version;
if (isDifferentVersionRunning && !isDisabled) {
if (!(this.extension.local && this.extensionService.canAddExtension(toExtensionDescription(this.extension.local)))) {
// Requires reload to run the updated extension
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postUpdateTooltip', "Please reload Azure Data Studio to complete the updating of this extension.");
}
return;
}
if (isDisabled) {
// Requires reload to disable the extension
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postDisableTooltip', "Please reload Azure Data Studio to complete the disabling of this extension.");
return;
}
} else {
if (!isDisabled && !(this.extension.local && this.extensionService.canAddExtension(toExtensionDescription(this.extension.local)))) {
this.enabled = true;
if (isEnabled) {
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to complete the enabling of this extension.");
} else {
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postInstallTooltip', "Please reload Azure Data Studio to complete the installation of this extension.");
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName));
}
}
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postUninstallTooltip', "Please reload Azure Data Studio to complete the uninstallation of this extension.");
alert(localize('uninstallExtensionComplete', "Please reload Azure Data Studio to complete the uninstallation of the extension {0}.", this.extension.displayName));
}
return;
}
if (isUninstalled && runningExtension) {
// Requires reload to deactivate the extension
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postUninstallTooltip', "Please reload Azure Data Studio to complete the uninstallation of this extension.");
alert(localize('uninstallExtensionComplete', "Please reload Azure Data Studio to complete the uninstallation of the extension {0}.", this.extension.displayName));
return;
if (this.extension.local) {
const isEnabled = this.extensionEnablementService.isEnabled(this.extension.local);
if (runningExtension) {
// Extension is running
const isSameExtensionRunning = this.extension.server === this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation);
const isSameVersionRunning = isSameExtensionRunning && this.extension.version === runningExtension.version;
if (isEnabled) {
if (!isSameVersionRunning && !this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postUpdateTooltip', "Please reload Azure Data Studio to enable the updated extension.");
}
} else {
if (isSameExtensionRunning) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postDisableTooltip', "Please reload Azure Data Studio to disable this extension.");
}
}
return;
} else {
// Extension is not running
if (isEnabled && !this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension.");
return;
}
if (this.workbenchEnvironmentService.configuration.remoteAuthority
// Local Workspace Extension
&& this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && !isUIExtension(this.extension.local.manifest, this.configurationService)
) {
const remoteExtension = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.remoteExtensionManagementServer)[0];
// Extension exist in remote and enabled
if (remoteExtension && remoteExtension.local && this.extensionEnablementService.isEnabled(remoteExtension.local)) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension.");
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName));
return;
}
}
}
}
}
@@ -1394,10 +1511,11 @@ export class ClearExtensionsInputAction extends Action {
id: string,
label: string,
onSearchChange: Event<string>,
value: string,
@IViewletService private readonly viewletService: IViewletService
) {
super(id, label, 'clear-extensions', true);
this.enabled = false;
this.onSearchChange(value);
onSearchChange(this.onSearchChange, this, this.disposables);
}
@@ -1893,6 +2011,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
label: string,
@IWorkspaceContextService protected contextService: IWorkspaceContextService,
@IFileService private readonly fileService: IFileService,
@ITextFileService private readonly textFileService: ITextFileService,
@IEditorService protected editorService: IEditorService,
@IJSONEditingService private readonly jsonEditingService: IJSONEditingService,
@ITextModelService private readonly textModelResolverService: ITextModelService
@@ -2041,7 +2160,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
return Promise.resolve(this.fileService.resolveContent(extensionsFileResource)).then(content => {
return { created: false, extensionsFileResource, content: content.value };
}, err => {
return this.fileService.updateContent(extensionsFileResource, ExtensionsConfigurationInitialContent).then(() => {
return this.textFileService.write(extensionsFileResource, ExtensionsConfigurationInitialContent).then(() => {
return { created: true, extensionsFileResource, content: ExtensionsConfigurationInitialContent };
});
});
@@ -2059,12 +2178,13 @@ export class ConfigureWorkspaceRecommendedExtensionsAction extends AbstractConfi
id: string,
label: string,
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEditorService editorService: IEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@ITextModelService textModelResolverService: ITextModelService
) {
super(id, label, contextService, fileService, editorService, jsonEditingService, textModelResolverService);
super(id, label, contextService, fileService, textFileService, editorService, jsonEditingService, textModelResolverService);
this.contextService.onDidChangeWorkbenchState(() => this.update(), this, this.disposables);
this.update();
}
@@ -2100,13 +2220,14 @@ export class ConfigureWorkspaceFolderRecommendedExtensionsAction extends Abstrac
id: string,
label: string,
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEditorService editorService: IEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@ITextModelService textModelResolverService: ITextModelService,
@ICommandService private readonly commandService: ICommandService
) {
super(id, label, contextService, fileService, editorService, jsonEditingService, textModelResolverService);
super(id, label, contextService, fileService, textFileService, editorService, jsonEditingService, textModelResolverService);
this.contextService.onDidChangeWorkspaceFolders(() => this.update(), this, this.disposables);
this.update();
}
@@ -2145,6 +2266,7 @@ export class AddToWorkspaceFolderRecommendationsAction extends AbstractConfigure
id: string,
label: string,
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEditorService editorService: IEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@@ -2152,7 +2274,7 @@ export class AddToWorkspaceFolderRecommendationsAction extends AbstractConfigure
@ICommandService private readonly commandService: ICommandService,
@INotificationService private readonly notificationService: INotificationService
) {
super(id, label, contextService, fileService, editorService, jsonEditingService, textModelResolverService);
super(id, label, contextService, fileService, textFileService, editorService, jsonEditingService, textModelResolverService);
}
run(shouldRecommend: boolean): Promise<void> {
@@ -2228,13 +2350,14 @@ export class AddToWorkspaceRecommendationsAction extends AbstractConfigureRecomm
id: string,
label: string,
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEditorService editorService: IEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@ITextModelService textModelResolverService: ITextModelService,
@INotificationService private readonly notificationService: INotificationService
) {
super(id, label, contextService, fileService, editorService, jsonEditingService, textModelResolverService);
super(id, label, contextService, fileService, textFileService, editorService, jsonEditingService, textModelResolverService);
}
run(shouldRecommend: boolean): Promise<void> {
@@ -2410,6 +2533,103 @@ export class MaliciousStatusLabelAction extends ExtensionAction {
}
}
export class SystemDisabledLabelAction extends ExtensionAction {
private static readonly Class = 'disable-status';
updateWhenCounterExtensionChanges: boolean = true;
private disposables: IDisposable[] = [];
constructor(
private readonly warningAction: SystemDisabledWarningAction,
) {
super('extensions.systemDisabledLabel', warningAction.tooltip, `${SystemDisabledLabelAction.Class} hide`, false);
warningAction.onDidChange(() => this.update(), this, this.disposables);
}
update(): void {
this.enabled = this.warningAction.enabled;
if (this.enabled) {
this.class = SystemDisabledLabelAction.Class;
this.label = this.warningAction.tooltip;
} else {
this.class = `${SystemDisabledLabelAction.Class} hide`;
this.label = '';
}
}
run(): Promise<any> {
return Promise.resolve(null);
}
dispose(): void {
dispose(this.disposables);
super.dispose();
}
}
export class SystemDisabledWarningAction extends ExtensionAction {
private static readonly Class = 'disable-warning';
updateWhenCounterExtensionChanges: boolean = true;
private disposables: IDisposable[] = [];
private _runningExtensions: IExtensionDescription[] | null = null;
constructor(
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@ILabelService private readonly labelService: ILabelService,
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionService private readonly extensionService: IExtensionService,
) {
super('extensions.install', '', `${SystemDisabledWarningAction.Class} hide`, false);
this.labelService.onDidChangeFormatters(() => this.update(), this, this.disposables);
this.extensionService.onDidChangeExtensions(this.updateRunningExtensions, this, this.disposables);
this.updateRunningExtensions();
this.update();
}
private updateRunningExtensions(): void {
this.extensionService.getExtensions().then(runningExtensions => { this._runningExtensions = runningExtensions; this.update(); });
}
update(): void {
this.enabled = false;
this.class = `${SystemDisabledWarningAction.Class} hide`;
this.tooltip = '';
if (this.extension && this.extension.local && this._runningExtensions) {
if (
// Remote Window
this.workbenchEnvironmentService.configuration.remoteAuthority
// Local Workspace Extension
&& this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && !isUIExtension(this.extension.local.manifest, this.configurationService)
// Extension does not exist in remote
&& !this.extensionsWorkbenchService.local.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.remoteExtensionManagementServer)
) {
this.enabled = true;
this.class = `${SystemDisabledWarningAction.Class}`;
const host = this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.workbenchEnvironmentService.configuration.remoteAuthority) || localize('remote', "Remote");
this.tooltip = localize('disabled workspace Extension', "This extension is disabled because it cannot run in a window connected to the remote server.", host, host);
if (this.extensionsWorkbenchService.canInstall(this.extension)) {
this.tooltip = `${this.tooltip} ${localize('Install in remote server', "Install it in '{0}' server to enable.", host)}`;
}
return;
}
}
}
run(): Promise<any> {
return Promise.resolve(null);
}
dispose(): void {
dispose(this.disposables);
super.dispose();
}
}
export class DisableAllAction extends Action {
static readonly ID = 'workbench.extensions.action.disableAll';