Skip to content

Commit 218c6d4

Browse files
authored
* microsoft#177481 remove install and do not sync action * microsoft#177481 more cleanup
1 parent cf31308 commit 218c6d4

File tree

1 file changed

+13
-121
lines changed

1 file changed

+13
-121
lines changed

src/vs/workbench/contrib/extensions/browser/extensionsActions.ts

Lines changed: 13 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { disposeIfDisposable } from 'vs/base/common/lifecycle';
1515
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewPaneContainer, IExtensionContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP } from 'vs/workbench/contrib/extensions/common/extensions';
1616
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
1717
import { IGalleryExtension, IExtensionGalleryService, ILocalExtension, InstallOptions, InstallOperation, TargetPlatformToString, ExtensionManagementErrorCode } from 'vs/platform/extensionManagement/common/extensionManagement';
18-
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer, IWorkbenchExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
18+
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
1919
import { ExtensionRecommendationReason, IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
2020
import { areSameExtensions, getExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
2121
import { ExtensionType, ExtensionIdentifier, IExtensionDescription, IExtensionManifest, isLanguagePackExtension, getWorkspaceSupportTypeMessage, TargetPlatform } from 'vs/platform/extensions/common/extensions';
@@ -51,7 +51,7 @@ import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/
5151
import { IActionViewItemOptions, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
5252
import { EXTENSIONS_CONFIG, IExtensionsConfigContent } from 'vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig';
5353
import { getErrorMessage, isCancellationError } from 'vs/base/common/errors';
54-
import { IUserDataSyncEnablementService, SyncResource } from 'vs/platform/userDataSync/common/userDataSync';
54+
import { IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
5555
import { ActionWithDropdownActionViewItem, IActionWithDropdownActionViewItemOptions } from 'vs/base/browser/ui/dropdown/dropdownActionViewItem';
5656
import { IContextMenuProvider } from 'vs/base/browser/contextmenu';
5757
import { ILogService } from 'vs/platform/log/common/log';
@@ -128,7 +128,7 @@ export class PromptExtensionInstallFailureAction extends Action {
128128
buttons: [{
129129
label: localize('install anyway', "Install Anyway"),
130130
run: () => {
131-
const installAction = this.installOptions?.isMachineScoped ? this.instantiationService.createInstance(InstallAction, { donotVerifySignature: true }) : this.instantiationService.createInstance(InstallAndSyncAction, { donotVerifySignature: true });
131+
const installAction = this.instantiationService.createInstance(InstallAction, { donotVerifySignature: true });
132132
installAction.extension = this.extension;
133133
return installAction.run();
134134
}
@@ -149,7 +149,7 @@ export class PromptExtensionInstallFailureAction extends Action {
149149
promptChoices.push({
150150
label: localize('install release version', "Install Release Version"),
151151
run: () => {
152-
const installAction = this.installOptions?.isMachineScoped ? this.instantiationService.createInstance(InstallAction, { installPreReleaseVersion: !!this.installOptions.installPreReleaseVersion }) : this.instantiationService.createInstance(InstallAndSyncAction, { installPreReleaseVersion: !!this.installOptions?.installPreReleaseVersion });
152+
const installAction = this.instantiationService.createInstance(InstallAction, { installPreReleaseVersion: !!this.installOptions?.installPreReleaseVersion });
153153
installAction.extension = this.extension;
154154
return installAction.run();
155155
}
@@ -295,7 +295,7 @@ export class ActionWithDropDownAction extends ExtensionAction {
295295
}
296296
}
297297

298-
export abstract class AbstractInstallAction extends ExtensionAction {
298+
export class InstallAction extends ExtensionAction {
299299

300300
static readonly Class = `${ExtensionAction.LABEL_ACTION_CLASS} prominent install`;
301301

@@ -306,9 +306,10 @@ export abstract class AbstractInstallAction extends ExtensionAction {
306306
}
307307

308308
private readonly updateThrottler = new Throttler();
309+
public readonly options: InstallOptions;
309310

310311
constructor(
311-
id: string, readonly options: InstallOptions, cssClass: string,
312+
options: InstallOptions,
312313
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
313314
@IInstantiationService private readonly instantiationService: IInstantiationService,
314315
@IExtensionService private readonly runtimeExtensionService: IExtensionService,
@@ -318,7 +319,8 @@ export abstract class AbstractInstallAction extends ExtensionAction {
318319
@IPreferencesService private readonly preferencesService: IPreferencesService,
319320
@ITelemetryService private readonly telemetryService: ITelemetryService,
320321
) {
321-
super(id, localize('install', "Install"), cssClass, false);
322+
super('extensions.install', localize('install', "Install"), InstallAction.Class, false);
323+
this.options = { ...options, isMachineScoped: false };
322324
this.update();
323325
this._register(this.labelService.onDidChangeFormatters(() => this.updateLabel(), this));
324326
}
@@ -464,11 +466,10 @@ export abstract class AbstractInstallAction extends ExtensionAction {
464466
}
465467

466468
private async install(extension: IExtension): Promise<IExtension | undefined> {
467-
const installOptions = this.getInstallOptions();
468469
try {
469-
return await this.extensionsWorkbenchService.install(extension, installOptions);
470+
return await this.extensionsWorkbenchService.install(extension, this.options);
470471
} catch (error) {
471-
await this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, installOptions, error).run();
472+
await this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, this.options, error).run();
472473
return undefined;
473474
}
474475
}
@@ -508,117 +509,12 @@ export abstract class AbstractInstallAction extends ExtensionAction {
508509
return localize('install', "Install");
509510
}
510511

511-
protected getInstallOptions(): InstallOptions {
512-
return this.options;
513-
}
514-
}
515-
516-
export class InstallAction extends AbstractInstallAction {
517-
518-
constructor(
519-
options: InstallOptions,
520-
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
521-
@IInstantiationService instantiationService: IInstantiationService,
522-
@IExtensionService runtimeExtensionService: IExtensionService,
523-
@IWorkbenchThemeService workbenchThemeService: IWorkbenchThemeService,
524-
@ILabelService labelService: ILabelService,
525-
@IDialogService dialogService: IDialogService,
526-
@IPreferencesService preferencesService: IPreferencesService,
527-
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
528-
@IWorkbenchExtensionManagementService private readonly workbenchExtensionManagementService: IWorkbenchExtensionManagementService,
529-
@IUserDataSyncEnablementService protected readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
530-
@ITelemetryService telemetryService: ITelemetryService,
531-
) {
532-
super(`extensions.install`, options, InstallAction.Class,
533-
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService, preferencesService, telemetryService);
534-
this.updateLabel();
535-
this._register(labelService.onDidChangeFormatters(() => this.updateLabel(), this));
536-
this._register(Event.any(userDataSyncEnablementService.onDidChangeEnablement,
537-
Event.filter(userDataSyncEnablementService.onDidChangeResourceEnablement, e => e[0] === SyncResource.Extensions))(() => this.update()));
538-
}
539-
540-
override getLabel(primary?: boolean): string {
541-
const baseLabel = super.getLabel(primary);
542-
543-
const donotSyncLabel = localize('do no sync', "Do not sync");
544-
const isMachineScoped = this.getInstallOptions().isMachineScoped;
545-
546-
// When remote connection exists
547-
if (this._manifest && this.extensionManagementServerService.remoteExtensionManagementServer) {
548-
549-
const server = this.workbenchExtensionManagementService.getExtensionManagementServerToInstall(this._manifest);
550-
551-
if (server === this.extensionManagementServerService.remoteExtensionManagementServer) {
552-
const host = this.extensionManagementServerService.remoteExtensionManagementServer.label;
553-
return isMachineScoped
554-
? localize({
555-
key: 'install extension in remote and do not sync',
556-
comment: [
557-
'First placeholder is install action label.',
558-
'Second placeholder is the name of the action to install an extension in remote server and do not sync it. Placeholder is for the name of remote server.',
559-
'Third placeholder is do not sync label.',
560-
]
561-
}, "{0} in {1} ({2})", baseLabel, host, donotSyncLabel)
562-
: localize({
563-
key: 'install extension in remote',
564-
comment: [
565-
'First placeholder is install action label.',
566-
'Second placeholder is the name of the action to install an extension in remote server and do not sync it. Placeholder is for the name of remote server.',
567-
]
568-
}, "{0} in {1}", baseLabel, host);
569-
}
570-
571-
return isMachineScoped ?
572-
localize('install extension locally and do not sync', "{0} Locally ({1})", baseLabel, donotSyncLabel) : localize('install extension locally', "{0} Locally", baseLabel);
573-
}
574-
575-
return isMachineScoped ? `${baseLabel} (${donotSyncLabel})` : baseLabel;
576-
}
577-
578-
protected override getInstallOptions(): InstallOptions {
579-
return { ...super.getInstallOptions(), isMachineScoped: this.userDataSyncEnablementService.isEnabled() && this.userDataSyncEnablementService.isResourceEnabled(SyncResource.Extensions) };
580-
}
581-
582-
}
583-
584-
export class InstallAndSyncAction extends AbstractInstallAction {
585-
586-
constructor(
587-
options: InstallOptions,
588-
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
589-
@IInstantiationService instantiationService: IInstantiationService,
590-
@IExtensionService runtimeExtensionService: IExtensionService,
591-
@IWorkbenchThemeService workbenchThemeService: IWorkbenchThemeService,
592-
@ILabelService labelService: ILabelService,
593-
@IDialogService dialogService: IDialogService,
594-
@IPreferencesService preferencesService: IPreferencesService,
595-
@IProductService productService: IProductService,
596-
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
597-
@ITelemetryService telemetryService: ITelemetryService,
598-
) {
599-
super('extensions.installAndSync', options, AbstractInstallAction.Class,
600-
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService, preferencesService, telemetryService);
601-
this.tooltip = localize({ key: 'install everywhere tooltip', comment: ['Placeholder is the name of the product. Eg: Visual Studio Code or Visual Studio Code - Insiders'] }, "Install this extension in all your synced {0} instances", productService.nameLong);
602-
this._register(Event.any(userDataSyncEnablementService.onDidChangeEnablement,
603-
Event.filter(userDataSyncEnablementService.onDidChangeResourceEnablement, e => e[0] === SyncResource.Extensions))(() => this.update()));
604-
}
605-
606-
protected override async computeAndUpdateEnablement(): Promise<void> {
607-
await super.computeAndUpdateEnablement();
608-
if (this.enabled) {
609-
this.enabled = this.userDataSyncEnablementService.isEnabled() && this.userDataSyncEnablementService.isResourceEnabled(SyncResource.Extensions);
610-
}
611-
}
612-
613-
protected override getInstallOptions(): InstallOptions {
614-
return { ...super.getInstallOptions(), isMachineScoped: false };
615-
}
616512
}
617513

618514
export class InstallDropdownAction extends ActionWithDropDownAction {
619515

620516
set manifest(manifest: IExtensionManifest | null) {
621-
this.extensionActions.forEach(a => (<AbstractInstallAction>a).manifest = manifest);
517+
this.extensionActions.forEach(a => (<InstallAction>a).manifest = manifest);
622518
this.update();
623519
}
624520

@@ -627,18 +523,14 @@ export class InstallDropdownAction extends ActionWithDropDownAction {
627523
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
628524
) {
629525
super(`extensions.installActions`, '', [
630-
[
631-
instantiationService.createInstance(InstallAndSyncAction, { installPreReleaseVersion: extensionsWorkbenchService.preferPreReleases }),
632-
instantiationService.createInstance(InstallAndSyncAction, { installPreReleaseVersion: !extensionsWorkbenchService.preferPreReleases }),
633-
],
634526
[
635527
instantiationService.createInstance(InstallAction, { installPreReleaseVersion: extensionsWorkbenchService.preferPreReleases }),
636528
instantiationService.createInstance(InstallAction, { installPreReleaseVersion: !extensionsWorkbenchService.preferPreReleases }),
637529
]
638530
]);
639531
}
640532

641-
protected override getLabel(action: AbstractInstallAction): string {
533+
protected override getLabel(action: InstallAction): string {
642534
return action.getLabel(true);
643535
}
644536

0 commit comments

Comments
 (0)