@@ -65,6 +65,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
65
65
import { ViewContainerLocation } from 'vs/workbench/common/views' ;
66
66
import { flatten } from 'vs/base/common/arrays' ;
67
67
import { fromNow } from 'vs/base/common/date' ;
68
+ import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences' ;
68
69
69
70
export class PromptExtensionInstallFailureAction extends Action {
70
71
@@ -250,6 +251,7 @@ export abstract class AbstractInstallAction extends ExtensionAction {
250
251
@IWorkbenchThemeService private readonly workbenchThemeService : IWorkbenchThemeService ,
251
252
@ILabelService private readonly labelService : ILabelService ,
252
253
@IDialogService private readonly dialogService : IDialogService ,
254
+ @IPreferencesService private readonly preferencesService : IPreferencesService ,
253
255
) {
254
256
super ( id , localize ( 'install' , "Install" ) , cssClass , false ) ;
255
257
this . update ( ) ;
@@ -276,20 +278,33 @@ export abstract class AbstractInstallAction extends ExtensionAction {
276
278
}
277
279
278
280
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
+
279
301
const result = await this . dialogService . show (
280
302
Severity . Warning ,
281
303
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 } ) ;
291
306
if ( result . choice === 1 ) {
292
- return this . extensionsWorkbenchService . open ( this . extension , { showPreReleaseVersion : this . installPreReleaseVersion } ) ;
307
+ return action ( ) ;
293
308
}
294
309
if ( result . choice === 2 ) {
295
310
return ;
@@ -396,12 +411,13 @@ export class InstallAction extends AbstractInstallAction {
396
411
@IWorkbenchThemeService workbenchThemeService : IWorkbenchThemeService ,
397
412
@ILabelService labelService : ILabelService ,
398
413
@IDialogService dialogService : IDialogService ,
414
+ @IPreferencesService preferencesService : IPreferencesService ,
399
415
@IExtensionManagementServerService private readonly extensionManagementServerService : IExtensionManagementServerService ,
400
416
@IWorkbenchExtensionManagementService private readonly workbenchExtensioManagementService : IWorkbenchExtensionManagementService ,
401
417
@IUserDataSyncEnablementService protected readonly userDataSyncEnablementService : IUserDataSyncEnablementService ,
402
418
) {
403
419
super ( `extensions.install` , installPreReleaseVersion , InstallAction . Class ,
404
- extensionsWorkbenchService , instantiationService , runtimeExtensionService , workbenchThemeService , labelService , dialogService ) ;
420
+ extensionsWorkbenchService , instantiationService , runtimeExtensionService , workbenchThemeService , labelService , dialogService , preferencesService ) ;
405
421
this . updateLabel ( ) ;
406
422
this . _register ( labelService . onDidChangeFormatters ( ( ) => this . updateLabel ( ) , this ) ) ;
407
423
this . _register ( Event . any ( userDataSyncEnablementService . onDidChangeEnablement ,
@@ -462,11 +478,12 @@ export class InstallAndSyncAction extends AbstractInstallAction {
462
478
@IWorkbenchThemeService workbenchThemeService : IWorkbenchThemeService ,
463
479
@ILabelService labelService : ILabelService ,
464
480
@IDialogService dialogService : IDialogService ,
481
+ @IPreferencesService preferencesService : IPreferencesService ,
465
482
@IProductService productService : IProductService ,
466
483
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService : IUserDataSyncEnablementService ,
467
484
) {
468
485
super ( 'extensions.installAndSync' , installPreReleaseVersion , AbstractInstallAction . Class ,
469
- extensionsWorkbenchService , instantiationService , runtimeExtensionService , workbenchThemeService , labelService , dialogService ) ;
486
+ extensionsWorkbenchService , instantiationService , runtimeExtensionService , workbenchThemeService , labelService , dialogService , preferencesService ) ;
470
487
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 ) ;
471
488
this . _register ( Event . any ( userDataSyncEnablementService . onDidChangeEnablement ,
472
489
Event . filter ( userDataSyncEnablementService . onDidChangeResourceEnablement , e => e [ 0 ] === SyncResource . Extensions ) ) ( ( ) => this . update ( ) ) ) ;
0 commit comments