Skip to content

Commit

Permalink
support extension packs in exe recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jul 8, 2020
1 parent 855f75e commit 79d85e4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ export type IConfigBasedExtensionTip = {

export type IExecutableBasedExtensionTip = {
readonly extensionId: string,
readonly friendlyName: string,
readonly extensionName: string,
readonly isExtensionPack: boolean,
readonly exeFriendlyName: string,
readonly windowsPath?: string,
};
Expand Down
15 changes: 8 additions & 7 deletions src/vs/platform/extensionManagement/node/extensionTipsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ExtensionTipsService as BaseExtensionTipsService } from 'vs/platform/ex
type IExeBasedExtensionTips = {
readonly exeFriendlyName: string,
readonly windowsPath?: string,
readonly recommendations: { extensionId: string, extensionName: string }[];
readonly recommendations: { extensionId: string, extensionName: string, isExtensionPack: boolean }[];
};

export class ExtensionTipsService extends BaseExtensionTipsService {
Expand All @@ -41,13 +41,13 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
super(fileService, productService, requestService, logService);
if (productService.exeBasedExtensionTips) {
forEach(productService.exeBasedExtensionTips, ({ key, value }) => {
const importantRecommendations: { extensionId: string, extensionName: string }[] = [];
const otherRecommendations: { extensionId: string, extensionName: string }[] = [];
const importantRecommendations: { extensionId: string, extensionName: string, isExtensionPack: boolean }[] = [];
const otherRecommendations: { extensionId: string, extensionName: string, isExtensionPack: boolean }[] = [];
forEach(value.recommendations, ({ key: extensionId, value }) => {
if (value.important) {
importantRecommendations.push({ extensionId, extensionName: value.name });
importantRecommendations.push({ extensionId, extensionName: value.name, isExtensionPack: !!value.isExtensionPack });
} else {
otherRecommendations.push({ extensionId, extensionName: value.name });
otherRecommendations.push({ extensionId, extensionName: value.name, isExtensionPack: !!value.isExtensionPack });
}
});
if (importantRecommendations.length) {
Expand Down Expand Up @@ -99,10 +99,11 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
checkedExecutables.set(exePath, exists);
}
if (exists) {
for (const { extensionId, extensionName: friendlyName } of extensionTip.recommendations) {
for (const { extensionId, extensionName, isExtensionPack } of extensionTip.recommendations) {
result.push({
extensionId,
friendlyName,
extensionName,
isExtensionPack,
exeFriendlyName: extensionTip.exeFriendlyName,
windowsPath: extensionTip.windowsPath,
});
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/product/common/productService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export interface IConfigBasedExtensionTip {
export interface IExeBasedExtensionTip {
friendlyName: string;
windowsPath?: string;
recommendations: IStringDictionary<{ name: string, important?: boolean }>;
recommendations: IStringDictionary<{ name: string, important?: boolean, isExtensionPack?: boolean }>;
}

export interface IRemoteExtensionTip {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export class ExeBasedRecommendations extends ExtensionRecommendations {

for (const extensionId of recommendations) {
const tip = importantExeBasedRecommendations[extensionId];
const message = localize('exeRecommended', "The '{0}' extension is recommended as you have {1} installed on your system.", tip.friendlyName!, tip.exeFriendlyName || basename(tip.windowsPath!));
const message = tip.isExtensionPack ? localize('extensionPackRecommended', "The '{0}' extension pack is recommended as you have {1} installed on your system.", tip.extensionName!, tip.exeFriendlyName || basename(tip.windowsPath!))
: localize('exeRecommended', "The '{0}' extension is recommended as you have {1} installed on your system.", tip.extensionName!, tip.exeFriendlyName || basename(tip.windowsPath!));
this.promptImportantExtensionInstallNotification(extensionId, message);
}
}
Expand All @@ -111,7 +112,7 @@ export class ExeBasedRecommendations extends ExtensionRecommendations {
source: 'executable',
reason: {
reasonId: ExtensionRecommendationReason.Executable,
reasonText: localize('exeBasedRecommendation', "This extension is recommended because you have {0} installed.", tip.friendlyName)
reasonText: localize('exeBasedRecommendation', "This extension is recommended because you have {0} installed.", tip.extensionName)
}
};
}
Expand Down

0 comments on commit 79d85e4

Please sign in to comment.