Skip to content

Commit

Permalink
CB-3977 remove connection from resource on driver delete (#2428)
Browse files Browse the repository at this point in the history
Co-authored-by: Daria Marutkina <[email protected]>
  • Loading branch information
devnaumov and dariamarutkina authored Mar 15, 2024
1 parent 826d0c6 commit 25b895c
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { schemaValidationError } from '@cloudbeaver/core-utils';
import { CONNECTION_INFO_PARAM_SCHEMA, type IConnectionInfoParams } from './CONNECTION_INFO_PARAM_SCHEMA';
import { ConnectionInfoEventHandler, IConnectionInfoEvent } from './ConnectionInfoEventHandler';
import type { DatabaseConnection } from './DatabaseConnection';
import { DBDriverResource } from './DBDriverResource';

export type Connection = DatabaseConnection & {
authProperties?: UserConnectionAuthPropertiesFragment[];
Expand Down Expand Up @@ -89,6 +90,7 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
private readonly projectsService: ProjectsService,
private readonly projectInfoResource: ProjectInfoResource,
private readonly dataSynchronizationService: DataSynchronizationService,
dbDriverResource: DBDriverResource,
sessionDataResource: SessionDataResource,
appAuthService: AppAuthService,
connectionInfoEventHandler: ConnectionInfoEventHandler,
Expand All @@ -114,6 +116,11 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
this.onItemDelete.addHandler(ExecutorInterrupter.interrupter(() => this.sessionUpdate));
this.onConnectionCreate.addHandler(ExecutorInterrupter.interrupter(() => this.sessionUpdate));

dbDriverResource.onItemDelete.addHandler(data => {
const hiddenConnections = this.values.filter(connection => connection.driverId === data);
this.delete(resourceKeyList(hiddenConnections.map(connection => createConnectionParam(connection))));
});

userInfoResource.onUserChange.addHandler(() => {
this.clear();
});
Expand Down

0 comments on commit 25b895c

Please sign in to comment.