Skip to content

Commit

Permalink
Close old web view page on refresh (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas authored Jul 18, 2023
1 parent 6af72d0 commit e72a422
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/main/commands/commandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export class IssuesTreeDataProvider implements vscode.TreeDataProvider<IssuesRoo
}
// Descriptor issues nodes
if (element instanceof CveTreeNode || element instanceof LicenseIssueTreeNode) {
element.command = Utils.createNodeCommand('jfrog.view.details.page', 'Show details', [element.getDetailsPage()]);
element.command = Utils.createNodeCommand('jfrog.view.details.page.open', 'Show details', [element.getDetailsPage()]);
}
// Source code issues nodes
if (
Expand Down
11 changes: 10 additions & 1 deletion src/main/webview/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ export class WebView {

public async activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand('jfrog.view.details.page', (page: WebviewPage) => 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
Expand Down

0 comments on commit e72a422

Please sign in to comment.