提交 5078bd35 编写于 作者: S Sandeep Somavarapu

Fix #103954

上级 144a8ede
......@@ -88,7 +88,7 @@ export class ConfigBasedRecommendations extends ExtensionRecommendations {
const tip = this.importantTips.filter(tip => tip.extensionId === extension)[0];
const message = tip.isExtensionPack ? localize('extensionPackRecommended', "The '{0}' extension pack is recommended for this workspace.", tip.extensionName)
: localize('extensionRecommended', "The '{0}' extension is recommended for this workspace.", tip.extensionName);
this.promptImportantExtensionInstallNotification(extension, message);
this.promptImportantExtensionsInstallNotification([extension], message);
}
}
......
......@@ -90,15 +90,39 @@ export class ExeBasedRecommendations extends ExtensionRecommendations {
return;
}
const recommendationsByExe = new Map<string, IExecutableBasedExtensionTip[]>();
for (const extensionId of recommendations) {
if (this.tasExperimentService && extensionId === 'ms-vscode-remote.remote-wsl') {
const tip = importantExeBasedRecommendations[extensionId];
let tips = recommendationsByExe.get(tip.exeFriendlyName);
if (!tips) {
tips = [];
recommendationsByExe.set(tip.exeFriendlyName, tips);
}
tips.push(tip);
}
for (const [, tips] of recommendationsByExe) {
const extensionIds = tips.map(({ extensionId }) => extensionId.toLowerCase());
if (this.tasExperimentService && extensionIds.indexOf('ms-vscode-remote.remote-wsl') !== -1) {
await this.tasExperimentService.getTreatment<boolean>('wslpopupaa');
}
const tip = importantExeBasedRecommendations[extensionId];
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);
if (tips.length === 1) {
const tip = tips[0];
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.promptImportantExtensionsInstallNotification(extensionIds, message);
}
else if (tips.length === 2) {
const message = localize('two extensions recommended', "The '{0}' and '{1}' extensions are recommended as you have {2} installed on your system.", tips[0].extensionName, tips[1].extensionName, tips[0].exeFriendlyName || basename(tips[0].windowsPath!));
this.promptImportantExtensionsInstallNotification(extensionIds, message);
}
else if (tips.length > 2) {
const message = localize('more than two extensions recommended', "The '{0}', '{1}' and other extensions are recommended as you have {2} installed on your system.", tips[0].extensionName, tips[1].extensionName, tips[0].exeFriendlyName || basename(tips[0].windowsPath!));
this.promptImportantExtensionsInstallNotification(extensionIds, message);
}
}
}
......
......@@ -8,7 +8,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { localize } from 'vs/nls';
import { InstallRecommendedExtensionAction, ShowRecommendedExtensionAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { InstallRecommendedExtensionAction, ShowRecommendedExtensionAction, ShowRecommendedExtensionsAction, InstallRecommendedExtensionsAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { ExtensionRecommendationSource, IExtensionRecommendationReson } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { IExtensionsConfiguration, ConfigurationKey } from 'vs/workbench/contrib/extensions/common/extensions';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
......@@ -65,26 +65,40 @@ export abstract class ExtensionRecommendations extends Disposable {
}
}
protected promptImportantExtensionInstallNotification(extensionId: string, message: string): void {
protected promptImportantExtensionsInstallNotification(extensionIds: string[], message: string): void {
this.notificationService.prompt(Severity.Info, message,
[{
label: localize('install', 'Install'),
run: () => {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'install', extensionId });
this.runAction(this.instantiationService.createInstance(InstallRecommendedExtensionAction, extensionId));
label: extensionIds.length === 1 ? localize('install', 'Install') : localize('installAll', "Install All"),
run: async () => {
for (const extensionId of extensionIds) {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'install', extensionId });
}
if (extensionIds.length === 1) {
this.runAction(this.instantiationService.createInstance(InstallRecommendedExtensionAction, extensionIds[0]));
} else {
this.runAction(this.instantiationService.createInstance(InstallRecommendedExtensionsAction, InstallRecommendedExtensionsAction.ID, InstallRecommendedExtensionsAction.LABEL, extensionIds, 'install-recommendations'));
}
}
}, {
label: localize('moreInformation', "More Information"),
label: extensionIds.length === 1 ? localize('moreInformation', "More Information") : localize('showRecommendations', "Show Recommendations"),
run: () => {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'show', extensionId });
this.runAction(this.instantiationService.createInstance(ShowRecommendedExtensionAction, extensionId));
for (const extensionId of extensionIds) {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'show', extensionId });
}
if (extensionIds.length === 1) {
this.runAction(this.instantiationService.createInstance(ShowRecommendedExtensionAction, extensionIds[0]));
} else {
this.runAction(this.instantiationService.createInstance(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL));
}
}
}, {
label: choiceNever,
isSecondary: true,
run: () => {
this.addToImportantRecommendationsIgnore(extensionId);
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'neverShowAgain', extensionId });
for (const extensionId of extensionIds) {
this.addToImportantRecommendationsIgnore(extensionId);
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'neverShowAgain', extensionId });
}
this.notificationService.prompt(
Severity.Info,
localize('ignoreExtensionRecommendations', "Do you want to ignore all extension recommendations?"),
......@@ -101,7 +115,9 @@ export abstract class ExtensionRecommendations extends Disposable {
{
sticky: true,
onCancel: () => {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'cancelled', extensionId });
for (const extensionId of extensionIds) {
this.telemetryService.publicLog2<{ userReaction: string, extensionId: string }, ExtensionRecommendationsNotificationClassification>('extensionRecommendations:popup', { userReaction: 'cancelled', extensionId });
}
}
}
);
......
......@@ -1829,19 +1829,20 @@ export class ShowRecommendedExtensionsAction extends Action {
}
}
export class InstallWorkspaceRecommendedExtensionsAction extends Action {
export class InstallRecommendedExtensionsAction extends Action {
static readonly ID = 'workbench.extensions.action.installWorkspaceRecommendedExtensions';
static readonly LABEL = localize('installWorkspaceRecommendedExtensions', "Install All Workspace Recommended Extensions");
static readonly ID = 'workbench.extensions.action.installRecommendedExtensions';
static readonly LABEL = localize('installRecommendedExtensions', "Install Recommended Extensions");
private _recommendations: string[] = [];
get recommendations(): string[] { return this._recommendations; }
set recommendations(recommendations: string[]) { this._recommendations = recommendations; this.enabled = this._recommendations.length > 0; }
constructor(
id: string = InstallWorkspaceRecommendedExtensionsAction.ID,
label: string = InstallWorkspaceRecommendedExtensionsAction.LABEL,
id: string,
label: string,
recommendations: string[],
private readonly source: string,
@IViewletService private readonly viewletService: IViewletService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IExtensionsWorkbenchService private readonly extensionWorkbenchService: IExtensionsWorkbenchService,
......@@ -1860,7 +1861,7 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action {
viewlet.search('@recommended ');
viewlet.focus();
const names = this.recommendations;
return this.extensionWorkbenchService.queryGallery({ names, source: 'install-all-workspace-recommendations' }, CancellationToken.None).then(pager => {
return this.extensionWorkbenchService.queryGallery({ names, source: this.source }, CancellationToken.None).then(pager => {
let installPromises: Promise<any>[] = [];
let model = new PagedModel(pager);
for (let i = 0; i < pager.total; i++) {
......@@ -1892,6 +1893,22 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action {
}
}
export class InstallWorkspaceRecommendedExtensionsAction extends InstallRecommendedExtensionsAction {
constructor(
recommendations: string[],
@IViewletService viewletService: IViewletService,
@IInstantiationService instantiationService: IInstantiationService,
@IExtensionsWorkbenchService extensionWorkbenchService: IExtensionsWorkbenchService,
@IConfigurationService configurationService: IConfigurationService,
@IExtensionManagementServerService extensionManagementServerService: IExtensionManagementServerService,
@IProductService productService: IProductService,
) {
super('workbench.extensions.action.installWorkspaceRecommendedExtensions', localize('installWorkspaceRecommendedExtensions', "Install Workspace Recommended Extensions"), recommendations, 'install-all-workspace-recommendations',
viewletService, instantiationService, extensionWorkbenchService, configurationService, extensionManagementServerService, productService);
}
}
export class ShowRecommendedExtensionAction extends Action {
static readonly ID = 'workbench.extensions.action.showRecommendedExtension';
......
......@@ -1030,7 +1030,7 @@ export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
getActions(): IAction[] {
if (!this.installAllAction) {
this.installAllAction = this._register(this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, InstallWorkspaceRecommendedExtensionsAction.ID, InstallWorkspaceRecommendedExtensionsAction.LABEL, []));
this.installAllAction = this._register(this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, []));
this.installAllAction.class = 'codicon codicon-cloud-download';
}
......
......@@ -226,7 +226,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
message = localize('reallyRecommendedExtensionPack', "The '{0}' extension pack is recommended for this file type.", extensionName);
}
this.promptImportantExtensionInstallNotification(extensionId, message);
this.promptImportantExtensionsInstallNotification([extensionId], message);
return true;
}
......
......@@ -18,7 +18,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { CancellationToken } from 'vs/base/common/cancellation';
import { localize } from 'vs/nls';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { InstallWorkspaceRecommendedExtensionsAction, ShowRecommendedExtensionsAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { ShowRecommendedExtensionsAction, InstallWorkspaceRecommendedExtensionsAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
......@@ -120,7 +120,7 @@ export class WorkspaceRecommendations extends ExtensionRecommendations {
label: localize('installAll', "Install All"),
run: () => {
this.telemetryService.publicLog2<{ userReaction: string }, ExtensionWorkspaceRecommendationsNotificationClassification>('extensionWorkspaceRecommendations:popup', { userReaction: 'install' });
const installAllAction = this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, InstallWorkspaceRecommendedExtensionsAction.ID, localize('installAll', "Install All"), recommendations.map(({ extensionId }) => extensionId));
const installAllAction = this.instantiationService.createInstance(InstallWorkspaceRecommendedExtensionsAction, recommendations.map(({ extensionId }) => extensionId));
installAllAction.run();
installAllAction.dispose();
c(undefined);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册