@@ -59,6 +59,8 @@ import { installLocalInRemoteIcon } from 'vs/workbench/contrib/extensions/browse
59
59
import { registerAction2 , Action2 , MenuId } from 'vs/platform/actions/common/actions' ;
60
60
import { IPaneComposite } from 'vs/workbench/common/panecomposite' ;
61
61
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite' ;
62
+ import { IProductService } from 'vs/platform/product/common/productService' ;
63
+ import { memoize } from 'vs/base/common/decorators' ;
62
64
63
65
const SearchMarketplaceExtensionsContext = new RawContextKey < boolean > ( 'searchMarketplaceExtensions' , false ) ;
64
66
const SearchIntalledExtensionsContext = new RawContextKey < boolean > ( 'searchInstalledExtensions' , false ) ;
@@ -73,17 +75,21 @@ const SearchUnsupportedWorkspaceExtensionsContext = new RawContextKey<boolean>('
73
75
const RecommendedExtensionsContext = new RawContextKey < boolean > ( 'recommendedExtensions' , false ) ;
74
76
75
77
export class ExtensionsViewletViewsContribution implements IWorkbenchContribution {
78
+ static EXTENSION_RECOMMENDATION_KEY = 'EXTENSION_RECOMMENDATION_KEY' ;
76
79
77
80
private readonly container : ViewContainer ;
78
81
79
82
constructor (
80
83
@IExtensionManagementServerService private readonly extensionManagementServerService : IExtensionManagementServerService ,
81
84
@ILabelService private readonly labelService : ILabelService ,
82
85
@IViewDescriptorService viewDescriptorService : IViewDescriptorService ,
83
- @IContextKeyService private readonly contextKeyService : IContextKeyService
86
+ @IContextKeyService private readonly contextKeyService : IContextKeyService ,
87
+ @IProductService private readonly _productService : IProductService ,
84
88
) {
85
89
this . container = viewDescriptorService . getViewContainerById ( VIEWLET_ID ) ! ;
86
90
this . registerViews ( ) ;
91
+
92
+ this . contextKeyService . createKey ( ExtensionsViewletViewsContribution . EXTENSION_RECOMMENDATION_KEY , ! ! this . _productService . extensionsGallery ?. recommendationsUrl ) ;
87
93
}
88
94
89
95
private registerViews ( ) : void {
@@ -226,16 +232,22 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
226
232
canToggleVisibility : false
227
233
} ) ;
228
234
235
+
229
236
/*
230
- * Default recommended extensions view
231
- * When user has installed extensions, this is shown along with the views for enabled & disabled extensions
232
- * When user has no installed extensions, this is shown along with the view for popular extensions
233
- */
237
+ * Default recommended extensions view
238
+ * When user has installed extensions, this is shown along with the views for enabled & disabled extensions
239
+ * When user has no installed extensions, this is shown along with the view for popular extensions
240
+ */
234
241
viewDescriptors . push ( {
235
242
id : 'extensions.recommendedList' ,
236
243
name : localize ( 'recommendedExtensions' , "Recommended" ) ,
237
244
ctorDescriptor : new SyncDescriptor ( DefaultRecommendedExtensionsView , [ { } ] ) ,
238
- when : ContextKeyExpr . and ( DefaultViewsContext , ContextKeyExpr . not ( 'config.extensions.showRecommendationsOnlyOnDemand' ) ) ,
245
+ when : ContextKeyExpr . and (
246
+ DefaultViewsContext ,
247
+ ContextKeyExpr . not ( 'config.extensions.showRecommendationsOnlyOnDemand' ) ,
248
+ /** @coder Open VSX doesn't yet support `recommendationsUrl`, so we hide the pane. */
249
+ ContextKeyExpr . has ( ExtensionsViewletViewsContribution . EXTENSION_RECOMMENDATION_KEY )
250
+ ) ,
239
251
weight : 40 ,
240
252
order : 3 ,
241
253
canToggleVisibility : true
@@ -479,7 +491,9 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
479
491
@IExtensionService extensionService : IExtensionService ,
480
492
@IViewDescriptorService viewDescriptorService : IViewDescriptorService ,
481
493
@IPreferencesService private readonly preferencesService : IPreferencesService ,
482
- @ICommandService private readonly commandService : ICommandService
494
+ @ICommandService private readonly commandService : ICommandService ,
495
+ @IProductService private readonly _productService : IProductService ,
496
+
483
497
) {
484
498
super ( VIEWLET_ID , { mergeViewWithContainerWhenSingleView : true } , instantiationService , configurationService , layoutService , contextMenuService , telemetryService , extensionService , themeService , storageService , contextService , viewDescriptorService ) ;
485
499
@@ -499,7 +513,7 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
499
513
this . recommendedExtensionsContextKey = RecommendedExtensionsContext . bindTo ( contextKeyService ) ;
500
514
this . _register ( this . paneCompositeService . onDidPaneCompositeOpen ( e => { if ( e . viewContainerLocation === ViewContainerLocation . Sidebar ) { this . onViewletOpen ( e . composite ) ; } } , this ) ) ;
501
515
this . searchViewletState = this . getMemento ( StorageScope . WORKSPACE , StorageTarget . USER ) ;
502
-
516
+
503
517
if ( extensionManagementServerService . webExtensionManagementServer ) {
504
518
this . _register ( extensionsWorkbenchService . onChange ( ( ) => {
505
519
// show installed web extensions view only when it is not visible
@@ -511,6 +525,17 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
511
525
}
512
526
}
513
527
528
+ /** @coder Added to clarify source of marketplace extensions. */
529
+ @memoize
530
+ get marketplaceHostname ( ) : string {
531
+ if ( this . _productService . extensionsGallery ?. serviceUrl ) {
532
+ return new URL ( this . _productService . extensionsGallery ?. serviceUrl ) . hostname ;
533
+ }
534
+
535
+ return 'Marketplace' ;
536
+ }
537
+
538
+
514
539
get searchValue ( ) : string | undefined {
515
540
return this . searchBox ?. getValue ( ) ;
516
541
}
@@ -525,7 +550,7 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
525
550
hide ( overlay ) ;
526
551
527
552
const header = append ( this . root , $ ( '.header' ) ) ;
528
- const placeholder = localize ( 'searchExtensions' , " Search Extensions in Marketplace" ) ;
553
+ const placeholder = localize ( 'searchExtensions' , ' Search Extensions on {0}' , this . marketplaceHostname ) ;
529
554
530
555
const searchValue = this . searchViewletState [ 'query.value' ] ? this . searchViewletState [ 'query.value' ] : '' ;
531
556
0 commit comments