mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #31487 from excerebrose/extensions-repository-url
Displaying Repository URL (Git Link) on Extensions Page.
This commit is contained in:
commit
3c3395c685
|
@ -133,6 +133,7 @@ export interface IGalleryExtensionAssets {
|
|||
download: IGalleryExtensionAsset;
|
||||
icon: IGalleryExtensionAsset;
|
||||
license: IGalleryExtensionAsset;
|
||||
repository: IGalleryExtensionAsset;
|
||||
}
|
||||
|
||||
export interface IExtensionIdentifier {
|
||||
|
|
|
@ -106,6 +106,7 @@ const AssetType = {
|
|||
Manifest: 'Microsoft.VisualStudio.Code.Manifest',
|
||||
VSIX: 'Microsoft.VisualStudio.Services.VSIXPackage',
|
||||
License: 'Microsoft.VisualStudio.Services.Content.License',
|
||||
Repository: 'Microsoft.VisualStudio.Services.Links.Source'
|
||||
};
|
||||
|
||||
const PropertyType = {
|
||||
|
@ -199,6 +200,25 @@ function getStatistic(statistics: IRawGalleryExtensionStatistics[], name: string
|
|||
function getVersionAsset(version: IRawGalleryExtensionVersion, type: string): IGalleryExtensionAsset {
|
||||
const result = version.files.filter(f => f.assetType === type)[0];
|
||||
|
||||
if (type === AssetType.Repository) {
|
||||
const results = version.properties.filter(p => p.key === type);
|
||||
const gitRegExp = new RegExp('((git|ssh|http(s)?)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git)(/)?');
|
||||
|
||||
const uri = results.filter(r => gitRegExp.test(r.value))[0];
|
||||
if (!uri) {
|
||||
return {
|
||||
uri: null,
|
||||
fallbackUri: null
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
uri: uri.value,
|
||||
fallbackUri: uri.value,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
if (type === AssetType.Icon) {
|
||||
const uri = require.toUrl('./media/defaultIcon.png');
|
||||
|
@ -240,7 +260,8 @@ function toExtension(galleryExtension: IRawGalleryExtension, extensionsGalleryUr
|
|||
changelog: getVersionAsset(version, AssetType.Changelog),
|
||||
download: getVersionAsset(version, AssetType.VSIX),
|
||||
icon: getVersionAsset(version, AssetType.Icon),
|
||||
license: getVersionAsset(version, AssetType.License)
|
||||
license: getVersionAsset(version, AssetType.License),
|
||||
repository: getVersionAsset(version, AssetType.Repository),
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -157,6 +157,7 @@ export class ExtensionEditor extends BaseEditor {
|
|||
private publisher: HTMLElement;
|
||||
private installCount: HTMLElement;
|
||||
private rating: HTMLElement;
|
||||
private repository: HTMLElement;
|
||||
private description: HTMLElement;
|
||||
private extensionActionBar: ActionBar;
|
||||
private navbar: NavBar;
|
||||
|
@ -222,6 +223,10 @@ export class ExtensionEditor extends BaseEditor {
|
|||
|
||||
this.rating = append(subtitle, $('span.rating.clickable', { title: localize('rating', "Rating") }));
|
||||
|
||||
this.repository = append(subtitle, $('span.repository.clickable'));
|
||||
this.repository.textContent = localize('repository', 'Repository');
|
||||
this.repository.style.display = 'none';
|
||||
|
||||
this.license = append(subtitle, $('span.license.clickable'));
|
||||
this.license.textContent = localize('license', 'License');
|
||||
this.license.style.display = 'none';
|
||||
|
@ -311,6 +316,15 @@ export class ExtensionEditor extends BaseEditor {
|
|||
}
|
||||
}
|
||||
|
||||
if (extension.repository) {
|
||||
this.repository.onclick = finalHandler(() => window.open(extension.repository));
|
||||
this.repository.style.display = 'initial';
|
||||
}
|
||||
else {
|
||||
this.repository.onclick = null;
|
||||
this.repository.style.display = 'none';
|
||||
}
|
||||
|
||||
const install = this.instantiationService.createInstance(InstallWidget, this.installCount, { extension });
|
||||
this.transientDisposables.push(install);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ export interface IExtension {
|
|||
latestVersion: string;
|
||||
description: string;
|
||||
url: string;
|
||||
repository: string;
|
||||
iconUrl: string;
|
||||
iconUrlFallback: string;
|
||||
licenseUrl: string;
|
||||
|
|
|
@ -141,6 +141,10 @@ class Extension implements IExtension {
|
|||
return require.toUrl('../browser/media/defaultIcon.png');
|
||||
}
|
||||
|
||||
get repository(): string {
|
||||
return this.gallery && this.gallery.assets.repository.uri;
|
||||
}
|
||||
|
||||
get licenseUrl(): string {
|
||||
return this.gallery && this.gallery.assets.license && this.gallery.assets.license.uri;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,8 @@ suite('ExtensionsWorkbenchService Test', () => {
|
|||
changelog: { uri: 'uri:changelog', fallbackUri: 'fallback:changlog' },
|
||||
download: { uri: 'uri:download', fallbackUri: 'fallback:download' },
|
||||
icon: { uri: 'uri:icon', fallbackUri: 'fallback:icon' },
|
||||
license: { uri: 'uri:license', fallbackUri: 'fallback:license' }
|
||||
license: { uri: 'uri:license', fallbackUri: 'fallback:license' },
|
||||
repository: { uri: 'uri:repository', fallbackUri: 'fallback:repository' },
|
||||
});
|
||||
|
||||
testObject = instantiationService.createInstance(ExtensionsWorkbenchService);
|
||||
|
@ -250,7 +251,8 @@ suite('ExtensionsWorkbenchService Test', () => {
|
|||
changelog: { uri: 'uri:changelog', fallbackUri: 'fallback:changlog' },
|
||||
download: { uri: 'uri:download', fallbackUri: 'fallback:download' },
|
||||
icon: { uri: 'uri:icon', fallbackUri: 'fallback:icon' },
|
||||
license: { uri: 'uri:license', fallbackUri: 'fallback:license' }
|
||||
license: { uri: 'uri:license', fallbackUri: 'fallback:license' },
|
||||
repository: { uri: 'uri:repository', fallbackUri: 'fallback:repository' },
|
||||
});
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local1, local2]);
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery1));
|
||||
|
@ -996,7 +998,8 @@ suite('ExtensionsWorkbenchService Test', () => {
|
|||
icon: null,
|
||||
license: null,
|
||||
manifest: null,
|
||||
readme: null
|
||||
readme: null,
|
||||
repository: null
|
||||
};
|
||||
|
||||
function aGalleryExtension(name: string, properties: any = {}, galleryExtensionProperties: any = {}, assets: IGalleryExtensionAssets = noAssets): IGalleryExtension {
|
||||
|
|
Loading…
Reference in a new issue