Generalized the list item renderers.

To support update/downgrade.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2019-11-22 11:42:39 +01:00
parent 63cd2701b4
commit c3e2aa4feb
9 changed files with 84 additions and 156 deletions

View File

@@ -59,7 +59,7 @@ export class CoreClientProviderImpl implements CoreClientProvider {
resolve(undefined);
return
}
if (!workspaceRootOrResourceUri) {
resolve(this.getOrCreateClient(roots[0]));
return;

View File

@@ -1,8 +1,10 @@
import { injectable, inject } from 'inversify';
import { Library, LibraryService } from '../common/protocol/library-service';
import { CoreClientProvider } from './core-client-provider';
import { LibrarySearchReq, LibrarySearchResp, LibraryListReq, LibraryListResp, LibraryRelease,
InstalledLibrary, LibraryInstallReq, LibraryInstallResp } from './cli-protocol/commands/lib_pb';
import {
LibrarySearchReq, LibrarySearchResp, LibraryListReq, LibraryListResp, LibraryRelease,
InstalledLibrary, LibraryInstallReq, LibraryInstallResp
} from './cli-protocol/commands/lib_pb';
import { ToolOutputServiceServer } from '../common/protocol/tool-output-service';
import { Installable } from '../common/protocol/installable';
@@ -44,6 +46,7 @@ export class LibraryServiceImpl implements LibraryService {
.filter(item => !!item.getLatest())
.slice(0, 50)
.map(item => {
const availableVersions = item.getReleasesMap().getEntryList().map(([key, _]) => key);
let installedVersion: string | undefined;
const installed = installedLibsIdx.get(item.getName());
if (installed) {
@@ -52,8 +55,8 @@ export class LibraryServiceImpl implements LibraryService {
return toLibrary({
name: item.getName(),
installable: true,
installedVersion
}, item.getLatest()!)
installedVersion,
}, item.getLatest()!, availableVersions)
})
return { items };
@@ -88,14 +91,14 @@ export class LibraryServiceImpl implements LibraryService {
}
function toLibrary(tpl: Partial<Library>, release: LibraryRelease): Library {
function toLibrary(tpl: Partial<Library>, release: LibraryRelease, availableVersions: string[]): Library {
return {
name: "",
installable: false,
...tpl,
author: release.getAuthor(),
availableVersions: [release.getVersion()],
availableVersions,
description: release.getSentence(),
moreInfoLink: release.getWebsite(),
summary: release.getParagraph()