Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385 (#6460)

* Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385

* fix servers icon

* fix tests
This commit is contained in:
Anthony Dresser
2019-07-22 18:28:21 -07:00
committed by GitHub
parent f2afacd8b2
commit 15fc7a077a
91 changed files with 2562 additions and 972 deletions

View File

@@ -28,7 +28,7 @@ import { IExtensionsWorkbenchService, IExtensionsViewlet, VIEWLET_ID, IExtension
import { RatingsWidget, InstallCountWidget, RemoteBadgeWidget } from 'vs/workbench/contrib/extensions/browser/extensionsWidgets';
import { EditorOptions } from 'vs/workbench/common/editor';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { CombinedInstallAction, UpdateAction, ExtensionEditorDropDownAction, ReloadAction, MaliciousStatusLabelAction, IgnoreExtensionRecommendationAction, UndoIgnoreExtensionRecommendationAction, EnableDropDownAction, DisableDropDownAction, StatusLabelAction, SetFileIconThemeAction, SetColorThemeAction, RemoteInstallAction, DisabledLabelAction, SystemDisabledWarningAction, LocalInstallAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { CombinedInstallAction, UpdateAction, ExtensionEditorDropDownAction, ReloadAction, MaliciousStatusLabelAction, IgnoreExtensionRecommendationAction, UndoIgnoreExtensionRecommendationAction, EnableDropDownAction, DisableDropDownAction, StatusLabelAction, SetFileIconThemeAction, SetColorThemeAction, RemoteInstallAction, ExtensionToolTipAction, SystemDisabledWarningAction, LocalInstallAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { IOpenerService } from 'vs/platform/opener/common/opener';
@@ -391,7 +391,7 @@ export class ExtensionEditor extends BaseEditor {
this.instantiationService.createInstance(LocalInstallAction),
combinedInstallAction,
systemDisabledWarningAction,
this.instantiationService.createInstance(DisabledLabelAction, systemDisabledWarningAction),
this.instantiationService.createInstance(ExtensionToolTipAction, systemDisabledWarningAction, reloadAction),
this.instantiationService.createInstance(MaliciousStatusLabelAction, true),
];
const extensionContainers: ExtensionContainers = this.instantiationService.createInstance(ExtensionContainers, [...actions, ...widgets]);

View File

@@ -64,14 +64,15 @@ Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
);
// Editor
const editorDescriptor = new EditorDescriptor(
ExtensionEditor,
ExtensionEditor.ID,
localize('extension', "Extension")
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
new EditorDescriptor(
ExtensionEditor,
ExtensionEditor.ID,
localize('extension', "Extension")
),
[
new SyncDescriptor(ExtensionsInput)
]);
// Viewlet
const viewletDescriptor = new ViewletDescriptor(

View File

@@ -61,11 +61,11 @@ import { IPreferencesService } from 'vs/workbench/services/preferences/common/pr
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IProductService } from 'vs/platform/product/common/product';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
// {{SQL CARBON EDIT}}
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; // {{SQL CARBON EDIT}}
function toExtensionDescription(local: ILocalExtension): IExtensionDescription {
export function toExtensionDescription(local: ILocalExtension): IExtensionDescription {
return {
identifier: new ExtensionIdentifier(local.identifier.id),
isBuiltin: local.type === ExtensionType.System,
@@ -76,7 +76,8 @@ function toExtensionDescription(local: ILocalExtension): IExtensionDescription {
};
}
const promptDownloadManually = (extension: IGalleryExtension | undefined, message: string, error: Error, instantiationService: IInstantiationService, notificationService: INotificationService, openerService: IOpenerService, productService: IProductService) => {
const promptDownloadManually = (extension: IGalleryExtension | undefined, message: string, error: Error,
instantiationService: IInstantiationService, notificationService: INotificationService, openerService: IOpenerService, productService: IProductService) => {
if (!extension || error.name === INSTALL_ERROR_INCOMPATIBLE || error.name === INSTALL_ERROR_MALICIOUS || !productService.extensionsGallery) {
return Promise.reject(error);
} else {
@@ -1182,9 +1183,7 @@ export class ReloadAction extends ExtensionAction {
@IWindowService private readonly windowService: IWindowService,
@IExtensionService private readonly extensionService: IExtensionService,
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IProductService private readonly productService: IProductService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
) {
super('extensions.reload', localize('reloadAction', "Reload"), ReloadAction.DisabledClass, false);
this._register(this.extensionService.onDidChangeExtensions(this.updateRunningExtensions, this));
@@ -1232,8 +1231,9 @@ export class ReloadAction extends ExtensionAction {
}
if (this.extension.local) {
const isEnabled = this.extensionEnablementService.isEnabled(this.extension.local);
// Extension is runningÎ
if (runningExtension) {
// Extension is running
if (isEnabled) {
if (!this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
if (isSameExtensionRunning) {
@@ -1259,39 +1259,27 @@ export class ReloadAction extends ExtensionAction {
}
}
return;
} else {
// Extension is not running
}
// Extension is not running
else {
if (isEnabled && !this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension."); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
return;
}
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
const uiExtension = isUIExtension(this.extension.local.manifest, this.productService, this.configurationService);
// Local Workspace Extension
if (!uiExtension && this.extension.server === this.extensionManagementServerService.localExtensionManagementServer) {
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");
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension.");// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName)); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
return;
}
}
// Remote UI Extension
if (uiExtension && this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer) {
const localExtension = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.localExtensionManagementServer)[0];
// Extension exist in local and enabled
if (localExtension && localExtension.local && this.extensionEnablementService.isEnabled(localExtension.local)) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension."); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName)); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
return;
}
const otherServer = this.extension.server ? this.extension.server === this.extensionManagementServerService.localExtensionManagementServer ? this.extensionManagementServerService.remoteExtensionManagementServer : this.extensionManagementServerService.localExtensionManagementServer : null;
if (otherServer && this.extension.enablementState === EnablementState.DisabledByExtensionKind) {
const extensionInOtherServer = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === otherServer)[0];
// Same extension in other server exists and
if (extensionInOtherServer && extensionInOtherServer.local && this.extensionEnablementService.isEnabled(extensionInOtherServer.local)) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension."); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
alert(localize('installExtensionComplete', "Installing extension {0} is completed. Please reload Azure Data Studio to enable it.", this.extension.displayName)); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
return;
}
}
}
@@ -2548,7 +2536,7 @@ export class MaliciousStatusLabelAction extends ExtensionAction {
}
}
export class DisabledLabelAction extends ExtensionAction {
export class ExtensionToolTipAction extends ExtensionAction {
private static readonly Class = 'disable-status';
@@ -2557,10 +2545,12 @@ export class DisabledLabelAction extends ExtensionAction {
constructor(
private readonly warningAction: SystemDisabledWarningAction,
private readonly reloadAction: ReloadAction,
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
@IExtensionService private readonly extensionService: IExtensionService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
) {
super('extensions.disabledLabel', warningAction.tooltip, `${DisabledLabelAction.Class} hide`, false);
super('extensions.tooltip', warningAction.tooltip, `${ExtensionToolTipAction.Class} hide`, false);
this._register(warningAction.onDidChange(() => this.update(), this));
this._register(this.extensionService.onDidChangeExtensions(this.updateRunningExtensions, this));
this.updateRunningExtensions();
@@ -2571,25 +2561,51 @@ export class DisabledLabelAction extends ExtensionAction {
}
update(): void {
this.class = `${DisabledLabelAction.Class} hide`;
this.label = '';
this.label = this.getTooltip();
this.class = ExtensionToolTipAction.Class;
if (!this.label) {
this.class = `${ExtensionToolTipAction.Class} hide`;
}
}
private getTooltip(): string {
if (!this.extension) {
return '';
}
if (this.reloadAction.enabled) {
return this.reloadAction.tooltip;
}
if (this.warningAction.tooltip) {
this.class = DisabledLabelAction.Class;
this.label = this.warningAction.tooltip;
return;
return this.warningAction.tooltip;
}
if (this.extension && this.extension.local && isLanguagePackExtension(this.extension.local.manifest)) {
return;
}
if (this.extension && this.extension.local && this._runningExtensions) {
if (this.extension && this.extension.local && this.extension.state === ExtensionState.Installed && this._runningExtensions) {
const isRunning = this._runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier));
const isEnabled = this.extensionEnablementService.isEnabled(this.extension.local);
const isExtensionRunning = this._runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier));
if (!isExtensionRunning && !isEnabled && this.extensionEnablementService.canChangeEnablement(this.extension.local)) {
this.class = DisabledLabelAction.Class;
this.label = localize('disabled by user', "This extension is disabled by the user.");
return;
if (isEnabled && isRunning) {
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer) {
return localize('extension enabled on remote', "Extension is enabled on '{0}'", this.extension.server.label);
}
}
if (this.extension.enablementState === EnablementState.EnabledGlobally) {
return localize('globally enabled', "This extension is enabled globally.");
}
if (this.extension.enablementState === EnablementState.EnabledWorkspace) {
return localize('workspace enabled', "This extension is enabled for this workspace by the user.");
}
}
if (!isEnabled && !isRunning) {
if (this.extension.enablementState === EnablementState.DisabledGlobally) {
return localize('globally disabled', "This extension is disabled globally by the user.");
}
if (this.extension.enablementState === EnablementState.DisabledWorkspace) {
return localize('workspace disabled', "This extension is disabled for this workspace by the user.");
}
}
}
return '';
}
run(): Promise<any> {
@@ -2832,6 +2848,7 @@ export class InstallVSIXAction extends Action {
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@INotificationService private readonly notificationService: INotificationService,
@IWindowService private readonly windowService: IWindowService,
@IFileDialogService private readonly fileDialogService: IFileDialogService,
@IExtensionService private readonly extensionService: IExtensionService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
// {{SQL CARBON EDIT}}

View File

@@ -13,7 +13,7 @@ import { IPagedRenderer } from 'vs/base/browser/ui/list/listPaging';
import { Event } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { IExtension, ExtensionContainers, ExtensionState, IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
import { InstallAction, UpdateAction, ManageExtensionAction, ReloadAction, MaliciousStatusLabelAction, ExtensionActionViewItem, StatusLabelAction, RemoteInstallAction, SystemDisabledWarningAction, DisabledLabelAction, LocalInstallAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { InstallAction, UpdateAction, ManageExtensionAction, ReloadAction, MaliciousStatusLabelAction, ExtensionActionViewItem, StatusLabelAction, RemoteInstallAction, SystemDisabledWarningAction, ExtensionToolTipAction, LocalInstallAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { Label, RatingsWidget, InstallCountWidget, RecommendationWidget, RemoteBadgeWidget, TooltipWidget } from 'vs/workbench/contrib/extensions/browser/extensionsWidgets';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -103,8 +103,8 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
systemDisabledWarningAction,
this.instantiationService.createInstance(ManageExtensionAction)
];
const disabledLabelAction = this.instantiationService.createInstance(DisabledLabelAction, systemDisabledWarningAction);
const tooltipWidget = this.instantiationService.createInstance(TooltipWidget, root, disabledLabelAction, recommendationWidget, reloadAction);
const extensionTooltipAction = this.instantiationService.createInstance(ExtensionToolTipAction, systemDisabledWarningAction, reloadAction);
const tooltipWidget = this.instantiationService.createInstance(TooltipWidget, root, extensionTooltipAction, recommendationWidget);
const widgets = [
recommendationWidget,
iconRemoteBadgeWidget,
@@ -115,10 +115,10 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
// this.instantiationService.createInstance(InstallCountWidget, installCount, true),
this.instantiationService.createInstance(RatingsWidget, ratings, true)
];
const extensionContainers: ExtensionContainers = this.instantiationService.createInstance(ExtensionContainers, [...actions, ...widgets, disabledLabelAction]);
const extensionContainers: ExtensionContainers = this.instantiationService.createInstance(ExtensionContainers, [...actions, ...widgets, extensionTooltipAction]);
actionbar.push(actions, actionOptions);
const disposables = combinedDisposable(...actions, ...widgets, actionbar, extensionContainers, disabledLabelAction);
const disposables = combinedDisposable(...actions, ...widgets, actionbar, extensionContainers, extensionTooltipAction);
return {
// {{SQL CARBON EDIT}}

View File

@@ -5,13 +5,13 @@
import 'vs/css!./media/extensionsWidgets';
import { Disposable, toDisposable, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
import { IExtension, IExtensionsWorkbenchService, IExtensionContainer, ExtensionState } from '../common/extensions';
import { IExtension, IExtensionsWorkbenchService, IExtensionContainer } from 'vs/workbench/contrib/extensions/common/extensions';
import { append, $, addClass } from 'vs/base/browser/dom';
import * as platform from 'vs/base/common/platform';
import { localize } from 'vs/nls';
import { IExtensionTipsService, IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { ILabelService } from 'vs/platform/label/common/label';
import { extensionButtonProminentBackground, extensionButtonProminentForeground, DisabledLabelAction, ReloadAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { extensionButtonProminentBackground, extensionButtonProminentForeground, ExtensionToolTipAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import { EXTENSION_BADGE_REMOTE_BACKGROUND, EXTENSION_BADGE_REMOTE_FOREGROUND } from 'vs/workbench/common/theme';
import { Emitter, Event } from 'vs/base/common/event';
@@ -145,16 +145,13 @@ export class TooltipWidget extends ExtensionWidget {
constructor(
private readonly parent: HTMLElement,
private readonly disabledLabelAction: DisabledLabelAction,
private readonly tooltipAction: ExtensionToolTipAction,
private readonly recommendationWidget: RecommendationWidget,
private readonly reloadAction: ReloadAction,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@ILabelService private readonly labelService: ILabelService
) {
super();
this._register(Event.any<any>(
this.disabledLabelAction.onDidChange,
this.reloadAction.onDidChange,
this.tooltipAction.onDidChange,
this.recommendationWidget.onDidChangeTooltip,
this.labelService.onDidChangeFormatters
)(() => this.render()));
@@ -173,17 +170,8 @@ export class TooltipWidget extends ExtensionWidget {
if (!this.extension) {
return '';
}
if (this.reloadAction.enabled) {
return this.reloadAction.tooltip;
}
if (this.disabledLabelAction.label) {
return this.disabledLabelAction.label;
}
if (this.extension.local && this.extension.state === ExtensionState.Installed) {
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer) {
return localize('extension enabled on remote', "Extension is enabled on '{0}'", this.extension.server.label);
}
return localize('extension enabled locally', "Extension is enabled locally.");
if (this.tooltipAction.tooltip) {
return this.tooltipAction.tooltip;
}
return this.recommendationWidget.tooltip;
}

View File

@@ -424,7 +424,9 @@ class Extensions extends Disposable {
const installingExtension = gallery ? this.installing.filter(e => areSameExtensions(e.identifier, gallery.identifier))[0] : null;
this.installing = installingExtension ? this.installing.filter(e => e !== installingExtension) : this.installing;
let extension: Extension | undefined = installingExtension ? installingExtension : zipPath ? this.instantiationService.createInstance(Extension, this.stateProvider, this.server, local, undefined) : undefined;
let extension: Extension | undefined = installingExtension ? installingExtension
: (zipPath || local) ? this.instantiationService.createInstance(Extension, this.stateProvider, this.server, local, undefined)
: undefined;
if (extension) {
if (local) {
const installed = this.installed.filter(e => areSameExtensions(e.identifier, extension!.identifier))[0];

View File

@@ -1063,37 +1063,39 @@ suite('ExtensionsActions Test', () => {
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension state is installing', () => {
test('Test ReloadAction when extension state is installing', async () => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
const gallery = aGalleryExtension('a');
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
return workbenchService.queryGallery(CancellationToken.None)
.then((paged) => {
testObject.extension = paged.firstPage[0];
installEvent.fire({ identifier: gallery.identifier, gallery });
const paged = await workbenchService.queryGallery(CancellationToken.None);
testObject.extension = paged.firstPage[0];
installEvent.fire({ identifier: gallery.identifier, gallery });
assert.ok(!testObject.enabled);
});
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension state is uninstalling', () => {
test('Test ReloadAction when extension state is uninstalling', async () => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const local = aLocalExtension('a');
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return instantiationService.get(IExtensionsWorkbenchService).queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
uninstallEvent.fire(local.identifier);
assert.ok(!testObject.enabled);
});
const extensions = await instantiationService.get(IExtensionsWorkbenchService).queryLocal();
testObject.extension = extensions[0];
uninstallEvent.fire(local.identifier);
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is newly installed', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
const runningExtensions = [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }];
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve(runningExtensions),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => false
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const gallery = aGalleryExtension('a');
@@ -1103,35 +1105,50 @@ suite('ExtensionsActions Test', () => {
testObject.extension = paged.firstPage[0];
assert.ok(!testObject.enabled);
return new Promise(c => {
testObject.onDidChange(() => {
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
if (testObject.enabled && testObject.tooltip === 'Please reload Azure Data Studio to enable this extension.') {
c();
}
});
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
});
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
assert.ok(testObject.enabled);
assert.equal(testObject.tooltip, 'Please reload Azure Data Studio to enable this extension.'); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test ReloadAction when extension is installed and uninstalled', () => {
test('Test ReloadAction when extension is newly installed and reload is not required', async () => {
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
const runningExtensions = [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }];
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve(runningExtensions),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => true
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const gallery = aGalleryExtension('a');
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None);
testObject.extension = paged.firstPage[0];
assert.ok(!testObject.enabled);
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is installed and uninstalled', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const gallery = aGalleryExtension('a');
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
return instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None)
.then((paged) => {
testObject.extension = paged.firstPage[0];
const identifier = gallery.identifier;
installEvent.fire({ identifier, gallery });
didInstallEvent.fire({ identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, { identifier }) });
uninstallEvent.fire(identifier);
didUninstallEvent.fire({ identifier });
const paged = await instantiationService.get(IExtensionsWorkbenchService).queryGallery(CancellationToken.None);
assert.ok(!testObject.enabled);
});
testObject.extension = paged.firstPage[0];
const identifier = gallery.identifier;
installEvent.fire({ identifier, gallery });
didInstallEvent.fire({ identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, { identifier }) });
uninstallEvent.fire(identifier);
didUninstallEvent.fire({ identifier });
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is uninstalled', async () => {
@@ -1145,8 +1162,7 @@ suite('ExtensionsActions Test', () => {
return new Promise(c => {
testObject.onDidChange(() => {
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
if (testObject.enabled && testObject.tooltip === 'Please reload Azure Data Studio to complete the uninstallation of this extension.') {
if (testObject.enabled && testObject.tooltip === 'Please reload Azure Data Studio to complete the uninstallation of this extension.') { // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
c();
}
});
@@ -1155,25 +1171,24 @@ suite('ExtensionsActions Test', () => {
});
});
test('Test ReloadAction when extension is uninstalled and installed', () => {
test('Test ReloadAction when extension is uninstalled and installed', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.a'), version: '1.0.0', extensionLocation: URI.file('pub.a') }]);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const local = aLocalExtension('a');
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return instantiationService.get(IExtensionsWorkbenchService).queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
uninstallEvent.fire(local.identifier);
didUninstallEvent.fire({ identifier: local.identifier });
const extensions = await instantiationService.get(IExtensionsWorkbenchService).queryLocal();
const gallery = aGalleryExtension('a');
const identifier = gallery.identifier;
installEvent.fire({ identifier, gallery });
didInstallEvent.fire({ identifier, gallery, operation: InstallOperation.Install, local });
testObject.extension = extensions[0];
uninstallEvent.fire(local.identifier);
didUninstallEvent.fire({ identifier: local.identifier });
assert.ok(!testObject.enabled);
});
const gallery = aGalleryExtension('a');
const identifier = gallery.identifier;
installEvent.fire({ identifier, gallery });
didInstallEvent.fire({ identifier, gallery, operation: InstallOperation.Install, local });
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is updated while running', async () => {
@@ -1188,8 +1203,7 @@ suite('ExtensionsActions Test', () => {
return new Promise(c => {
testObject.onDidChange(() => {
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
if (testObject.enabled && testObject.tooltip === 'Please reload Azure Data Studio to enable the updated extension.') {
if (testObject.enabled && testObject.tooltip === 'Please reload Azure Data Studio to enable the updated extension.') { // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
c();
}
});
@@ -1199,131 +1213,103 @@ suite('ExtensionsActions Test', () => {
});
});
test('Test ReloadAction when extension is updated when not running', () => {
test('Test ReloadAction when extension is updated when not running', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const local = aLocalExtension('a', { version: '1.0.1' });
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
.then(() => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
await instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.2' });
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Update, local: aLocalExtension('a', gallery, gallery) });
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.2' });
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Update, local: aLocalExtension('a', gallery, gallery) });
assert.ok(!testObject.enabled);
});
});
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is disabled when running', () => {
test('Test ReloadAction when extension is disabled when running', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.a'), extensionLocation: URI.file('pub.a') }]);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const local = aLocalExtension('a');
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal().then(extensions => {
testObject.extension = extensions[0];
return workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally)
.then(() => testObject.update())
.then(() => {
assert.ok(testObject.enabled);
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
assert.equal('Please reload Azure Data Studio to disable this extension.', testObject.tooltip);
});
});
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
await workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally);
await testObject.update();
assert.ok(testObject.enabled);
assert.equal('Please reload Azure Data Studio to disable this extension.', testObject.tooltip); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test ReloadAction when extension enablement is toggled when running', () => {
test('Test ReloadAction when extension enablement is toggled when running', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.a'), version: '1.0.0', extensionLocation: URI.file('pub.a') }]);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const local = aLocalExtension('a');
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal().
then(extensions => {
testObject.extension = extensions[0];
return workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally)
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally))
.then(() => assert.ok(!testObject.enabled));
});
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
await workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally);
await workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally);
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is enabled when not running', () => {
test('Test ReloadAction when extension is enabled when not running', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const local = aLocalExtension('a');
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
.then(() => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
.then(() => testObject.update())
.then(() => {
assert.ok(testObject.enabled);
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
assert.equal('Please reload Azure Data Studio to enable this extension.', testObject.tooltip);
});
});
});
await instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
await workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally);
await testObject.update();
assert.ok(testObject.enabled);
assert.equal('Please reload Azure Data Studio to enable this extension.', testObject.tooltip); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test ReloadAction when extension enablement is toggled when not running', () => {
test('Test ReloadAction when extension enablement is toggled when not running', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const local = aLocalExtension('a');
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
.then(() => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally))
.then(() => assert.ok(!testObject.enabled));
});
});
await instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
await workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally);
await workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally);
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is updated when not running and enabled', () => {
test('Test ReloadAction when extension is updated when not running and enabled', async () => {
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
const local = aLocalExtension('a', { version: '1.0.1' });
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
.then(() => {
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
return workbenchService.queryLocal()
.then(extensions => {
testObject.extension = extensions[0];
await instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally);
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
const workbenchService = instantiationService.get(IExtensionsWorkbenchService);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const extensions = await workbenchService.queryLocal();
testObject.extension = extensions[0];
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.2' });
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
.then(() => testObject.update())
.then(() => {
assert.ok(testObject.enabled);
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
assert.equal('Please reload Azure Data Studio to enable this extension.', testObject.tooltip);
});
});
});
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.2' });
installEvent.fire({ identifier: gallery.identifier, gallery });
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
await workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally);
await testObject.update();
assert.ok(testObject.enabled);
assert.equal('Please reload Azure Data Studio to enable this extension.', testObject.tooltip); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test ReloadAction when a localization extension is newly installed', async () => {
@@ -1358,6 +1344,146 @@ suite('ExtensionsActions Test', () => {
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is not installed but extension from different server is installed and running', async () => {
// multi server setup
const gallery = aGalleryExtension('a');
const localExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a') });
const remoteExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a').with({ scheme: Schemas.vscodeRemote }) });
const extensionManagementServerService = aMultiExtensionManagementServerService(instantiationService, createExtensionManagementService([localExtension]), createExtensionManagementService([remoteExtension]));
instantiationService.stub(IExtensionManagementServerService, extensionManagementServerService);
instantiationService.stub(IExtensionEnablementService, new TestExtensionEnablementService(instantiationService));
const workbenchService: IExtensionsWorkbenchService = instantiationService.createInstance(ExtensionsWorkbenchService);
instantiationService.set(IExtensionsWorkbenchService, workbenchService);
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
const runningExtensions = [ExtensionsActions.toExtensionDescription(remoteExtension)];
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve(runningExtensions),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => false
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
await workbenchService.queryGallery(CancellationToken.None);
const extensions = await workbenchService.queryLocal(extensionManagementServerService.localExtensionManagementServer!);
testObject.extension = extensions[0];
assert.ok(testObject.extension);
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is uninstalled but extension from different server is installed and running', async () => {
// multi server setup
const gallery = aGalleryExtension('a');
const localExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a') });
const remoteExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a').with({ scheme: Schemas.vscodeRemote }) });
const localExtensionManagementService = createExtensionManagementService([localExtension]);
const uninstallEvent = new Emitter<IExtensionIdentifier>();
const onDidUninstallEvent = new Emitter<{ identifier: IExtensionIdentifier }>();
localExtensionManagementService.onUninstallExtension = uninstallEvent.event;
localExtensionManagementService.onDidUninstallExtension = onDidUninstallEvent.event;
const extensionManagementServerService = aMultiExtensionManagementServerService(instantiationService, localExtensionManagementService, createExtensionManagementService([remoteExtension]));
instantiationService.stub(IExtensionManagementServerService, extensionManagementServerService);
instantiationService.stub(IExtensionEnablementService, new TestExtensionEnablementService(instantiationService));
const workbenchService: IExtensionsWorkbenchService = instantiationService.createInstance(ExtensionsWorkbenchService);
instantiationService.set(IExtensionsWorkbenchService, workbenchService);
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
const runningExtensions = [ExtensionsActions.toExtensionDescription(remoteExtension)];
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve(runningExtensions),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => false
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
await workbenchService.queryGallery(CancellationToken.None);
const extensions = await workbenchService.queryLocal(extensionManagementServerService.localExtensionManagementServer!);
testObject.extension = extensions[0];
assert.ok(testObject.extension);
assert.ok(!testObject.enabled);
uninstallEvent.fire(localExtension.identifier);
didUninstallEvent.fire({ identifier: localExtension.identifier });
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when workspace extension is disabled on local server and installed in remote server', async () => {
// multi server setup
const gallery = aGalleryExtension('a');
const remoteExtensionManagementService = createExtensionManagementService([]);
const onDidInstallEvent = new Emitter<DidInstallExtensionEvent>();
remoteExtensionManagementService.onDidInstallExtension = onDidInstallEvent.event;
const localExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a') });
const extensionManagementServerService = aMultiExtensionManagementServerService(instantiationService, createExtensionManagementService([localExtension]), remoteExtensionManagementService);
instantiationService.stub(IExtensionManagementServerService, extensionManagementServerService);
instantiationService.stub(IExtensionEnablementService, new TestExtensionEnablementService(instantiationService));
const workbenchService: IExtensionsWorkbenchService = instantiationService.createInstance(ExtensionsWorkbenchService);
instantiationService.set(IExtensionsWorkbenchService, workbenchService);
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve([]),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => false
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
await workbenchService.queryGallery(CancellationToken.None);
const extensions = await workbenchService.queryLocal(extensionManagementServerService.localExtensionManagementServer!);
testObject.extension = extensions[0];
assert.ok(testObject.extension);
assert.ok(!testObject.enabled);
const remoteExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file('pub.a').with({ scheme: Schemas.vscodeRemote }) });
onDidInstallEvent.fire({ identifier: remoteExtension.identifier, local: remoteExtension, operation: InstallOperation.Install });
assert.ok(testObject.enabled);
assert.equal(testObject.tooltip, 'Please reload Azure Data Studio to enable this extension.'); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test ReloadAction when ui extension is disabled on remote server and installed in local server', async () => {
// multi server setup
const gallery = aGalleryExtension('a');
const localExtensionManagementService = createExtensionManagementService([]);
const onDidInstallEvent = new Emitter<DidInstallExtensionEvent>();
localExtensionManagementService.onDidInstallExtension = onDidInstallEvent.event;
const remoteExtension = aLocalExtension('a', { extensionKind: 'ui' }, { location: URI.file('pub.a').with({ scheme: Schemas.vscodeRemote }) });
const extensionManagementServerService = aMultiExtensionManagementServerService(instantiationService, localExtensionManagementService, createExtensionManagementService([remoteExtension]));
instantiationService.stub(IExtensionManagementServerService, extensionManagementServerService);
instantiationService.stub(IExtensionEnablementService, new TestExtensionEnablementService(instantiationService));
const workbenchService: IExtensionsWorkbenchService = instantiationService.createInstance(ExtensionsWorkbenchService);
instantiationService.set(IExtensionsWorkbenchService, workbenchService);
const onDidChangeExtensionsEmitter: Emitter<void> = new Emitter<void>();
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve([]),
onDidChangeExtensions: onDidChangeExtensionsEmitter.event,
canAddExtension: (extension) => false
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));
await workbenchService.queryGallery(CancellationToken.None);
const extensions = await workbenchService.queryLocal(extensionManagementServerService.remoteExtensionManagementServer!);
testObject.extension = extensions[0];
assert.ok(testObject.extension);
assert.ok(!testObject.enabled);
const localExtension = aLocalExtension('a', { extensionKind: 'ui' }, { location: URI.file('pub.a') });
onDidInstallEvent.fire({ identifier: localExtension.identifier, local: localExtension, operation: InstallOperation.Install });
assert.ok(testObject.enabled);
assert.equal(testObject.tooltip, 'Please reload Azure Data Studio to enable this extension.'); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
});
test('Test remote install action is enabled for local workspace extension', async () => {
// multi server setup
const localWorkspaceExtension = aLocalExtension('a', { extensionKind: 'workspace' }, { location: URI.file(`pub.a`) });