Skip to content

Commit 903c5c6

Browse files
authored
- Remove Show Extension button (microsoft#150274)
- Add Open Alternative Extension or Configure Settings button
1 parent a3a7f52 commit 903c5c6

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

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

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
6565
import { ViewContainerLocation } from 'vs/workbench/common/views';
6666
import { flatten } from 'vs/base/common/arrays';
6767
import { fromNow } from 'vs/base/common/date';
68+
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
6869

6970
export class PromptExtensionInstallFailureAction extends Action {
7071

@@ -250,6 +251,7 @@ export abstract class AbstractInstallAction extends ExtensionAction {
250251
@IWorkbenchThemeService private readonly workbenchThemeService: IWorkbenchThemeService,
251252
@ILabelService private readonly labelService: ILabelService,
252253
@IDialogService private readonly dialogService: IDialogService,
254+
@IPreferencesService private readonly preferencesService: IPreferencesService,
253255
) {
254256
super(id, localize('install', "Install"), cssClass, false);
255257
this.update();
@@ -276,20 +278,33 @@ export abstract class AbstractInstallAction extends ExtensionAction {
276278
}
277279

278280
if (this.extension.deprecationInfo) {
281+
let detail = localize('deprecated message', "This extension is no longer being maintained and is deprecated.");
282+
let action: () => Promise<any> = async () => undefined;
283+
const buttons = [
284+
localize('install anyway', "Install Anyway"),
285+
localize('cancel', "Cancel"),
286+
];
287+
288+
if (this.extension.deprecationInfo.extension) {
289+
detail = localize('deprecated with alternate extension message', "This extension has been deprecated. Use {0} instead.", this.extension.deprecationInfo.extension.displayName);
290+
buttons.splice(1, 0, localize('Show alternate extension', "Open {0}", this.extension.deprecationInfo.extension.displayName));
291+
const alternateExtension = this.extension.deprecationInfo.extension;
292+
action = () => this.extensionsWorkbenchService.getExtensions([{ id: alternateExtension.id, preRelease: alternateExtension.preRelease }], CancellationToken.None)
293+
.then(([extension]) => this.extensionsWorkbenchService.open(extension));
294+
} else if (this.extension.deprecationInfo.settings) {
295+
detail = localize('deprecated with alternate settings message', "This extension is deprecated and has become a native feature in VS Code.");
296+
buttons.splice(1, 0, localize('configure in settings', "Configure Settings"));
297+
const settings = this.extension.deprecationInfo.settings;
298+
action = () => this.preferencesService.openSettings({ query: settings.map(setting => `@id:${setting}`).join(' ') });
299+
}
300+
279301
const result = await this.dialogService.show(
280302
Severity.Warning,
281303
localize('install confirmation', "Are you sure you want to install '{0}'?", this.extension.displayName),
282-
[
283-
localize('install anyway', "Install Anyway"),
284-
localize('open extension', "Open Extension"),
285-
localize('cancel', "Cancel"),
286-
],
287-
{
288-
detail: localize('deprecated message', "This extension is no longer being maintained and is deprecated."),
289-
cancelId: 2,
290-
});
304+
buttons,
305+
{ detail, cancelId: buttons.length - 1 });
291306
if (result.choice === 1) {
292-
return this.extensionsWorkbenchService.open(this.extension, { showPreReleaseVersion: this.installPreReleaseVersion });
307+
return action();
293308
}
294309
if (result.choice === 2) {
295310
return;
@@ -396,12 +411,13 @@ export class InstallAction extends AbstractInstallAction {
396411
@IWorkbenchThemeService workbenchThemeService: IWorkbenchThemeService,
397412
@ILabelService labelService: ILabelService,
398413
@IDialogService dialogService: IDialogService,
414+
@IPreferencesService preferencesService: IPreferencesService,
399415
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
400416
@IWorkbenchExtensionManagementService private readonly workbenchExtensioManagementService: IWorkbenchExtensionManagementService,
401417
@IUserDataSyncEnablementService protected readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
402418
) {
403419
super(`extensions.install`, installPreReleaseVersion, InstallAction.Class,
404-
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService);
420+
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService, preferencesService);
405421
this.updateLabel();
406422
this._register(labelService.onDidChangeFormatters(() => this.updateLabel(), this));
407423
this._register(Event.any(userDataSyncEnablementService.onDidChangeEnablement,
@@ -462,11 +478,12 @@ export class InstallAndSyncAction extends AbstractInstallAction {
462478
@IWorkbenchThemeService workbenchThemeService: IWorkbenchThemeService,
463479
@ILabelService labelService: ILabelService,
464480
@IDialogService dialogService: IDialogService,
481+
@IPreferencesService preferencesService: IPreferencesService,
465482
@IProductService productService: IProductService,
466483
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
467484
) {
468485
super('extensions.installAndSync', installPreReleaseVersion, AbstractInstallAction.Class,
469-
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService);
486+
extensionsWorkbenchService, instantiationService, runtimeExtensionService, workbenchThemeService, labelService, dialogService, preferencesService);
470487
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);
471488
this._register(Event.any(userDataSyncEnablementService.onDidChangeEnablement,
472489
Event.filter(userDataSyncEnablementService.onDidChangeResourceEnablement, e => e[0] === SyncResource.Extensions))(() => this.update()));

0 commit comments

Comments
 (0)