From 22f29a567807870ae7b2085fd500145d121c4f6e Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Thu, 22 Sep 2022 21:45:57 -0400 Subject: [PATCH] Support of selection of data provider in overview view Contributes to #55 Signed-off-by: Bernd Hufmann --- .../trace-viewer/vscode-trace-viewer-container.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vscode-trace-webviews/src/trace-viewer/vscode-trace-viewer-container.tsx b/vscode-trace-webviews/src/trace-viewer/vscode-trace-viewer-container.tsx index 723ed0c0..77b9e51b 100644 --- a/vscode-trace-webviews/src/trace-viewer/vscode-trace-viewer-container.tsx +++ b/vscode-trace-webviews/src/trace-viewer/vscode-trace-viewer-container.tsx @@ -14,6 +14,7 @@ import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client'; import { VsCodeMessageManager } from '../common/vscode-message-manager'; import '../style/trace-viewer.css'; import JSONBigConfig from 'json-bigint'; +import { signalManager, Signals } from 'traceviewer-base/lib/signals/signal-manager'; const JSONBig = JSONBigConfig({ useNativeBigInt: true, @@ -35,6 +36,8 @@ class App extends React.Component<{}, VscodeAppState> { private selectedMarkerCategoriesMap: Map = new Map(); private selectedMarkerSetId = ''; + private _onOverviewSelected = (payload: {traceId: string, outputDescriptor: OutputDescriptor}): void => this.doHandleOverviewSelectedSignal(payload); + constructor(props: {}) { super(props); this.state = { @@ -66,12 +69,17 @@ class App extends React.Component<{}, VscodeAppState> { }); this.onOutputRemoved = this.onOutputRemoved.bind(this); this.onOverviewRemoved = this.onOverviewRemoved.bind(this); + signalManager().on(Signals.OVERVIEW_OUTPUT_SELECTED, this._onOverviewSelected); } componentDidMount(): void { this._signalHandler.notifyReady(); } + componentWillUnmount(): void { + signalManager().off(Signals.OVERVIEW_OUTPUT_SELECTED, this._onOverviewSelected); + } + private onOutputRemoved(outputId: string) { const outputToKeep = this.state.outputs.filter(output => output.id !== outputId); this.setState({outputs: outputToKeep}); @@ -90,6 +98,12 @@ class App extends React.Component<{}, VscodeAppState> { } } + protected doHandleOverviewSelectedSignal(payload: {traceId: string, outputDescriptor: OutputDescriptor}): void { + if (this.state.experiment && payload && payload?.traceId === this.state.experiment.UUID && payload.outputDescriptor){ + this.setState({overviewOutputDescriptor: payload.outputDescriptor}); + } + } + protected async getDefaultTraceOverviewOutputDescriptor(experiment: Experiment| undefined): Promise { const availableDescriptors = await this.getAvailableTraceOverviewOutputDescriptor(experiment); return availableDescriptors?.find(output => output.id === this.DEFAULT_OVERVIEW_DATA_PROVIDER_ID);