From 58c2fb5f52552428d3169ae0c4d3aa7e8a5f815a Mon Sep 17 00:00:00 2001 From: chriswang521 Date: Thu, 16 May 2024 13:34:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=AE=BE=E7=BD=AE=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8F=92=E4=BB=B6=E5=95=86=E5=BA=97=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9,=E5=90=AB=E6=9C=89serviceU?= =?UTF-8?q?rl=E5=92=8CitemUrl=E9=85=8D=E7=BD=AE,=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9C=89:=201.=E6=97=A0=E9=9C=80=E9=87=8D=E5=90=AF,=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=BF=AE=E6=94=B9;=202.=E6=B7=BB=E5=8A=A0=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E6=98=BE=E7=A4=BA.=203.code-server=E4=B8=AD=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E4=BD=BF=E7=94=A8.=204.=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=AD=A3=E5=B8=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../translations/main.i18n.json | 9 ++ src/vs/code/node/cliProcessMain.ts | 3 + .../node/sharedProcess/sharedProcessMain.ts | 7 ++ .../common/extensionGalleryService.ts | 28 +++++- .../extensionsGallery.config.contribution.ts | 43 +++++++++ .../common/extensionsGalleryConfig.ts | 87 +++++++++++++++++++ .../common/extensionsGalleryConfigService.ts | 15 ++++ src/vs/server/node/serverServices.ts | 3 + .../extensions/browser/extensionsActions.ts | 13 ++- .../browser/extensionsWorkbenchService.ts | 12 ++- .../preferences/browser/settingsLayout.ts | 5 ++ .../update/browser/update.contribution.ts | 1 + src/vs/workbench/workbench.common.main.ts | 3 + 13 files changed, 223 insertions(+), 6 deletions(-) create mode 100644 src/vs/platform/extensionsGallery/common/extensionsGallery.config.contribution.ts create mode 100644 src/vs/platform/extensionsGallery/common/extensionsGalleryConfig.ts create mode 100644 src/vs/platform/extensionsGallery/common/extensionsGalleryConfigService.ts diff --git a/extensions/vscode-language-pack-zh-hans/translations/main.i18n.json b/extensions/vscode-language-pack-zh-hans/translations/main.i18n.json index 1ba32b04..71a76f4c 100644 --- a/extensions/vscode-language-pack-zh-hans/translations/main.i18n.json +++ b/extensions/vscode-language-pack-zh-hans/translations/main.i18n.json @@ -1975,6 +1975,14 @@ "versionSpecificity2": "\"engines.vscode\" ({0}) 中指定的版本不够具体。对于 1.0.0 之后的 vscode 版本,请至少定义主要想要的版本。例如: ^1.10.0、1.10.x、1.x.x、2.x.x 等。", "versionSyntax": "无法解析 \"engines.vscode\" 的值 {0}。请改为如 ^1.22.0, ^1.22.x 等。" }, + "vs/platform/extensionsGallery/common/extensionsGallery.config.contribution":{ + "extensionsGalleryConfigurationTitle":"插件商店地址", + "extensionsGalleryServiceUrl":"配置插件商店的服务器地址serviceUrl。例如:https://open-vsx.org/vscode/gallery", + "extensionsGalleryItemUrl":"配置插件商店的单个插件地址itemUrl。例如:https://open-vsx.org/vscode/item" + }, + "vs/platform/extensionsGallery/common/extensionsGalleryConfig":{ + "galleryConfigChanged":"插件商店配置地址已更改。" + }, "vs/platform/externalTerminal/node/externalTerminalService": { "console.title": "Kylin-Code 控制台", "ext.term.app.not.found": "找不到终端应用程序 \"{0}\"", @@ -9135,6 +9143,7 @@ "editorManagement": "编辑管理", "experimental": "实验性", "extensions": "插件", + "extensionsGallery":"插件商店地址", "features": "功能", "fileExplorer": "资源管理器", "files": "文件", diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index b2861976..fce9c3fc 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -29,6 +29,8 @@ import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagemen import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService'; import { ExtensionManagementService, INativeServerExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService'; import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService'; +import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; import { IFileService } from 'vs/platform/files/common/files'; import { FileService } from 'vs/platform/files/common/fileService'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; @@ -200,6 +202,7 @@ class CliMain extends Disposable { services.set(IDownloadService, new SyncDescriptor(DownloadService, undefined, true)); // Extensions + services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService, undefined, true)); services.set(IExtensionsProfileScannerService, new SyncDescriptor(ExtensionsProfileScannerService, undefined, true)); services.set(IExtensionsScannerService, new SyncDescriptor(ExtensionsScannerService, undefined, true)); services.set(IExtensionSignatureVerificationService, new SyncDescriptor(ExtensionSignatureVerificationService, undefined, true)); diff --git a/src/vs/code/node/sharedProcess/sharedProcessMain.ts b/src/vs/code/node/sharedProcess/sharedProcessMain.ts index 3c5650cb..153cafc0 100644 --- a/src/vs/code/node/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/node/sharedProcess/sharedProcessMain.ts @@ -116,6 +116,10 @@ import { RemoteConnectionType } from 'vs/platform/remote/common/remoteAuthorityR import { nodeSocketFactory } from 'vs/platform/remote/node/nodeSocketFactory'; import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { SharedProcessRawConnection, SharedProcessLifecycle } from 'vs/platform/sharedProcess/common/sharedProcess'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; +import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig'; +// import { NotificationService } from 'vs/workbench/services/notification/common/notificationService'; +// import { INotificationService } from 'vs/platform/notification/common/notification'; class SharedProcessMain extends Disposable implements IClientConnectionFilter { @@ -324,6 +328,9 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter { services.set(IExtensionSignatureVerificationService, new SyncDescriptor(ExtensionSignatureVerificationService, undefined, true)); services.set(INativeServerExtensionManagementService, new SyncDescriptor(ExtensionManagementService, undefined, true)); + // services.set(INotificationService, new SyncDescriptor(NotificationService, undefined, true)); + services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService, undefined, true)); + // Extension Gallery services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService, undefined, true)); diff --git a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts index a468c400..3e4fc6c3 100644 --- a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts @@ -27,6 +27,7 @@ import { resolveMarketplaceHeaders } from 'vs/platform/externalServices/common/m import { IStorageService } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { StopWatch } from 'vs/base/common/stopwatch'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; const CURRENT_TARGET_PLATFORM = isWeb ? TargetPlatform.WEB : getTargetPlatform(platform, arch); const ACTIVITY_HEADER_NAME = 'X-Market-Search-Activity-Id'; @@ -577,7 +578,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi declare readonly _serviceBrand: undefined; - private readonly extensionsGalleryUrl: string | undefined; + private extensionsGalleryUrl: string | undefined; private readonly extensionsGallerySearchUrl: string | undefined; private readonly extensionsControlUrl: string | undefined; @@ -592,10 +593,17 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi @IFileService private readonly fileService: IFileService, @IProductService private readonly productService: IProductService, @IConfigurationService private readonly configurationService: IConfigurationService, + @IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService, + ) { const config = productService.extensionsGallery; const isPPEEnabled = config?.servicePPEUrl && configurationService.getValue('_extensionsGallery.enablePPE'); - this.extensionsGalleryUrl = isPPEEnabled ? config.servicePPEUrl : config?.serviceUrl; + if (extensionsGalleryConfigService && extensionsGalleryConfigService.serviceUrl) { + this.extensionsGalleryUrl = extensionsGalleryConfigService.serviceUrl; + } else { + this.extensionsGalleryUrl = isPPEEnabled ? config.servicePPEUrl : config?.serviceUrl; + } + this.extensionsGalleryConfigService!.onConfigChange!(this.onUpdateConfigChange, this); this.extensionsGallerySearchUrl = isPPEEnabled ? undefined : config?.searchUrl; this.extensionsControlUrl = config?.controlUrl; this.commonHeadersPromise = resolveMarketplaceHeaders( @@ -608,6 +616,16 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi this.telemetryService); } + private onUpdateConfigChange(serverURL: string) { + this.logService.info('wpl onUpdateConfigChange serverURL:' + serverURL); + if (serverURL) { + this.extensionsGalleryUrl = serverURL; + } else { + const config = this.productService.extensionsGallery; + this.extensionsGalleryUrl = config && config.serviceUrl; + } + } + private api(path = ''): string { return `${this.extensionsGalleryUrl}${path}`; } @@ -1263,8 +1281,9 @@ export class ExtensionGalleryService extends AbstractExtensionGalleryService { @IFileService fileService: IFileService, @IProductService productService: IProductService, @IConfigurationService configurationService: IConfigurationService, + @IExtensionsGalleryConfigService extensionsGalleryConfigService: IExtensionsGalleryConfigService, ) { - super(storageService, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService); + super(storageService, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService, extensionsGalleryConfigService); } } @@ -1278,7 +1297,8 @@ export class ExtensionGalleryServiceWithNoStorageService extends AbstractExtensi @IFileService fileService: IFileService, @IProductService productService: IProductService, @IConfigurationService configurationService: IConfigurationService, + @IExtensionsGalleryConfigService extensionsGalleryConfigService: IExtensionsGalleryConfigService, ) { - super(undefined, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService); + super(undefined, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService, extensionsGalleryConfigService); } } diff --git a/src/vs/platform/extensionsGallery/common/extensionsGallery.config.contribution.ts b/src/vs/platform/extensionsGallery/common/extensionsGallery.config.contribution.ts new file mode 100644 index 00000000..a13d92c9 --- /dev/null +++ b/src/vs/platform/extensionsGallery/common/extensionsGallery.config.contribution.ts @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) kylinIDETeam. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { localize } from 'vs/nls'; +import { ConfigurationScope, Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; +import { Registry } from 'vs/platform/registry/common/platform'; + +const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); +configurationRegistry.registerConfiguration({ + id: 'extensionsGallery', + order: 199, + title: localize('extensionsGalleryConfigurationTitle', "extensionsGallery"), + type: 'object', + properties: { + 'extensionsGallery.serviceUrl': { + type: 'string', + pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$', + default: '', + scope: ConfigurationScope.APPLICATION, + description: localize('extensionsGalleryServiceUrl', "Configure Extensions Gallery ServiceUrl.Sample:https://open-vsx.org/vscode/gallery"), + restricted: true + }, + 'extensionsGallery.itemUrl': { + type: 'string', + pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$', + default: '', + scope: ConfigurationScope.APPLICATION, + description: localize('extensionsGalleryItemUrl', "Configure Extensions Gallery ItemUrl.Sample:https://open-vsx.org/vscode/item"), + restricted: true, + + } + }, +}); + +export interface IExtensionsGalleryConfiguration { + // extensionsGallery?: { + serviceUrl: string; + itemUrl: string; + // } + +} diff --git a/src/vs/platform/extensionsGallery/common/extensionsGalleryConfig.ts b/src/vs/platform/extensionsGallery/common/extensionsGalleryConfig.ts new file mode 100644 index 00000000..dab506dd --- /dev/null +++ b/src/vs/platform/extensionsGallery/common/extensionsGalleryConfig.ts @@ -0,0 +1,87 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) kylinIDETeam. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// import { Action } from 'vs/base/common/actions'; +// import { isWeb } from 'vs/base/common/platform'; +import { localize } from 'vs/nls'; +import { Emitter, Event } from 'vs/base/common/event'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { IExtensionsGalleryConfiguration } from 'vs/platform/extensionsGallery/common/extensionsGallery.config.contribution'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; +import { INotificationService } from 'vs/platform/notification/common/notification'; +// import { IHostService } from 'vs/workbench/services/host/browser/host'; + +export class ExtensionsGalleryConfigService implements IExtensionsGalleryConfigService { + declare readonly _serviceBrand: undefined; + private _serviceUrl: string = ''; + private _itemUrl: string = ''; + public extensionsGalleryConfiguration!: IExtensionsGalleryConfiguration; + private preExtensionsGalleryConfig: IExtensionsGalleryConfiguration; + + private readonly _onConfigChange = new Emitter(); + readonly onConfigChange: Event = this._onConfigChange.event; + + constructor( + @IConfigurationService private readonly configurationService: IConfigurationService, + @INotificationService private readonly notificationService: INotificationService, + // @IHostService private readonly hostService: IHostService, + ) { + this.preExtensionsGalleryConfig = this.configurationService.getValue('extensionsGallery'); + + this.updateURL(this.preExtensionsGalleryConfig); + this.configurationService.onDidChangeConfiguration(() => this.configure(this.configurationService.getValue('extensionsGallery')), this); + } + + get serviceUrl(): string { + return this._serviceUrl; + } + get itemUrl(): string { + return this._itemUrl; + } + private updateURL(extensionsGalleryConfig: IExtensionsGalleryConfiguration) { + if (extensionsGalleryConfig) { + this._serviceUrl = extensionsGalleryConfig.serviceUrl; + this._itemUrl = extensionsGalleryConfig.itemUrl; + } + } + + private configure(extensionsGalleryConfig: IExtensionsGalleryConfiguration) { + //不能直接使用==判断,可以将内容转为json的比较,必须序列一致 + if (JSON.stringify(this.preExtensionsGalleryConfig) === JSON.stringify(extensionsGalleryConfig)) { + //前一次和本次修改一致,不做任何操作 + } else { + this.preExtensionsGalleryConfig = extensionsGalleryConfig; + this.updateURL(extensionsGalleryConfig); + // if (extensionsGalleryConfig.serviceUrl) { + // this._serviceUrl = extensionsGalleryConfig!.serviceUrl!; + // this._itemUrl = extensionsGalleryConfig.itemUrl; + this._onConfigChange.fire(this._serviceUrl ? this._serviceUrl : ''); + + this.notificationService.info(localize('galleryConfigChanged', "Extensions Gallery Config Changed")); + + // this.notificationService.prompt( + // Severity.Info, + // "changed testing", + // [ + // { + // label: isWeb ? localize('reload', "Reload") : localize('restart', "Restart"), + // run: () => this.hostService.restart() + // } + // ] + // ); + + // this.notificationService.notify({ + // severity: Severity.Info, + // message: "satest", + // actions: { + // primary: [ + // new Action('Restart', isWeb ? localize('reload', "Reload") : localize('restart', "Restart"), undefined, true, () => this.hostService.restart()) + // ] + // } + // }); + // } + } + } +} diff --git a/src/vs/platform/extensionsGallery/common/extensionsGalleryConfigService.ts b/src/vs/platform/extensionsGallery/common/extensionsGalleryConfigService.ts new file mode 100644 index 00000000..b2339192 --- /dev/null +++ b/src/vs/platform/extensionsGallery/common/extensionsGalleryConfigService.ts @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) kylinIDETeam. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import { Event } from 'vs/base/common/event'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; + +export const IExtensionsGalleryConfigService = createDecorator('extensionsGalleryConfigService'); + +export interface IExtensionsGalleryConfigService { + readonly serviceUrl: string; + readonly itemUrl: string; + readonly _serviceBrand: undefined; + readonly onConfigChange: Event; +} diff --git a/src/vs/server/node/serverServices.ts b/src/vs/server/node/serverServices.ts index 019b7d37..55a85d88 100644 --- a/src/vs/server/node/serverServices.ts +++ b/src/vs/server/node/serverServices.ts @@ -77,6 +77,8 @@ import { RemoteExtensionsScannerChannel, RemoteExtensionsScannerService } from ' import { RemoteExtensionsScannerChannelName } from 'vs/platform/remote/common/remoteExtensionsScanner'; import { RemoteUserDataProfilesServiceChannel } from 'vs/platform/userDataProfile/common/userDataProfileIpc'; import { NodePtyHostStarter } from 'vs/platform/terminal/node/nodePtyHostStarter'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; +import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig'; const eventPrefix = 'monacoworkbench'; @@ -176,6 +178,7 @@ export async function setupServerServices(connectionToken: ServerConnectionToken services.set(IServerTelemetryService, ServerNullTelemetryService); } + services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService)); services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryServiceWithNoStorageService)); const downloadChannel = socketServer.getChannel('download', router); diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 79ec9c77..57eab206 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -71,6 +71,7 @@ import { ILocaleService } from 'vs/workbench/services/localization/common/locale import { isString } from 'vs/base/common/types'; import { showWindowLogActionId } from 'vs/workbench/services/log/common/logConstants'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; export class PromptExtensionInstallFailureAction extends Action { @@ -89,6 +90,7 @@ export class PromptExtensionInstallFailureAction extends Action { @IInstantiationService private readonly instantiationService: IInstantiationService, @IExtensionGalleryService private readonly galleryService: IExtensionGalleryService, @IExtensionManifestPropertiesService private readonly extensionManifestPropertiesService: IExtensionManifestPropertiesService, + @IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService, ) { super('extension.promptExtensionInstallFailure'); } @@ -177,6 +179,15 @@ export class PromptExtensionInstallFailureAction extends Action { if (!this.extensionManagementServerService.localExtensionManagementServer && !this.extensionManagementServerService.remoteExtensionManagementServer) { return undefined; } + if (!this.productService.extensionsGallery || !(this.extensionsGalleryConfigService && this.extensionsGalleryConfigService.serviceUrl)) { + return undefined; + } + let extServiceURL: string = ''; + if (this.extensionsGalleryConfigService && this.extensionsGalleryConfigService.serviceUrl) { + extServiceURL = this.extensionsGalleryConfigService.serviceUrl; + } else if (this.productService.extensionsGallery) { + extServiceURL = this.productService.extensionsGallery.serviceUrl; + } let targetPlatform = this.extension.gallery.properties.targetPlatform; if (targetPlatform !== TargetPlatform.UNIVERSAL && targetPlatform !== TargetPlatform.UNDEFINED && this.extensionManagementServerService.remoteExtensionManagementServer) { try { @@ -192,7 +203,7 @@ export class PromptExtensionInstallFailureAction extends Action { if (targetPlatform === TargetPlatform.UNKNOWN) { return undefined; } - return URI.parse(`${this.productService.extensionsGallery.serviceUrl}/publishers/${this.extension.publisher}/vsextensions/${this.extension.name}/${this.version}/vspackage${targetPlatform !== TargetPlatform.UNDEFINED ? `?targetPlatform=${targetPlatform}` : ''}`); + return URI.parse(`${extServiceURL}/publishers/${this.extension.publisher}/vsextensions/${this.extension.name}/${this.version}/vspackage${targetPlatform !== TargetPlatform.UNDEFINED ? `?targetPlatform=${targetPlatform}` : ''}`); } } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 8750e3e4..75b08f63 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -52,6 +52,7 @@ import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUti import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile'; import { mainWindow } from 'vs/base/browser/window'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; interface IExtensionStateProvider { (extension: Extension): T; @@ -82,7 +83,8 @@ export class Extension implements IExtension { @ITelemetryService private readonly telemetryService: ITelemetryService, @ILogService private readonly logService: ILogService, @IFileService private readonly fileService: IFileService, - @IProductService private readonly productService: IProductService + @IProductService private readonly productService: IProductService, + @IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService, ) { } get type(): ExtensionType { @@ -165,6 +167,14 @@ export class Extension implements IExtension { } get url(): string | undefined { + if (this.extensionsGalleryConfigService.serviceUrl) { + if (this.extensionsGalleryConfigService.itemUrl && this.gallery) { + return `${this.extensionsGalleryConfigService.itemUrl}?itemName=${this.publisher}.${this.name}`; + } else { + this.logService.info('itemUrl undefine'); + return undefined; + } + } if (!this.productService.extensionsGallery || !this.gallery) { return undefined; } diff --git a/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts b/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts index b4b225d7..ad13e924 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsLayout.ts @@ -276,6 +276,11 @@ export const tocData: ITOCEntry = { id: 'application/other', label: localize('other', "Other"), settings: ['application.*'] + }, + { + id: 'application/extensionsGallery', + label: localize('extensionsGallery', "Extensions Gallery"), + settings: ['extensionsGallery.*'] } ] }, diff --git a/src/vs/workbench/contrib/update/browser/update.contribution.ts b/src/vs/workbench/contrib/update/browser/update.contribution.ts index 1f131713..f7e5b361 100644 --- a/src/vs/workbench/contrib/update/browser/update.contribution.ts +++ b/src/vs/workbench/contrib/update/browser/update.contribution.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/platform/update/common/update.config.contribution'; +import 'vs/platform/extensionsGallery/common/extensionsGallery.config.contribution'; import { localize } from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index a943798d..8cc759c2 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -119,6 +119,8 @@ import 'vs/workbench/services/userActivity/browser/userActivityBrowser'; import 'vs/workbench/services/issue/browser/issueTroubleshoot'; import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig'; +import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService'; import { GlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionEnablementService'; import { IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement'; @@ -148,6 +150,7 @@ registerSingleton(IUserDataSyncLogService, UserDataSyncLogService, Instantiation registerSingleton(IIgnoredExtensionsManagementService, IgnoredExtensionsManagementService, InstantiationType.Delayed); registerSingleton(IGlobalExtensionEnablementService, GlobalExtensionEnablementService, InstantiationType.Delayed); registerSingleton(IExtensionStorageService, ExtensionStorageService, InstantiationType.Delayed); +registerSingleton(IExtensionsGalleryConfigService, ExtensionsGalleryConfigService, InstantiationType.Delayed); registerSingleton(IExtensionGalleryService, ExtensionGalleryService, InstantiationType.Delayed); registerSingleton(IContextViewService, ContextViewService, InstantiationType.Delayed); registerSingleton(IListService, ListService, InstantiationType.Delayed);