Support filtering remoteExtensionTips by platform (#175246)

This commit is contained in:
Martin Aeschlimann 2023-02-23 16:32:44 +01:00 committed by GitHub
parent 7cfe4e043b
commit cc99387a09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 9 deletions

View file

@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.76.0",
"distro": "ef7b3fe403fb76194fc61bc83b4b53af19a8f704",
"distro": "30820417178d1e9f8ca7347ab291696ee134692f",
"author": {
"name": "Microsoft Corporation"
},

View file

@ -135,7 +135,9 @@ export const enum Platform {
Linux,
Windows
}
export function PlatformToString(platform: Platform) {
export type PlatformName = 'Web' | 'Windows' | 'Mac' | 'Linux';
export function PlatformToString(platform: Platform): PlatformName {
switch (platform) {
case Platform.Web: return 'Web';
case Platform.Mac: return 'Mac';

View file

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { IStringDictionary } from 'vs/base/common/collections';
import { PlatformName } from 'vs/base/common/platform';
export interface IBuiltInExtension {
readonly name: string;
@ -198,11 +199,13 @@ export interface IExeBasedExtensionTip {
export interface IRemoteExtensionTip {
friendlyName: string;
extensionId: string;
supportedPlatforms?: PlatformName[];
}
export interface IVirtualWorkspaceExtensionTip {
friendlyName: string;
extensionId: string;
supportedPlatforms?: PlatformName[];
}
export interface ISurveyData {

View file

@ -6,6 +6,7 @@
import { ExtensionRecommendations, ExtensionRecommendation } from 'vs/workbench/contrib/extensions/browser/extensionRecommendations';
import { IProductService } from 'vs/platform/product/common/productService';
import { ExtensionRecommendationReason } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
import { PlatformToString, platform } from 'vs/base/common/platform';
export class RemoteRecommendations extends ExtensionRecommendations {
@ -20,7 +21,8 @@ export class RemoteRecommendations extends ExtensionRecommendations {
protected async doActivate(): Promise<void> {
const extensionTips = { ...this.productService.remoteExtensionTips, ...this.productService.virtualWorkspaceExtensionTips };
this._recommendations = Object.entries(extensionTips).map(([_, extension]) => ({
const currentPlatform = PlatformToString(platform);
this._recommendations = Object.values(extensionTips).filter(({ supportedPlatforms }) => !supportedPlatforms || supportedPlatforms.includes(currentPlatform)).map(extension => ({
extensionId: extension.extensionId.toLowerCase(),
reason: {
reasonId: ExtensionRecommendationReason.Application,

View file

@ -21,7 +21,7 @@ import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/envir
import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { isWeb } from 'vs/base/common/platform';
import { PlatformToString, isWeb, platform } from 'vs/base/common/platform';
import { once } from 'vs/base/common/functional';
import { truncate } from 'vs/base/common/strings';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
@ -513,11 +513,14 @@ export class RemoteStatusIndicator extends Disposable implements IWorkbenchContr
private hasAdditionalRemoteExtensions() {
const extensionTips = { ...this.productService.remoteExtensionTips, ...this.productService.virtualWorkspaceExtensionTips };
for (const [_, extension] of Object.entries(extensionTips)) {
const { extensionId: recommendedExtensionId } = extension;
// if this recommended extension isn't already installed, return early
if (!this.extensionService.extensions.some((extension) => extension.id?.toLowerCase() === recommendedExtensionId.toLowerCase())) {
return true;
const currentPlatform = PlatformToString(platform);
for (const extension of Object.values(extensionTips)) {
const { extensionId: recommendedExtensionId, supportedPlatforms } = extension;
if (!supportedPlatforms || supportedPlatforms.includes(currentPlatform)) {
// if this recommended extension isn't already installed, return early
if (!this.extensionService.extensions.some((extension) => extension.id?.toLowerCase() === recommendedExtensionId.toLowerCase())) {
return true;
}
}
}
return false;