提交 c954a8ab 编写于 作者: S Sandeep Somavarapu

Fix microsoft/vscode-remote-release/issues/1066

上级 bb256ef7
...@@ -3022,7 +3022,10 @@ interface IExtensionPickItem extends IQuickPickItem { ...@@ -3022,7 +3022,10 @@ interface IExtensionPickItem extends IQuickPickItem {
export class InstallLocalExtensionsInRemoteAction extends Action { export class InstallLocalExtensionsInRemoteAction extends Action {
private extensions: IExtension[] | undefined = undefined;
constructor( constructor(
private readonly selectAndInstall: boolean,
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService, @IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService, @IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService, @IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
...@@ -3034,7 +3037,12 @@ export class InstallLocalExtensionsInRemoteAction extends Action { ...@@ -3034,7 +3037,12 @@ export class InstallLocalExtensionsInRemoteAction extends Action {
) { ) {
super('workbench.extensions.actions.installLocalExtensionsInRemote'); super('workbench.extensions.actions.installLocalExtensionsInRemote');
this.update(); this.update();
this._register(this.extensionsWorkbenchService.onChange(() => this.update())); this.extensionsWorkbenchService.queryLocal().then(() => this.updateExtensions());
this._register(this.extensionsWorkbenchService.onChange(() => {
if (this.extensions) {
this.updateExtensions();
}
}));
} }
get label(): string { get label(): string {
...@@ -3042,24 +3050,38 @@ export class InstallLocalExtensionsInRemoteAction extends Action { ...@@ -3042,24 +3050,38 @@ export class InstallLocalExtensionsInRemoteAction extends Action {
localize('install local extensions', "Install Local Extensions in {0}...", this.extensionManagementServerService.remoteExtensionManagementServer.label) : ''; localize('install local extensions', "Install Local Extensions in {0}...", this.extensionManagementServerService.remoteExtensionManagementServer.label) : '';
} }
private updateExtensions(): void {
this.extensions = this.extensionsWorkbenchService.local;
this.update();
}
private update(): void { private update(): void {
this.enabled = this.getLocalExtensionsToInstall().length > 0; this.enabled = !!this.extensions && this.getExtensionsToInstall(this.extensions).length > 0;
}
async run(): Promise<void> {
if (this.selectAndInstall) {
return this.selectAndInstallLocalExtensions();
} else {
const extensionsToInstall = await this.queryExtensionsToInstall();
return this.installLocalExtensions(extensionsToInstall);
}
}
private async queryExtensionsToInstall(): Promise<IExtension[]> {
const local = await this.extensionsWorkbenchService.queryLocal();
return this.getExtensionsToInstall(local);
} }
private getLocalExtensionsToInstall(): IExtension[] { private getExtensionsToInstall(local: IExtension[]): IExtension[] {
return this.extensionsWorkbenchService.local.filter(extension => { return local.filter(extension => {
const action = this.instantiationService.createInstance(RemoteInstallAction); const action = this.instantiationService.createInstance(RemoteInstallAction);
action.extension = extension; action.extension = extension;
return action.enabled; return action.enabled;
}); });
} }
async run(): Promise<void> { private async selectAndInstallLocalExtensions(): Promise<void> {
this.selectAndInstallLocalExtensions();
return Promise.resolve();
}
private selectAndInstallLocalExtensions(): void {
const quickPick = this.quickInputService.createQuickPick<IExtensionPickItem>(); const quickPick = this.quickInputService.createQuickPick<IExtensionPickItem>();
quickPick.busy = true; quickPick.busy = true;
const disposable = quickPick.onDidAccept(() => { const disposable = quickPick.onDidAccept(() => {
...@@ -3069,7 +3091,7 @@ export class InstallLocalExtensionsInRemoteAction extends Action { ...@@ -3069,7 +3091,7 @@ export class InstallLocalExtensionsInRemoteAction extends Action {
this.onDidAccept(quickPick.selectedItems); this.onDidAccept(quickPick.selectedItems);
}); });
quickPick.show(); quickPick.show();
const localExtensionsToInstall = this.getLocalExtensionsToInstall(); const localExtensionsToInstall = await this.queryExtensionsToInstall();
quickPick.busy = false; quickPick.busy = false;
if (localExtensionsToInstall.length) { if (localExtensionsToInstall.length) {
quickPick.title = localize('install local extensions title', "Install Local Extensions in {0}", this.extensionManagementServerService.remoteExtensionManagementServer!.label); quickPick.title = localize('install local extensions title', "Install Local Extensions in {0}", this.extensionManagementServerService.remoteExtensionManagementServer!.label);
......
...@@ -22,7 +22,7 @@ import { IExtensionsWorkbenchService, IExtensionsViewlet, VIEWLET_ID, AutoUpdate ...@@ -22,7 +22,7 @@ import { IExtensionsWorkbenchService, IExtensionsViewlet, VIEWLET_ID, AutoUpdate
import { import {
ShowEnabledExtensionsAction, ShowInstalledExtensionsAction, ShowRecommendedExtensionsAction, ShowPopularExtensionsAction, ShowDisabledExtensionsAction, ShowEnabledExtensionsAction, ShowInstalledExtensionsAction, ShowRecommendedExtensionsAction, ShowPopularExtensionsAction, ShowDisabledExtensionsAction,
ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction, CheckForUpdatesAction, DisableAllAction, EnableAllAction, ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction, CheckForUpdatesAction, DisableAllAction, EnableAllAction,
EnableAutoUpdateAction, DisableAutoUpdateAction, ShowBuiltInExtensionsAction, InstallVSIXAction, InstallLocalExtensionsInRemoteAction EnableAutoUpdateAction, DisableAutoUpdateAction, ShowBuiltInExtensionsAction, InstallVSIXAction
} from 'vs/workbench/contrib/extensions/browser/extensionsActions'; } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionEnablementService, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; import { IExtensionEnablementService, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
...@@ -348,7 +348,6 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio ...@@ -348,7 +348,6 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
@IInstantiationService instantiationService: IInstantiationService, @IInstantiationService instantiationService: IInstantiationService,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService, @IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@INotificationService private readonly notificationService: INotificationService, @INotificationService private readonly notificationService: INotificationService,
@IViewletService private readonly viewletService: IViewletService, @IViewletService private readonly viewletService: IViewletService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
...@@ -478,7 +477,6 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio ...@@ -478,7 +477,6 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
this.instantiationService.createInstance(CheckForUpdatesAction, CheckForUpdatesAction.ID, CheckForUpdatesAction.LABEL), this.instantiationService.createInstance(CheckForUpdatesAction, CheckForUpdatesAction.ID, CheckForUpdatesAction.LABEL),
...(this.configurationService.getValue(AutoUpdateConfigurationKey) ? [this.instantiationService.createInstance(DisableAutoUpdateAction, DisableAutoUpdateAction.ID, DisableAutoUpdateAction.LABEL)] : [this.instantiationService.createInstance(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL), this.instantiationService.createInstance(EnableAutoUpdateAction, EnableAutoUpdateAction.ID, EnableAutoUpdateAction.LABEL)]), ...(this.configurationService.getValue(AutoUpdateConfigurationKey) ? [this.instantiationService.createInstance(DisableAutoUpdateAction, DisableAutoUpdateAction.ID, DisableAutoUpdateAction.LABEL)] : [this.instantiationService.createInstance(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL), this.instantiationService.createInstance(EnableAutoUpdateAction, EnableAutoUpdateAction.ID, EnableAutoUpdateAction.LABEL)]),
this.instantiationService.createInstance(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL), this.instantiationService.createInstance(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL),
...(this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer ? [this.instantiationService.createInstance(InstallLocalExtensionsInRemoteAction)] : []),
new Separator(), new Separator(),
this.instantiationService.createInstance(DisableAllAction, DisableAllAction.ID, DisableAllAction.LABEL), this.instantiationService.createInstance(DisableAllAction, DisableAllAction.ID, DisableAllAction.LABEL),
this.instantiationService.createInstance(EnableAllAction, EnableAllAction.ID, EnableAllAction.LABEL) this.instantiationService.createInstance(EnableAllAction, EnableAllAction.ID, EnableAllAction.LABEL)
......
...@@ -28,7 +28,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic ...@@ -28,7 +28,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge'; import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { InstallWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, ManageExtensionAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions'; import { InstallWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, ManageExtensionAction, InstallLocalExtensionsInRemoteAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { WorkbenchPagedList } from 'vs/platform/list/browser/listService'; import { WorkbenchPagedList } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
...@@ -73,7 +73,7 @@ class ExtensionListViewWarning extends Error { } ...@@ -73,7 +73,7 @@ class ExtensionListViewWarning extends Error { }
export class ExtensionsListView extends ViewletPanel { export class ExtensionsListView extends ViewletPanel {
private readonly server: IExtensionManagementServer | undefined; protected readonly server: IExtensionManagementServer | undefined;
private messageContainer: HTMLElement; private messageContainer: HTMLElement;
private messageSeverityIcon: HTMLElement; private messageSeverityIcon: HTMLElement;
private messageBox: HTMLElement; private messageBox: HTMLElement;
...@@ -861,6 +861,15 @@ export class ServerExtensionsView extends ExtensionsListView { ...@@ -861,6 +861,15 @@ export class ServerExtensionsView extends ExtensionsListView {
} }
return super.show(query.trim()); return super.show(query.trim());
} }
getActions(): IAction[] {
if (this.extensionManagementServerService.localExtensionManagementServer === this.server) {
const installLocalExtensionsInRemoteAction = this._register(this.instantiationService.createInstance(InstallLocalExtensionsInRemoteAction, false));
installLocalExtensionsInRemoteAction.class = 'octicon octicon-cloud-download';
return [installLocalExtensionsInRemoteAction];
}
return [];
}
} }
export class EnabledExtensionsView extends ExtensionsListView { export class EnabledExtensionsView extends ExtensionsListView {
......
...@@ -22,7 +22,7 @@ export class RemoteExtensionsInstaller extends Disposable implements IWorkbenchC ...@@ -22,7 +22,7 @@ export class RemoteExtensionsInstaller extends Disposable implements IWorkbenchC
) { ) {
super(); super();
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) { if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
const installLocalExtensionsInRemoteAction = instantiationService.createInstance(InstallLocalExtensionsInRemoteAction); const installLocalExtensionsInRemoteAction = instantiationService.createInstance(InstallLocalExtensionsInRemoteAction, true);
CommandsRegistry.registerCommand('workbench.extensions.installLocalExtensions', () => installLocalExtensionsInRemoteAction.run()); CommandsRegistry.registerCommand('workbench.extensions.installLocalExtensions', () => installLocalExtensionsInRemoteAction.run());
let disposable = Disposable.None; let disposable = Disposable.None;
const appendMenuItem = () => { const appendMenuItem = () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册