From e72a422f32ef5ec5c08da0f5f8f6fbf4afcb883f Mon Sep 17 00:00:00 2001 From: Assaf Attias <49212512+attiasas@users.noreply.github.com> Date: Tue, 18 Jul 2023 12:07:46 +0300 Subject: [PATCH] Close old web view page on refresh (#377) --- src/main/commands/commandManager.ts | 10 +++++++++- .../issuesTree/issuesTreeDataProvider.ts | 2 +- src/main/webview/webview.ts | 11 ++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/commands/commandManager.ts b/src/main/commands/commandManager.ts index 6c8c90dc0..d33f07f57 100644 --- a/src/main/commands/commandManager.ts +++ b/src/main/commands/commandManager.ts @@ -165,6 +165,7 @@ export class CommandManager implements ExtensionComponent { * @param scan - True to scan the workspace, false will load from cache */ private async doRefresh(scan: boolean = true) { + this.doCloseDetailsPage(); this._diagnosticManager.clearDiagnostics(); await this._treesManager.refresh(scan); this._diagnosticManager.updateDiagnostics(); @@ -175,7 +176,14 @@ export class CommandManager implements ExtensionComponent { * @param page - data to show in webpage */ public doShowDetailsPage(page: WebviewPage) { - vscode.commands.executeCommand('jfrog.view.details.page', page); + vscode.commands.executeCommand('jfrog.view.details.page.open', page); + } + + /** + * Close current webpage if one is open + */ + public doCloseDetailsPage() { + vscode.commands.executeCommand('jfrog.view.details.page.close'); } /** diff --git a/src/main/treeDataProviders/issuesTree/issuesTreeDataProvider.ts b/src/main/treeDataProviders/issuesTree/issuesTreeDataProvider.ts index acee2b228..2b41f7bc1 100644 --- a/src/main/treeDataProviders/issuesTree/issuesTreeDataProvider.ts +++ b/src/main/treeDataProviders/issuesTree/issuesTreeDataProvider.ts @@ -414,7 +414,7 @@ export class IssuesTreeDataProvider implements vscode.TreeDataProvider this.updateWebview(page, context)) + vscode.commands.registerCommand('jfrog.view.details.page.open', (page: WebviewPage) => this.updateWebview(page, context)), + vscode.commands.registerCommand('jfrog.view.details.page.close', () => this.closeWebview()) ); } + /** + * Close, if exists, an open webview page + */ + public closeWebview() { + this._currentPage = undefined; + this._webview?.dispose(); + } + /** * Create if not exists or update the webview panel with the given page data and show it in the editor * @param data - the data of the page to be update and show in the webpage