Skip to content

Commit

Permalink
Fixed #149: Added download URL to search entry versions
Browse files Browse the repository at this point in the history
  • Loading branch information
spoenemann committed Aug 12, 2020
1 parent 4a45936 commit e82f296
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,17 @@ private SearchEntryJson toSearchEntry(ExtensionSearch searchItem, String serverU
entry.files.put(FileResource.ICON, createApiUrl(serverUrl, "api", entry.namespace, entry.name, entry.version, "file", extVer.getIconFileName()));
var allVersions = Lists.newArrayList(repositories.findVersions(extension));
Collections.sort(allVersions, ExtensionVersion.SORT_COMPARATOR);
entry.allVersions = CollectionUtil.map(allVersions, ev -> toVersionReference(ev, serverUrl));
entry.allVersions = CollectionUtil.map(allVersions, ev -> toVersionReference(ev, entry, serverUrl));
return entry;
}

private SearchEntryJson.VersionReference toVersionReference(ExtensionVersion extVersion, String serverUrl) {
private SearchEntryJson.VersionReference toVersionReference(ExtensionVersion extVersion, SearchEntryJson entry, String serverUrl) {
var json = new SearchEntryJson.VersionReference();
json.version = extVersion.getVersion();
json.engines = extVersion.getEnginesMap();
json.url = createApiUrl(serverUrl, "api", extVersion.getExtension().getNamespace().getName(), extVersion.getExtension().getName(), extVersion.getVersion());
json.url = createApiUrl(serverUrl, "api", entry.namespace, entry.name, extVersion.getVersion());
json.files = new LinkedHashMap<>();
json.files.put(FileResource.DOWNLOAD, createApiUrl(serverUrl, "api", entry.namespace, entry.name, extVersion.getVersion(), "file", extVersion.getExtensionFileName()));
return json;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static class VersionReference {

public String url;

// key: file type (see constants in FileResource), value: url
public Map<String, String> files;

public String version;

public Map<String, String> engines;
Expand Down
2 changes: 2 additions & 0 deletions webui/src/extension-registry-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface SearchEntry {
timestamp?: string;
allVersions: {
url: UrlString;
// key: file type, value: url
files: { [id: string]: UrlString };
version: string;
// key: engine, value: version constraint
engines?: { [engine: string]: string };
Expand Down

0 comments on commit e82f296

Please sign in to comment.