From cea37e7e9777b7bdd545a278e07e7c433d6f931d Mon Sep 17 00:00:00 2001 From: jbicker Date: Fri, 6 Dec 2019 11:48:11 +0100 Subject: [PATCH] Added uninstall behaviour plus smaller bugfixes and adapted versions Signed-off-by: jbicker --- examples/browser/package.json | 1 + examples/electron/package.json | 1 + packages/plugin-ext/src/common/plugin-protocol.ts | 4 ++++ .../src/hosted/node/hosted-plugin-deployer-handler.ts | 9 +++++++++ .../plugin-ext/src/main/node/plugin-deployer-impl.ts | 5 +++++ .../plugin-ext/src/main/node/plugin-server-handler.ts | 4 ++++ packages/vsx-registry/package.json | 8 ++++---- .../src/browser/view/list/vsx-registry-list-widget.tsx | 9 +++++++-- .../src/browser/view/list/vsx-registry-widget.ts | 1 + .../vsx-registry/src/browser/vsx-registry-service.ts | 9 ++++----- 10 files changed, 40 insertions(+), 11 deletions(-) diff --git a/examples/browser/package.json b/examples/browser/package.json index 3b8526299f5b2..f2d1e9b31bd93 100644 --- a/examples/browser/package.json +++ b/examples/browser/package.json @@ -59,6 +59,7 @@ "@theia/typescript": "^0.13.0", "@theia/userstorage": "^0.13.0", "@theia/variable-resolver": "^0.13.0", + "@theia/vsx-registry": "^0.13.0", "@theia/workspace": "^0.13.0" }, "scripts": { diff --git a/examples/electron/package.json b/examples/electron/package.json index 4ef11436ab8ad..ab22d34931051 100644 --- a/examples/electron/package.json +++ b/examples/electron/package.json @@ -55,6 +55,7 @@ "@theia/typescript": "^0.13.0", "@theia/userstorage": "^0.13.0", "@theia/variable-resolver": "^0.13.0", + "@theia/vsx-registry": "^0.13.0", "@theia/workspace": "^0.13.0" }, "scripts": { diff --git a/packages/plugin-ext/src/common/plugin-protocol.ts b/packages/plugin-ext/src/common/plugin-protocol.ts index c2acff87e9300..1a8b1e982e537 100644 --- a/packages/plugin-ext/src/common/plugin-protocol.ts +++ b/packages/plugin-ext/src/common/plugin-protocol.ts @@ -626,6 +626,8 @@ export interface PluginDeployerHandler { deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise; deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise; + removeDeployedPluginId(pluginId: string): void; + getPluginDependencies(pluginToBeInstalled: PluginDeployerEntry): Promise } @@ -670,6 +672,8 @@ export interface PluginServer { */ deploy(pluginEntry: string): Promise; + undeploy(pluginId: string): Promise; + setStorageValue(key: string, value: KeysToAnyValues, kind: PluginStorageKind): Promise; getStorageValue(key: string, kind: PluginStorageKind): Promise; getAllStorageValues(kind: PluginStorageKind): Promise; diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts index 28f9726eaa59b..dd81d3129bceb 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts @@ -57,6 +57,15 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler { return [...this.deployedBackendPlugins.keys()]; } + removeDeployedPluginId(pluginId: string): void { + if (this.deployedBackendPlugins.get(pluginId)) { + this.deployedBackendPlugins.delete(pluginId); + } + if (this.deployedFrontendPlugins.get(pluginId)) { + this.deployedFrontendPlugins.delete(pluginId); + } + } + getDeployedPlugin(pluginId: string): DeployedPlugin | undefined { const metadata = this.deployedBackendPlugins.get(pluginId); if (metadata) { diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts index d4bb7b49e0ebf..fc0ae848adf10 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts @@ -104,6 +104,11 @@ export class PluginDeployerImpl implements PluginDeployer { } + public async undeploy(pluginId: string): Promise { + this.pluginDeployerHandler.removeDeployedPluginId(pluginId); + this.onDidDeployEmitter.fire(); + } + public async deploy(pluginEntry: string): Promise { await this.deployMultipleEntries([pluginEntry]); } diff --git a/packages/plugin-ext/src/main/node/plugin-server-handler.ts b/packages/plugin-ext/src/main/node/plugin-server-handler.ts index 0251579fdccee..d0f0f471250fb 100644 --- a/packages/plugin-ext/src/main/node/plugin-server-handler.ts +++ b/packages/plugin-ext/src/main/node/plugin-server-handler.ts @@ -33,6 +33,10 @@ export class PluginServerHandler implements PluginServer { return this.pluginDeployer.deploy(pluginEntry); } + undeploy(pluginId: string): Promise { + return this.pluginDeployer.undeploy(pluginId); + } + setStorageValue(key: string, value: KeysToAnyValues, kind: PluginStorageKind): Promise { return this.pluginsKeyValueStorage.set(key, value, kind); } diff --git a/packages/vsx-registry/package.json b/packages/vsx-registry/package.json index f7091cb0d647d..4f9eac9bacc93 100644 --- a/packages/vsx-registry/package.json +++ b/packages/vsx-registry/package.json @@ -1,10 +1,10 @@ { "name": "@theia/vsx-registry", - "version": "0.12.0", + "version": "0.13.0", "description": "Theia - VSX Registry", "dependencies": { - "@theia/core": "^0.12.0", - "@theia/plugin-ext": "^0.12.0", + "@theia/core": "^0.13.0", + "@theia/plugin-ext": "^0.13.0", "@types/sanitize-html": "^1.13.31", "@types/showdown": "^1.7.1", "sanitize-html": "^1.14.1", @@ -42,7 +42,7 @@ "test": "theiaext test" }, "devDependencies": { - "@theia/ext-scripts": "^0.12.0" + "@theia/ext-scripts": "^0.13.0" }, "nyc": { "extends": "../../configs/nyc.json" diff --git a/packages/vsx-registry/src/browser/view/list/vsx-registry-list-widget.tsx b/packages/vsx-registry/src/browser/view/list/vsx-registry-list-widget.tsx index 82074414adc07..024ddd0506fb6 100644 --- a/packages/vsx-registry/src/browser/view/list/vsx-registry-list-widget.tsx +++ b/packages/vsx-registry/src/browser/view/list/vsx-registry-list-widget.tsx @@ -61,9 +61,14 @@ export class VSXRegistryListWidget extends ReactWidget { this.title.label = this.options.label; this.model.onExtensionsChanged(() => { - this.extensions = this.model.getExtensionsByLocation(this.options.location); - this.update(); + this.updateExtensionList(); }); + this.updateExtensionList(); + } + + protected updateExtensionList(): void { + this.extensions = this.model.getExtensionsByLocation(this.options.location); + this.update(); } protected render(): React.ReactNode { diff --git a/packages/vsx-registry/src/browser/view/list/vsx-registry-widget.ts b/packages/vsx-registry/src/browser/view/list/vsx-registry-widget.ts index 66c98012fd102..ccf7027c47d40 100644 --- a/packages/vsx-registry/src/browser/view/list/vsx-registry-widget.ts +++ b/packages/vsx-registry/src/browser/view/list/vsx-registry-widget.ts @@ -109,6 +109,7 @@ export class VSXRegistryWidget extends ViewContainer { }); this.panel.node.tabIndex = -1; layout.addWidget(this.vscxSearchbar); + this.vscxSearchbar.update(); layout.addWidget(this.panel); } } diff --git a/packages/vsx-registry/src/browser/vsx-registry-service.ts b/packages/vsx-registry/src/browser/vsx-registry-service.ts index 6529686d8dbc6..f185021b62194 100644 --- a/packages/vsx-registry/src/browser/vsx-registry-service.ts +++ b/packages/vsx-registry/src/browser/vsx-registry-service.ts @@ -52,9 +52,10 @@ export class VSXRegistryService { protected async init(): Promise { this.vsxRegistryPreferences.onPreferenceChanged(e => { this.apiUrl = this.vsxRegistryPreferences['vsx-registry.api-url']; + this.toDispose.push(this.pluginSupport.onDidChangePlugins(() => this.updateInstalled())); this.updateSearch(); + this.updateInstalled(); }); - this.toDispose.push(this.pluginSupport.onDidChangePlugins(() => this.updateInstalled())); } protected createEndpoint(arr: string[], queries?: { key: string, value: string | number }[]): string { @@ -100,10 +101,8 @@ export class VSXRegistryService { } async uninstall(extension: VSCodeExtensionPart): Promise { - let res: () => void; - const p = new Promise(r => res = r); - setTimeout(() => res(), 3000); - return p; + const id = extension.publisher.toLowerCase() + '.' + extension.name.toLowerCase(); + await this.pluginServer.undeploy(id); } async outdated(): Promise {