@@ -15,7 +15,7 @@ import { disposeIfDisposable } from 'vs/base/common/lifecycle';
15
15
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' ;
16
16
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate' ;
17
17
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' ;
19
19
import { ExtensionRecommendationReason , IExtensionIgnoredRecommendationsService , IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations' ;
20
20
import { areSameExtensions , getExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
21
21
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/
51
51
import { IActionViewItemOptions , ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
52
52
import { EXTENSIONS_CONFIG , IExtensionsConfigContent } from 'vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig' ;
53
53
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' ;
55
55
import { ActionWithDropdownActionViewItem , IActionWithDropdownActionViewItemOptions } from 'vs/base/browser/ui/dropdown/dropdownActionViewItem' ;
56
56
import { IContextMenuProvider } from 'vs/base/browser/contextmenu' ;
57
57
import { ILogService } from 'vs/platform/log/common/log' ;
@@ -128,7 +128,7 @@ export class PromptExtensionInstallFailureAction extends Action {
128
128
buttons : [ {
129
129
label : localize ( 'install anyway' , "Install Anyway" ) ,
130
130
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 } ) ;
132
132
installAction . extension = this . extension ;
133
133
return installAction . run ( ) ;
134
134
}
@@ -149,7 +149,7 @@ export class PromptExtensionInstallFailureAction extends Action {
149
149
promptChoices . push ( {
150
150
label : localize ( 'install release version' , "Install Release Version" ) ,
151
151
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 } ) ;
153
153
installAction . extension = this . extension ;
154
154
return installAction . run ( ) ;
155
155
}
@@ -295,7 +295,7 @@ export class ActionWithDropDownAction extends ExtensionAction {
295
295
}
296
296
}
297
297
298
- export abstract class AbstractInstallAction extends ExtensionAction {
298
+ export class InstallAction extends ExtensionAction {
299
299
300
300
static readonly Class = `${ ExtensionAction . LABEL_ACTION_CLASS } prominent install` ;
301
301
@@ -306,9 +306,10 @@ export abstract class AbstractInstallAction extends ExtensionAction {
306
306
}
307
307
308
308
private readonly updateThrottler = new Throttler ( ) ;
309
+ public readonly options : InstallOptions ;
309
310
310
311
constructor (
311
- id : string , readonly options : InstallOptions , cssClass : string ,
312
+ options : InstallOptions ,
312
313
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService : IExtensionsWorkbenchService ,
313
314
@IInstantiationService private readonly instantiationService : IInstantiationService ,
314
315
@IExtensionService private readonly runtimeExtensionService : IExtensionService ,
@@ -318,7 +319,8 @@ export abstract class AbstractInstallAction extends ExtensionAction {
318
319
@IPreferencesService private readonly preferencesService : IPreferencesService ,
319
320
@ITelemetryService private readonly telemetryService : ITelemetryService ,
320
321
) {
321
- super ( id , localize ( 'install' , "Install" ) , cssClass , false ) ;
322
+ super ( 'extensions.install' , localize ( 'install' , "Install" ) , InstallAction . Class , false ) ;
323
+ this . options = { ...options , isMachineScoped : false } ;
322
324
this . update ( ) ;
323
325
this . _register ( this . labelService . onDidChangeFormatters ( ( ) => this . updateLabel ( ) , this ) ) ;
324
326
}
@@ -464,11 +466,10 @@ export abstract class AbstractInstallAction extends ExtensionAction {
464
466
}
465
467
466
468
private async install ( extension : IExtension ) : Promise < IExtension | undefined > {
467
- const installOptions = this . getInstallOptions ( ) ;
468
469
try {
469
- return await this . extensionsWorkbenchService . install ( extension , installOptions ) ;
470
+ return await this . extensionsWorkbenchService . install ( extension , this . options ) ;
470
471
} 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 ( ) ;
472
473
return undefined ;
473
474
}
474
475
}
@@ -508,117 +509,12 @@ export abstract class AbstractInstallAction extends ExtensionAction {
508
509
return localize ( 'install' , "Install" ) ;
509
510
}
510
511
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
- }
616
512
}
617
513
618
514
export class InstallDropdownAction extends ActionWithDropDownAction {
619
515
620
516
set manifest ( manifest : IExtensionManifest | null ) {
621
- this . extensionActions . forEach ( a => ( < AbstractInstallAction > a ) . manifest = manifest ) ;
517
+ this . extensionActions . forEach ( a => ( < InstallAction > a ) . manifest = manifest ) ;
622
518
this . update ( ) ;
623
519
}
624
520
@@ -627,18 +523,14 @@ export class InstallDropdownAction extends ActionWithDropDownAction {
627
523
@IExtensionsWorkbenchService extensionsWorkbenchService : IExtensionsWorkbenchService ,
628
524
) {
629
525
super ( `extensions.installActions` , '' , [
630
- [
631
- instantiationService . createInstance ( InstallAndSyncAction , { installPreReleaseVersion : extensionsWorkbenchService . preferPreReleases } ) ,
632
- instantiationService . createInstance ( InstallAndSyncAction , { installPreReleaseVersion : ! extensionsWorkbenchService . preferPreReleases } ) ,
633
- ] ,
634
526
[
635
527
instantiationService . createInstance ( InstallAction , { installPreReleaseVersion : extensionsWorkbenchService . preferPreReleases } ) ,
636
528
instantiationService . createInstance ( InstallAction , { installPreReleaseVersion : ! extensionsWorkbenchService . preferPreReleases } ) ,
637
529
]
638
530
] ) ;
639
531
}
640
532
641
- protected override getLabel ( action : AbstractInstallAction ) : string {
533
+ protected override getLabel ( action : InstallAction ) : string {
642
534
return action . getLabel ( true ) ;
643
535
}
644
536
0 commit comments