dbeaver/pro#6605 fix: reset filters on logout

This commit adds onLogout handler in DataViewerTabService which disposes opened tabs on logout.

Previously we didn't handle that at all and model was persisted in the memory after logout. On next login, if there was any filters, we would try to send them to backend and got an error, because backend doesn't support initial requests(without resultId) with filters.

The main logic of a handler repeats the already existed onDisconnect handler logic, which was extracted to handleTabsCleanup method. The difference between handlers is only in a set of tabs(onLogout we dispose all of them, onDisconnect - only tabs of a selected connection) and ability to interrupt the process.
This commit is contained in:
Sychev Andrey
2025-08-19 16:27:55 +02:00
parent 901669b802
commit d124b444c7
4 changed files with 36 additions and 5 deletions
@@ -38,6 +38,7 @@
"@cloudbeaver/core-ui": "workspace:*",
"@cloudbeaver/core-utils": "workspace:*",
"@cloudbeaver/core-view": "workspace:*",
"@cloudbeaver/plugin-authentication": "workspace:*",
"@cloudbeaver/plugin-codemirror6": "workspace:*",
"@cloudbeaver/plugin-navigation-tabs": "workspace:*",
"@cloudbeaver/plugin-object-viewer": "workspace:*",
@@ -20,6 +20,7 @@ import {
ObjectPage,
ObjectViewerTabService,
} from '@cloudbeaver/plugin-object-viewer';
import { AuthenticationService } from '@cloudbeaver/plugin-authentication';
import type { IDataViewerPageState } from './IDataViewerPageState.js';
import { TableViewerStorageService } from './TableViewer/TableViewerStorageService.js';
@@ -40,6 +41,7 @@ export class DataViewerTabService {
private readonly navigationTabsService: NavigationTabsService,
private readonly connectionInfoResource: ConnectionInfoResource,
private readonly tableViewerStorageService: TableViewerStorageService,
private readonly authService: AuthenticationService,
) {
this.page = this.dbObjectPageService.register({
key: 'data_viewer_data',
@@ -54,8 +56,9 @@ export class DataViewerTabService {
});
}
register() {
register(): void {
this.connectionsManagerService.onDisconnect.addHandler(this.disconnectHandler.bind(this));
this.authService.onLogout.addHandler(this.logoutHandler.bind(this));
}
registerTabHandler(): void {
@@ -75,12 +78,35 @@ export class DataViewerTabService {
),
);
await this.handleTabsCleanup(tabs, {
canInterrupt: data.state === 'before',
contexts,
});
}
private async logoutHandler() {
const tabs = Array.from(
this.navigationTabsService.findTabs(tab => isObjectViewerTab(tab)),
);
await this.handleTabsCleanup(tabs, {
canInterrupt: false,
});
}
private async handleTabsCleanup(
tabs: ITab<IObjectViewerTabState>[],
options: {
canInterrupt: boolean;
contexts?: IExecutionContextProvider<any>;
}
) {
for (const tab of tabs) {
if (data.state === 'before') {
if (options.canInterrupt) {
const canDisconnect = await this.handleTabCanClose(tab);
if (!canDisconnect) {
ExecutorInterrupter.interrupt(contexts);
if (!canDisconnect && options.contexts) {
ExecutorInterrupter.interrupt(options.contexts);
return;
}
} else if (isObjectViewerTab(tab) && tab.handlerState.tableId) {
@@ -109,7 +135,7 @@ export class DataViewerTabService {
}
}
private handleTabRestore(tab: ITab<IObjectViewerTabState>) {
private handleTabRestore(): boolean {
return true;
}
@@ -73,6 +73,9 @@
{
"path": "../core-view"
},
{
"path": "../plugin-authentication"
},
{
"path": "../plugin-codemirror6"
},
+1
View File
@@ -2905,6 +2905,7 @@ __metadata:
"@cloudbeaver/core-ui": "workspace:*"
"@cloudbeaver/core-utils": "workspace:*"
"@cloudbeaver/core-view": "workspace:*"
"@cloudbeaver/plugin-authentication": "workspace:*"
"@cloudbeaver/plugin-codemirror6": "workspace:*"
"@cloudbeaver/plugin-navigation-tabs": "workspace:*"
"@cloudbeaver/plugin-object-viewer": "workspace:*"