Skip to content

Commit 1d632ec

Browse files
committed
Show recommendation reason always Fixes microsoft#37419
1 parent c4028a7 commit 1d632ec

3 files changed

Lines changed: 15 additions & 34 deletions

File tree

src/vs/workbench/parts/extensions/browser/extensionsList.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,15 @@ const actionOptions = { icon: true, label: true };
4848

4949
export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
5050

51-
private showRecommendedLabel: boolean;
5251
constructor(
53-
showRecommendedLabel: boolean,
5452
@IInstantiationService private instantiationService: IInstantiationService,
5553
@IContextMenuService private contextMenuService: IContextMenuService,
5654
@IMessageService private messageService: IMessageService,
5755
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService,
5856
@IExtensionService private extensionService: IExtensionService,
5957
@IExtensionTipsService private extensionTipsService: IExtensionTipsService,
6058
@IThemeService private themeService: IThemeService
61-
) {
62-
this.showRecommendedLabel = showRecommendedLabel;
63-
}
59+
) { }
6460

6561
get templateId() { return 'extension'; }
6662

@@ -167,12 +163,10 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
167163
removeClass(data.root, 'recommended');
168164

169165
const extRecommendations = this.extensionTipsService.getAllRecommendationsWithReason();
170-
if (extRecommendations[extension.id.toLowerCase()] && !isInstalled) {
166+
if (extRecommendations[extension.id.toLowerCase()]) {
171167
data.root.setAttribute('aria-label', extension.displayName + '. ' + extRecommendations[extension.id]);
172-
if (this.showRecommendedLabel) {
173-
addClass(data.root, 'recommended');
174-
data.root.title = extRecommendations[extension.id.toLowerCase()];
175-
}
168+
addClass(data.root, 'recommended');
169+
data.root.title = extRecommendations[extension.id.toLowerCase()];
176170
}
177171

178172
data.name.textContent = extension.displayName;

src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
4141
_serviceBrand: any;
4242

4343
private _fileBasedRecommendations: { [id: string]: number; } = Object.create(null);
44-
private _exeBasedRecommendations: string[] = [];
44+
private _exeBasedRecommendations: { [id: string]: string; } = Object.create(null);
4545
private _availableRecommendations: { [pattern: string]: string[] } = Object.create(null);
4646
private importantRecommendations: { [id: string]: { name: string; pattern: string; } } = Object.create(null);
4747
private importantRecommendationsIgnoreList: string[];
@@ -83,6 +83,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
8383
let output: { [id: string]: string; } = Object.create(null);
8484
Object.keys(this._fileBasedRecommendations).forEach(x => output[x.toLowerCase()] = localize('fileBasedRecommendation', "This extension is recommended based on the files you recently opened."));
8585
this._allWorkspaceRecommendedExtensions.forEach(x => output[x.toLowerCase()] = localize('workspaceRecommendation', "This extension is recommended by users of the current workspace."));
86+
forEach(this._exeBasedRecommendations, entry => output[entry.key.toLowerCase()] = localize('exeBasedRecommendation', "This extension is recommended because you have {0} installed.", entry.value));
8687
return output;
8788
}
8889

@@ -148,8 +149,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
148149
}
149150

150151
getOtherRecommendations(): string[] {
151-
152-
return distinct(this._exeBasedRecommendations);
152+
return Object.keys(this._exeBasedRecommendations);
153153
}
154154

155155

@@ -439,15 +439,20 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
439439
});
440440
}
441441

442-
private _suggestBasedOnExecutables(recommendations: string[]): void {
442+
private _suggestBasedOnExecutables(recommendations: { [id: string]: string; }): void {
443443
const homeDir = os.homedir();
444444
let foundExecutables: Set<string> = new Set<string>();
445445

446446
let findExecutable = (exeName, path) => {
447447
return pfs.fileExists(path).then(exists => {
448448
if (exists && !foundExecutables.has(exeName)) {
449449
foundExecutables.add(exeName);
450-
recommendations.push(...product.exeBasedExtensionTips[exeName]['recommendations']);
450+
(product.exeBasedExtensionTips[exeName]['recommendations'] || [])
451+
.forEach(x => {
452+
if (product.exeBasedExtensionTips[exeName]['friendlyName']) {
453+
recommendations[x] = product.exeBasedExtensionTips[exeName]['friendlyName'];
454+
}
455+
});
451456
}
452457
});
453458
};

src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,11 @@ export class ExtensionsListView extends ViewsViewletPanel {
8181
this.disposables.push(attachBadgeStyler(this.badge, this.themeService));
8282
}
8383

84-
showRecommendedLabel() {
85-
return true;
86-
}
87-
8884
renderBody(container: HTMLElement): void {
8985
this.extensionsList = append(container, $('.extensions-list'));
9086
this.messageBox = append(container, $('.message'));
9187
const delegate = new Delegate();
92-
const renderer = this.instantiationService.createInstance(Renderer, this.showRecommendedLabel());
88+
const renderer = this.instantiationService.createInstance(Renderer);
9389
this.list = new PagedList(this.extensionsList, delegate, [renderer], {
9490
ariaLabel: localize('extensions', "Extensions"),
9591
keyboardSupport: false
@@ -541,23 +537,13 @@ export class InstalledExtensionsView extends ExtensionsListView {
541537
searchInstalledQuery = query ? searchInstalledQuery + ' ' + query : searchInstalledQuery;
542538
return super.show(searchInstalledQuery);
543539
}
544-
545-
showRecommendedLabel() {
546-
return false;
547-
}
548-
549540
}
550541

551542
export class RecommendedExtensionsView extends ExtensionsListView {
552543

553544
async show(query: string): TPromise<IPagedModel<IExtension>> {
554545
return super.show(!query.trim() ? '@recommended:all' : '@recommended');
555546
}
556-
557-
showRecommendedLabel() {
558-
return false;
559-
}
560-
561547
}
562548

563549
export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
@@ -590,8 +576,4 @@ export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
590576
return model;
591577
}
592578

593-
showRecommendedLabel() {
594-
return false;
595-
}
596-
597579
}

0 commit comments

Comments
 (0)