@@ -18,10 +18,11 @@ import { domEvent } from 'vs/base/browser/event';
18
18
import { IExtension , IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions' ;
19
19
import { InstallAction , UpdateAction , BuiltinStatusLabelAction , ManageExtensionAction , ReloadAction } from 'vs/workbench/parts/extensions/browser/extensionsActions' ;
20
20
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
21
- import { Label , RatingsWidget , InstallWidget } from 'vs/workbench/parts/extensions/browser/extensionsWidgets' ;
21
+ import { RatingsWidget , InstallWidget } from 'vs/workbench/parts/extensions/browser/extensionsWidgets' ;
22
22
import { EventType } from 'vs/base/common/events' ;
23
23
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
24
24
import { IExtensionService } from 'vs/platform/extensions/common/extensions' ;
25
+ import { IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement' ;
25
26
26
27
export interface ITemplateData {
27
28
root : HTMLElement ;
@@ -32,6 +33,7 @@ export interface ITemplateData {
32
33
ratings : HTMLElement ;
33
34
author : HTMLElement ;
34
35
description : HTMLElement ;
36
+ subText : HTMLElement ;
35
37
extension : IExtension ;
36
38
disposables : IDisposable [ ] ;
37
39
extensionDisposables : IDisposable [ ] ;
@@ -46,13 +48,18 @@ const actionOptions = { icon: true, label: true };
46
48
47
49
export class Renderer implements IPagedRenderer < IExtension , ITemplateData > {
48
50
51
+ private showRecommendedLabel : boolean ;
49
52
constructor (
53
+ showRecommendedLabel : boolean ,
50
54
@IInstantiationService private instantiationService : IInstantiationService ,
51
55
@IContextMenuService private contextMenuService : IContextMenuService ,
52
56
@IMessageService private messageService : IMessageService ,
53
57
@IExtensionsWorkbenchService private extensionsWorkbenchService : IExtensionsWorkbenchService ,
54
- @IExtensionService private extensionService : IExtensionService
55
- ) { }
58
+ @IExtensionService private extensionService : IExtensionService ,
59
+ @IExtensionTipsService private extensionTipsService : IExtensionTipsService
60
+ ) {
61
+ this . showRecommendedLabel = showRecommendedLabel ;
62
+ }
56
63
57
64
get templateId ( ) { return 'extension' ; }
58
65
@@ -63,7 +70,7 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
63
70
const headerContainer = append ( details , $ ( '.header-container' ) ) ;
64
71
const header = append ( headerContainer , $ ( '.header' ) ) ;
65
72
const name = append ( header , $ ( 'span.name' ) ) ;
66
- const version = append ( header , $ ( 'span.version' ) ) ;
73
+ const subText = append ( header , $ ( 'span.version' ) ) ;
67
74
const installCount = append ( header , $ ( 'span.install-count' ) ) ;
68
75
const ratings = append ( header , $ ( 'span.ratings' ) ) ;
69
76
const description = append ( details , $ ( '.description.ellipsis' ) ) ;
@@ -80,7 +87,6 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
80
87
} ) ;
81
88
actionbar . addListener ( EventType . RUN , ( { error } ) => error && this . messageService . show ( Severity . Error , error ) ) ;
82
89
83
- const versionWidget = this . instantiationService . createInstance ( Label , version , ( e : IExtension ) => e . version ) ;
84
90
const installCountWidget = this . instantiationService . createInstance ( InstallWidget , installCount , { small : true } ) ;
85
91
const ratingsWidget = this . instantiationService . createInstance ( RatingsWidget , ratings , { small : true } ) ;
86
92
@@ -91,13 +97,12 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
91
97
const manageAction = this . instantiationService . createInstance ( ManageExtensionAction ) ;
92
98
93
99
actionbar . push ( [ reloadAction , updateAction , installAction , builtinStatusAction , manageAction ] , actionOptions ) ;
94
- const disposables = [ versionWidget , installCountWidget , ratingsWidget , builtinStatusAction , updateAction , reloadAction , manageAction , actionbar ] ;
100
+ const disposables = [ installCountWidget , ratingsWidget , builtinStatusAction , updateAction , reloadAction , manageAction , actionbar ] ;
95
101
96
102
return {
97
- root, element, icon, name, installCount, ratings, author, description, disposables,
103
+ root, element, icon, name, installCount, ratings, author, description, subText , disposables,
98
104
extensionDisposables : [ ] ,
99
105
set extension ( extension : IExtension ) {
100
- versionWidget . extension = extension ;
101
106
installCountWidget . extension = extension ;
102
107
ratingsWidget . extension = extension ;
103
108
builtinStatusAction . extension = extension ;
@@ -127,10 +132,11 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
127
132
removeClass ( data . element , 'loading' ) ;
128
133
129
134
data . extensionDisposables = dispose ( data . extensionDisposables ) ;
135
+ const isInstalled = this . extensionsWorkbenchService . local . some ( e => e . id === extension . id ) ;
130
136
131
137
this . extensionService . getExtensions ( ) . then ( enabledExtensions => {
132
138
const isExtensionRunning = enabledExtensions . some ( e => areSameExtensions ( e , extension ) ) ;
133
- const isInstalled = this . extensionsWorkbenchService . local . some ( e => e . id === extension . id ) ;
139
+
134
140
toggleClass ( data . element , 'disabled' , isInstalled && ! isExtensionRunning ) ;
135
141
} ) ;
136
142
@@ -145,7 +151,17 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
145
151
data . icon . style . visibility = 'inherit' ;
146
152
}
147
153
154
+ data . subText . textContent = isInstalled ? extension . version : '' ;
148
155
data . root . setAttribute ( 'aria-label' , extension . displayName ) ;
156
+
157
+ const extRecommendations = this . extensionTipsService . getAllRecommendationsWithReason ( ) ;
158
+ if ( extRecommendations [ extension . id . toLowerCase ( ) ] && ! isInstalled ) {
159
+ data . root . setAttribute ( 'aria-label' , extension . displayName + '. ' + extRecommendations [ extension . id ] ) ;
160
+ if ( this . showRecommendedLabel ) {
161
+ data . subText . textContent = 'Recommended' ;
162
+ }
163
+ }
164
+
149
165
data . name . textContent = extension . displayName ;
150
166
data . author . textContent = extension . publisherDisplayName ;
151
167
data . description . textContent = extension . description ;
0 commit comments