Merge from vscode 2cfc8172e533e50c90e6a3152f6bfb1f82f963f3 (#6516)

* Merge from vscode 2cfc8172e533e50c90e6a3152f6bfb1f82f963f3

* fix tests
This commit is contained in:
Anthony Dresser
2019-07-28 15:15:24 -07:00
committed by GitHub
parent aacf1e7f1c
commit 1d56a17f32
292 changed files with 19784 additions and 1873 deletions

View File

@@ -62,6 +62,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
import { IProductService } from 'vs/platform/product/common/product';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; // {{SQL CARBON EDIT}}
@@ -287,7 +288,7 @@ export class InstallAction extends ExtensionAction {
}
}
export class InstallInOtherServerAction extends ExtensionAction {
export abstract class InstallInOtherServerAction extends ExtensionAction {
protected static INSTALL_LABEL = localize('install', "Install");
protected static INSTALLING_LABEL = localize('installing', "Installing");
@@ -296,7 +297,6 @@ export class InstallInOtherServerAction extends ExtensionAction {
private static readonly InstallingClass = 'extension-action install installing';
updateWhenCounterExtensionChanges: boolean = true;
protected installing: boolean = false;
constructor(
id: string,
@@ -304,70 +304,63 @@ export class InstallInOtherServerAction extends ExtensionAction {
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
) {
super(id, InstallInOtherServerAction.INSTALL_LABEL, InstallInOtherServerAction.Class, false);
this.updateLabel();
this.update();
}
private updateLabel(): void {
this.label = this.getLabel();
this.tooltip = this.label;
}
protected getLabel(): string {
return this.installing ? InstallInOtherServerAction.INSTALLING_LABEL :
this.server ? `${InstallInOtherServerAction.INSTALL_LABEL} on ${this.server.label}`
: InstallInOtherServerAction.INSTALL_LABEL;
}
update(): void {
this.enabled = false;
this.class = InstallInOtherServerAction.Class;
if (this.installing) {
this.enabled = true;
this.class = InstallInOtherServerAction.InstallingClass;
this.updateLabel();
return;
}
if (
this.extension && this.extension.local && this.server && this.extension.state === ExtensionState.Installed
this.extension && this.extension.local && this.server && this.extension.state === ExtensionState.Installed && this.extension.type === ExtensionType.User
// disabled by extension kind or it is a language pack extension
&& (this.extension.enablementState === EnablementState.DisabledByExtensionKind || isLanguagePackExtension(this.extension.local.manifest))
// Not installed in other server and can install in other server
&& !this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.server)
&& this.extensionsWorkbenchService.canInstall(this.extension)
) {
this.enabled = true;
this.updateLabel();
return;
const extensionInOtherServer = this.extensionsWorkbenchService.installed.filter(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.server)[0];
if (extensionInOtherServer) {
// Getting installed in other server
if (extensionInOtherServer.state === ExtensionState.Installing && !extensionInOtherServer.local) {
this.enabled = true;
this.label = InstallInOtherServerAction.INSTALLING_LABEL;
this.class = InstallInOtherServerAction.InstallingClass;
}
} else {
// Not installed in other server
this.enabled = true;
this.label = this.getInstallLabel();
}
}
}
async run(): Promise<void> {
if (this.server && !this.installing) {
this.installing = true;
this.update();
if (this.server) {
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.server.extensionManagementService.installFromGallery(this.extension.gallery);
this.installing = false;
this.update();
} else {
const vsix = await this.extension.server!.extensionManagementService.zip(this.extension.local!);
await this.server.extensionManagementService.install(vsix);
}
}
}
protected abstract getInstallLabel(): string;
}
export class RemoteInstallAction extends InstallInOtherServerAction {
constructor(
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionManagementServerService extensionManagementServerService: IExtensionManagementServerService
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
) {
super(`extensions.remoteinstall`, extensionManagementServerService.remoteExtensionManagementServer, extensionsWorkbenchService);
}
protected getInstallLabel(): string {
return this.extensionManagementServerService.remoteExtensionManagementServer ? localize('Install on Server', "Install on {0}", this.extensionManagementServerService.remoteExtensionManagementServer.label) : InstallInOtherServerAction.INSTALL_LABEL;
}
}
export class LocalInstallAction extends InstallInOtherServerAction {
@@ -379,8 +372,8 @@ export class LocalInstallAction extends InstallInOtherServerAction {
super(`extensions.localinstall`, extensionManagementServerService.localExtensionManagementServer, extensionsWorkbenchService);
}
protected getLabel(): string {
return this.installing ? InstallInOtherServerAction.INSTALLING_LABEL : localize('install locally', "Install Locally");
protected getInstallLabel(): string {
return localize('install locally', "Install Locally");
}
}
@@ -1220,7 +1213,7 @@ export class ReloadAction extends ExtensionAction {
const isSameExtensionRunning = runningExtension && this.extension.server === this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation);
if (isUninstalled) {
if (isSameExtensionRunning) {
if (isSameExtensionRunning && !this.extensionService.canRemoveExtension(runningExtension)) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
// {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
@@ -1725,7 +1718,7 @@ export class InstallRecommendedExtensionAction extends Action {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search('@recommended ');
viewlet.search(`@id:${this.extensionId}`);
viewlet.focus();
return this.extensionWorkbenchService.queryGallery({ names: [this.extensionId], source: 'install-recommendation', pageSize: 1 }, CancellationToken.None)
.then(pager => {
@@ -3092,6 +3085,119 @@ export class InstallSpecificVersionOfExtensionAction extends Action {
}
}
interface IExtensionPickItem extends IQuickPickItem {
extension?: IExtension;
}
export class InstallLocalExtensionsOnRemoteAction extends Action {
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@INotificationService private readonly notificationService: INotificationService,
@IWindowService private readonly windowService: IWindowService,
@IProgressService private readonly progressService: IProgressService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super('workbench.extensions.actions.installLocalExtensionsOnRemote');
this.update();
this._register(this.extensionsWorkbenchService.onChange(() => this.update()));
}
get label(): string {
return this.extensionManagementServerService.remoteExtensionManagementServer ?
localize('install local extensions', "Install Local Extensions on {0}", this.extensionManagementServerService.remoteExtensionManagementServer.label) : '';
}
private update(): void {
this.enabled = this.getLocalExtensionsToInstall().length > 0;
}
private getLocalExtensionsToInstall(): IExtension[] {
return this.extensionsWorkbenchService.local.filter(extension => {
const action = this.instantiationService.createInstance(RemoteInstallAction);
action.extension = extension;
return action.enabled;
});
}
async run(): Promise<void> {
this.selectAndInstallLocalExtensions();
return Promise.resolve();
}
private selectAndInstallLocalExtensions(): void {
const quickPick = this.quickInputService.createQuickPick<IExtensionPickItem>();
quickPick.busy = true;
const disposable = quickPick.onDidAccept(() => {
disposable.dispose();
quickPick.hide();
quickPick.dispose();
this.onDidAccept(quickPick.selectedItems);
});
quickPick.show();
const localExtensionsToInstall = this.getLocalExtensionsToInstall();
quickPick.busy = false;
if (localExtensionsToInstall.length) {
quickPick.placeholder = localize('select extensions to install', "Select extensions to install");
quickPick.canSelectMany = true;
localExtensionsToInstall.sort((e1, e2) => e1.displayName.localeCompare(e2.displayName));
quickPick.items = localExtensionsToInstall.map<IExtensionPickItem>(extension => ({ extension, label: extension.displayName, description: extension.version }));
} else {
quickPick.hide();
quickPick.dispose();
this.notificationService.notify({
severity: Severity.Info,
message: localize('no local extensions', "There are no extensions to install.")
});
}
}
private onDidAccept(selectedItems: ReadonlyArray<IExtensionPickItem>): void {
if (selectedItems.length) {
const localExtensionsToInstall = selectedItems.filter(r => !!r.extension).map(r => r.extension!);
if (localExtensionsToInstall.length) {
this.progressService.withProgress(
{
location: ProgressLocation.Notification,
title: localize('installing extensions', "Installing Extensions...")
},
() => this.installLocalExtensions(localExtensionsToInstall));
}
}
}
private async installLocalExtensions(localExtensionsToInstall: IExtension[]): Promise<void> {
const galleryExtensions: IGalleryExtension[] = [];
const vsixs: URI[] = [];
await Promise.all(localExtensionsToInstall.map(async extension => {
if (this.extensionGalleryService.isEnabled()) {
const gallery = await this.extensionGalleryService.getCompatibleExtension(extension.identifier, extension.version);
if (gallery) {
galleryExtensions.push(gallery);
return;
}
}
const vsix = await this.extensionManagementServerService.localExtensionManagementServer!.extensionManagementService.zip(extension.local!);
vsixs.push(vsix);
}));
await Promise.all(galleryExtensions.map(gallery => this.extensionManagementServerService.remoteExtensionManagementServer!.extensionManagementService.installFromGallery(gallery)));
await Promise.all(vsixs.map(vsix => this.extensionManagementServerService.remoteExtensionManagementServer!.extensionManagementService.install(vsix)));
this.notificationService.notify({
severity: Severity.Info,
message: localize('finished installing', "Completed installing the extensions. Please reload the window now."),
actions: {
primary: [new Action('realod', localize('reload', "Realod Window"), '', true,
() => this.windowService.reloadWindow())]
}
});
}
}
CommandsRegistry.registerCommand('workbench.extensions.action.showExtensionsForLanguage', function (accessor: ServicesAccessor, fileExtension: string) {
const viewletService = accessor.get(IViewletService);