From f7e6c495131b62cbe9a1aeb997f710958defcaf2 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Thu, 2 Nov 2023 13:49:13 -0400 Subject: [PATCH] Call TSP endpoint to close an experiment when closing it in the UI With this it's possible to close an experiment on the server. Upon reception of the command the server can dispose allocated resources hence the client doesn't need them anymore. This change follows the TSP update provided by: https://github.com/eclipse-cdt-cloud/trace-server-protocol/pull/95 Fixes #1024 Signed-off-by: Bernd Hufmann --- packages/base/src/experiment-manager.ts | 11 +++++++++++ .../src/browser/theia-rpc-tsp-proxy.ts | 9 +++++++++ .../theia-trace-explorer-opened-traces-widget.tsx | 3 ++- .../src/browser/trace-viewer/trace-viewer.tsx | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/base/src/experiment-manager.ts b/packages/base/src/experiment-manager.ts index f20491dd8..7a9893091 100644 --- a/packages/base/src/experiment-manager.ts +++ b/packages/base/src/experiment-manager.ts @@ -121,6 +121,17 @@ export class ExperimentManager { return undefined; } + /** + * Close the given experiment from the server + * @param experimentUUID experiment UUID + */ + async closeExperiment(experimentUUID: string): Promise { + const experimentToDelete = this.fOpenExperiments.get(experimentUUID); + if (experimentToDelete) { + await this.fTspClient.closeExperiment(experimentUUID); + } + } + /** * Delete the given experiment from the server * @param experimentUUID experiment UUID diff --git a/theia-extensions/viewer-prototype/src/browser/theia-rpc-tsp-proxy.ts b/theia-extensions/viewer-prototype/src/browser/theia-rpc-tsp-proxy.ts index 50a3d00d2..e5f576108 100644 --- a/theia-extensions/viewer-prototype/src/browser/theia-rpc-tsp-proxy.ts +++ b/theia-extensions/viewer-prototype/src/browser/theia-rpc-tsp-proxy.ts @@ -112,6 +112,15 @@ export class TheiaRpcTspProxy implements ITspClient { return this.toTspClientResponse(await this.tspClient.updateExperiment(expUUID, parameters)); } + /** + * Close an experiment + * @param expUUID Experiment UUID to close + * @returns The closed experiment + */ + public async closeExperiment(expUUID: string): Promise> { + return this.toTspClientResponse(await this.tspClient.closeExperiment(expUUID)); + } + /** * Delete an experiment on the server * @param expUUID Experiment UUID to delete diff --git a/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/theia-trace-explorer-opened-traces-widget.tsx b/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/theia-trace-explorer-opened-traces-widget.tsx index 90e854555..2bee26b37 100644 --- a/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/theia-trace-explorer-opened-traces-widget.tsx +++ b/theia-extensions/viewer-prototype/src/browser/trace-explorer/trace-explorer-sub-widgets/theia-trace-explorer-opened-traces-widget.tsx @@ -67,11 +67,12 @@ export class TraceExplorerOpenedTracesWidget extends ReactWidget { public closeExperiment(traceUUID: string): void { signalManager().fireCloseTraceViewerTabSignal(traceUUID); + this._experimentManager.closeExperiment(traceUUID); } public deleteExperiment(traceUUID: string): void { - this._experimentManager.deleteExperiment(traceUUID); this.closeExperiment(traceUUID); + this._experimentManager.deleteExperiment(traceUUID); } render(): React.ReactNode { diff --git a/theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx b/theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx index 416ebcf59..685159a09 100644 --- a/theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx +++ b/theia-extensions/viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx @@ -349,6 +349,7 @@ export class TraceViewerWidget extends ReactWidget implements StatefulWidget { super.onCloseRequest(msg); if (this.openedExperiment) { signalManager().fireExperimentClosedSignal(this.openedExperiment); + this.experimentManager.closeExperiment(this.openedExperiment.UUID); } }