From a2c713444111bbee7d3f52a461899ff4b07aef3c Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Thu, 22 Sep 2022 22:18:18 -0400 Subject: [PATCH] Add command to open overview view when closed Contributes to #55 Signed-off-by: Bernd Hufmann --- vscode-trace-extension/package.json | 5 +++++ vscode-trace-extension/src/extension.ts | 6 +++++- vscode-trace-extension/src/trace-explorer/trace-tree.ts | 4 ++++ .../src/trace-viewer-panel/trace-viewer-webview-panel.ts | 8 ++++++++ .../src/trace-viewer/vscode-trace-viewer-container.tsx | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/vscode-trace-extension/package.json b/vscode-trace-extension/package.json index d2e4d4b0..07c2fe8d 100644 --- a/vscode-trace-extension/package.json +++ b/vscode-trace-extension/package.json @@ -21,6 +21,11 @@ ], "contributes": { "commands": [ + { + "command": "outputs.openOverview", + "title": "Open Overview View", + "icon": "assets/media/chart-line-solid.svg" + }, { "command": "traces.openTrace", "title": "Open Trace", diff --git a/vscode-trace-extension/src/extension.ts b/vscode-trace-extension/src/extension.ts index ac3266aa..bac501cf 100644 --- a/vscode-trace-extension/src/extension.ts +++ b/vscode-trace-extension/src/extension.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode'; import { AnalysisProvider } from './trace-explorer/analysis-tree'; import { TraceExplorerAvailableViewsProvider } from './trace-explorer/views/trace-explorer-available-views-webview-provider'; import { TraceExplorerOpenedTracesViewProvider } from './trace-explorer/opened-traces/trace-explorer-opened-traces-webview-provider'; -import { fileHandler } from './trace-explorer/trace-tree'; +import { fileHandler, openOverviewHandler } from './trace-explorer/trace-tree'; import { updateTspClient } from './utils/tspClient'; export function activate(context: vscode.ExtensionContext): void { @@ -30,4 +30,8 @@ export function activate(context: vscode.ExtensionContext): void { } })); + const overViewOpenHanlder = openOverviewHandler(); + context.subscriptions.push(vscode.commands.registerCommand('outputs.openOverview', () => { + overViewOpenHanlder(); + })); } diff --git a/vscode-trace-extension/src/trace-explorer/trace-tree.ts b/vscode-trace-extension/src/trace-explorer/trace-tree.ts index 27604eef..75914dba 100644 --- a/vscode-trace-extension/src/trace-explorer/trace-tree.ts +++ b/vscode-trace-extension/src/trace-explorer/trace-tree.ts @@ -89,6 +89,10 @@ export const traceHandler = (analysisTree: AnalysisProvider) => (context: vscode })(); }; +export const openOverviewHandler = () => (): void => { + TraceViewerPanel.showOverviewToCurrent(); +}; + export const fileHandler = (analysisTree: AnalysisProvider) => (context: vscode.ExtensionContext, file: vscode.Uri): void => { const uri: string = file.path; if (!uri) { diff --git a/vscode-trace-extension/src/trace-viewer-panel/trace-viewer-webview-panel.ts b/vscode-trace-extension/src/trace-viewer-panel/trace-viewer-webview-panel.ts index 12a5e1dd..ec71fe8d 100644 --- a/vscode-trace-extension/src/trace-viewer-panel/trace-viewer-webview-panel.ts +++ b/vscode-trace-extension/src/trace-viewer-panel/trace-viewer-webview-panel.ts @@ -65,6 +65,10 @@ export class TraceViewerPanel { TraceViewerPanel.currentPanel?.addOutput(descriptor); } + public static showOverviewToCurrent(): void { + TraceViewerPanel.currentPanel?.showOverview(); + } + private constructor(extensionUri: vscode.Uri, column: vscode.ViewColumn, name: string) { this._extensionUri = extensionUri; // Create and show a new webview panel @@ -167,6 +171,10 @@ export class TraceViewerPanel { this._panel.webview.postMessage({command: 'add-output', data: wrapper}); } + showOverview(): void { + this._panel.webview.postMessage({command: 'open-overview'}); + } + private _getHtmlForWebview() { try { return this._getReactHtmlForWebview(); 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 84511b30..f261ce04 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 @@ -65,6 +65,8 @@ class App extends React.Component<{}, VscodeAppState> { const descriptor = JSONBig.parse(message.data); this.setState({outputs: [...this.state.outputs, descriptor] }); break; + case 'open-overview': + this.doHandleExperimentSetSignal(this.state.experiment); } }); this.onOutputRemoved = this.onOutputRemoved.bind(this);